π Quick Reference
Cybersecurity Commands Cheat Sheet
100+ essential commands for Nmap, dig, openssl, curl, hashcat, tshark, and more β all on one page.
π Reconnaissance & DNS
| Command | Description |
|---|---|
dig A example.com +short | IPv4 address |
dig AAAA example.com +short | IPv6 address |
dig MX example.com | Mail servers |
dig TXT example.com | TXT records (SPF, DKIM) |
dig NS example.com +short | Name servers |
dig CAA example.com | Allowed certificate authorities |
dig +trace example.com | Trace full resolution path |
dig -x 8.8.8.8 +short | Reverse DNS lookup |
dig AXFR example.com @ns1.example.com | Zone transfer test (should fail) |
nslookup -type=MX example.com | MX lookup (nslookup) |
host -t TXT example.com | TXT records (host) |
whois example.com | Domain registration info |
whois 8.8.8.8 | IP owner/ASN info |
curl -s "https://crt.sh/?q=%25.example.com&output=json" | jq '.[].name_value' | Certificate transparency (subdomains) |
curl -s "https://api.hackertarget.com/hostsearch?q=example.com" | Subdomain enumeration (HackerTarget) |
πΊοΈ Nmap Port Scanning
| Command | Description |
|---|---|
nmap -sn 192.168.1.0/24 | Ping sweep β find live hosts |
nmap 192.168.1.1 | Scan top 1000 ports |
nmap -p- 192.168.1.1 | Scan ALL 65535 ports |
nmap -p 22,80,443 192.168.1.1 | Scan specific ports |
nmap -sV 192.168.1.1 | Service version detection |
nmap -O 192.168.1.1 | OS detection |
nmap -A 192.168.1.1 | Aggressive (OS+version+scripts+traceroute) |
nmap -sU -p 53,123,161 192.168.1.1 | UDP port scan |
nmap -sS 192.168.1.1 | Stealth SYN scan (root required) |
nmap -Pn 192.168.1.1 | Skip ping (assume host is up) |
nmap -T4 192.168.1.1 | Fast timing (aggressive) |
nmap --script vuln 192.168.1.1 | Vulnerability scripts |
nmap --script smb-vuln-ms17-010 -p 445 | EternalBlue check |
nmap -oA scan-results 192.168.1.1 | Save in all formats |
nmap -iL targets.txt | Scan from file |
π Web Security
| Command | Description |
|---|---|
curl -sI https://example.com | Check HTTP response headers |
curl -sI https://example.com | grep -iE "strict-transport|content-security|x-frame" | Security headers check |
curl -s https://example.com/.git/HEAD | Check for exposed .git |
curl -s https://example.com/robots.txt | View robots.txt |
curl -sI -H "Origin: https://evil.com" https://example.com/api | CORS misconfiguration test |
curl -s -X OPTIONS -I https://example.com | Check allowed HTTP methods |
curl -s https://example.com | grep -i "iframe\|eval(" | Check for injected scripts |
curl -s https://example.com | grep -oP 'src="http://[^"]*"' | Find mixed content |
nikto -h https://example.com | Web vulnerability scanner |
gobuster dir -u http://target.com -w /usr/share/wordlists/dirb/common.txt | Directory brute force |
π SSL/TLS
| Command | Description |
|---|---|
openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -text -noout | View full certificate |
openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -issuer -dates -noout | Issuer and expiry |
echo | openssl s_client -connect example.com:443 2>/dev/null | openssl x509 -checkend 0 | Check if cert is expired |
openssl s_client -connect example.com:443 -tls1_2 2>&1 | grep "Cipher" | TLS 1.2 cipher used |
openssl s_client -connect example.com:443 -tls1 2>&1 | grep "CONNECTED" | Test if TLS 1.0 is accepted (bad) |
openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr | Generate CSR |
openssl x509 -in cert.pem -text -noout | View certificate file |
π Network & Firewall
| Command | Description |
|---|---|
netstat -tuln | Listening TCP/UDP ports |
ss -tuln | Listening ports (faster, modern) |
ss -tulnp | Listening ports + process names (root) |
netstat -anp | grep ESTABLISHED | Active connections |
lsof -i -P | grep LISTEN | Listening ports with processes (macOS) |
iptables -L -n -v | View firewall rules |
traceroute example.com | Trace network path |
mtr example.com | Continuous traceroute |
arp -a | View ARP table (connected devices) |
ip route show | Show routing table |
tcpdump -i eth0 -n port 80 | Capture HTTP traffic |
tcpdump -i eth0 -w capture.pcap | Save to pcap file |
# Hash & Crypto
| Command | Description |
|---|---|
echo -n "password" | md5sum | MD5 hash |
echo -n "password" | sha1sum | SHA-1 hash |
echo -n "password" | sha256sum | SHA-256 hash |
echo -n "password" | sha512sum | SHA-512 hash |
md5sum file.txt | Hash a file (integrity check) |
sha256sum file.txt > file.sha256 && sha256sum -c file.sha256 | Verify file integrity |
strings suspicious.bin | grep -iE "http|cmd|bash|exec" | Strings in binary |
file suspicious.bin | Identify file type |
base64 -e <<< "hello world" | Base64 encode |
echo "aGVsbG8gd29ybGQ=" | base64 -d | Base64 decode |
π Password Cracking
| Command | Description |
|---|---|
hashcat -m 0 -a 0 hash.txt rockyou.txt | MD5 dictionary attack |
hashcat -m 1400 -a 0 hash.txt rockyou.txt | SHA-256 dictionary attack |
hashcat -m 1800 -a 0 hash.txt rockyou.txt | bcrypt dictionary attack |
hashcat -m 22000 hash.hc22000 rockyou.txt | WPA2 cracking |
hashcat -m 0 -a 3 hash.txt ?a?a?a?a?a?a | Brute force 6-char all |
hashcat --show hash.txt | Show cracked passwords |
hashcat -b | Benchmark GPU speed |
john --wordlist=rockyou.txt hash.txt | John dictionary attack |
john --show hash.txt | Show cracked (John) |
hydra -L users.txt -P pass.txt ssh://192.168.1.1 | SSH brute force (authorised only) |
π‘ Packet Analysis (tshark)
| Command | Description |
|---|---|
tshark -i eth0 -c 100 | Capture 100 packets |
tshark -i eth0 -f "port 53" | Capture DNS only |
tshark -i eth0 -w capture.pcap | Save to pcap file |
tshark -r capture.pcap -Y "dns" | Read pcap, filter DNS |
tshark -r capture.pcap -Y "http.request" -T fields -e http.request.uri | Extract HTTP request URIs |
tshark -r capture.pcap -Y "dns" -T fields -e dns.qry.name | Extract DNS queries |