Web Hacking — Scanning & Enumeration¶
Scanning and enumeration is the phase after basic recon where we go service-by-service: once a port is known to be open (from Reconnaissance), the goal here is to find out exactly what is listening on it, which version, and whether it can be enumerated or brute-forced further. Most of the workflow below is built around Metasploit's auxiliary/scanner modules, one module family per protocol.
Metasploit basics¶
- Why use a database backend: Metasploit can store scan results (hosts, services, vulns) in a Postgres database so results from Nmap and other scans can be imported, queried, and reused across a whole engagement instead of scrolling back through terminal output.
- List/manage workspaces (keeps different targets/engagements separate):
- Import Nmap XML scan results into the current workspace:
- Confirm data imported successfully:
- Set a global variable (e.g. so
RHOSTdoesn't need to be re-typed for every module):
Web (80/443)¶
- assetfinder (built into Kali) also works for finding subdomains here.
- Search for general HTTP auxiliary scripts:
- Identify the HTTP server version:
- Pull HTTP response headers:
- Scan
robots.txtcontent:
- Scan/brute-force directories:
- HTTP file scanner:
- Brute-force an HTTP login form:
- Enumerate Apache users:
SMB (445)¶
- SMB (Server Message Block) is used to share files/printers on a network — misconfigured shares or weak accounts here are a common foothold.
RHOSTis set to the victim's IP. General flow: search for a scanner, get the version/name disclosure, then dig into shares/users.- Search for SMB scanners:
- Identify SMB version (note: the OS guess isn't always correct):
- Brute-force/enumerate SMB usernames:
- Get extra info about the currently selected module:
- Enumerate available shares:
- Brute-force the SMB login:
use auxiliray/scanner/smb/smb_login
set SMBUser admin
set PASS_FILE /usr/share/metasploit-framework/data/wordlists/unix_passwords.txt
- Once credentials are known, list shares directly:
- Access a specific share:
FTP (21)¶
- Search for general FTP scripts:
- Identify the FTP server version:
- Why identify the version first: once the exact FTP daemon/version is known, a targeted exploit search is far more likely to hit than trying exploits blind:
- Brute-force the FTP login:
- Common username wordlist for the brute force:
- Common password wordlist for the brute force:
SSH (22)¶
- Search for SSH scanner scripts:
- Identify SSH version:
- Normal password brute force:
- If the target uses public-key authentication instead:
SMTP (25/465/587)¶
- Search for SMTP scanner scripts:
- Identify SMTP version:
- Enumerate valid SMTP users:
MySQL (3306)¶
- Search for MySQL scanner scripts:
- Identify MySQL version:
- Brute-force the MySQL login:
- After gaining admin privileges, enumerate the database:
- Run arbitrary SQL queries once authenticated:
How to exploit¶
Once a service/version is identified, there are two general approaches to actually exploiting it:
- Use Metasploit — one of the best options when a matching module already exists (fastest, most reliable for known vulnerabilities).
- Manual exploitation — needed when no Metasploit module exists, or when more control over the exploit is required.
Exploits¶
- searchsploit — searches the Exploit-DB database locally for a specific exploit matching a service/version identified during enumeration.
Nessus¶
- Vulnerability scanner referenced as part of the overall methodology alongside Nmap/Nikto — no additional configuration/usage notes were captured in the source material for this page.
Backup files¶
- To enumerate a website looking for exposed backup files, use the BackupFinder extension in Burp Suite.
Nmap — practical example (Academy, THM)¶
Nmap is used to expose all the working ports on a specific machine before deciding where to dig in further.
Chain overview:
flowchart TD
A["Nmap port scan<br>21, 22, 80 open"] --> B["FTP: download note.txt<br>hash inside"]
B --> C["Crack hash<br>-> credentials"]
C --> D["gobuster on port 80<br>finds /academy"]
D --> E["Login with cracked creds"]
E --> F["File upload field found<br>(my-profile.php)"]
- Target: Academy,
192.168.1.66. A scan found 3 open ports: 21, 22, 80 — starting with the easiest, port 21 (FTP). - FTP hosted a
note.txtfile containing a hash value. - The hash type was identified with hash-identifier, then cracked — the credentials turned out to be user
10201321/ passwordstudent. - Why run gobuster next: with valid credentials but no known login path yet, directory brute-forcing the web port is the logical next step to find where those credentials should be used.
gobusteragainst port 80 revealed an/academydirectory containing a login page.- Logging in with the cracked credentials succeeded.
- After authenticating, a file-upload mechanism was found in the profile section. Since the upload target is a
.phpendpoint (my-profile.php), the plan is to exploit it with a PHP reverse shell — see File Upload → Reverse shell via file upload for the general technique, and OS Hacking → Linux Labs → Academy for where this specific machine's OS-level continuation is documented (this walkthrough's captured notes stop at identifying the upload opportunity).