Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import datetime
  4. import socket
  5.  
  6. # Initialization
  7. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  8. sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  9.  
  10. host = '192.168.56.1'
  11. port = 80
  12. address = (host, int(port))
  13.  
  14. print("[+] Starting Server")
  15. sock.bind(address)
  16. sock.listen(1)
  17.  
  18. # Options for interacting with malware
  19. options = ["", "", "", "", "", ""]
  20.  
  21. while(1):
  22. # Local Variables
  23. i = 0
  24.  
  25. print("[+] Waiting on a Connection")
  26. connection, client = sock.accept()
  27. data = connection.recv(8196)
  28.  
  29. # Interacting with the Malware
  30. print("Recieved:", data.decode())
  31.  
  32. # Reponse construction
  33. date = datetime.datetime.now().time()
  34. server = "\nServer: Apache/2.24\r\n"
  35. connect = "Connection: close\r\n\r\n"
  36. result = "HTTP/1.1 200 OK\r\n"
  37. length = "Content-Length: 16\r\n"
  38. content = "Content-Type: text/html\r\n"
  39.  
  40. # Prints options
  41. for x in options:
  42. i += 1
  43. print("[%s] %s" % (i, x))
  44.  
  45. # No Error Checking
  46. choice = input("\n\n[+] Selection an option.\nex. 1, 2, 3 .. \n")
  47.  
  48. # Building HTTP Response
  49. header = result + str(date) + server + content + \
  50. length + connect + options[int(choice) - 1]
  51. print("[+] Sending\n" + header)
  52. connection.send(header.encode())
  53. connection.close()
  54. print("[+] Package sent, closing connection")
  55. # time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement