lolamontes69

Python/ Lola69's Buffer Overflower

Jun 20th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.60 KB | None | 0 0
  1. import subprocess
  2. from random import *
  3. import os as os
  4.  
  5. def add_headers():
  6.     # Add headers to headerstring with \n after each one.
  7.     headerstring = "User-Agent: Mozilla/4.0\nAccept-Language: en-us\nProxy-Connection: Keep-Alive"
  8.     lines = headerstring.split('\n')
  9.     c = ""
  10.     for a in lines:
  11.         if len(a) > 0:
  12.             b = '-H "'+a+'" '
  13.             c += b
  14.     return c
  15.  
  16. def execute_unix(inputcommand):
  17.     # Coded by lola69 on 20th June 2013
  18.     p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True)
  19.     (output, err) = p.communicate()
  20.     return output
  21.  
  22. def get_request(url):
  23.     try:
  24.         c = add_headers()
  25.         inputcommand = "curl -v "+c+url
  26.         print inputcommand
  27.         execute_unix(inputcommand)
  28.     except: pass
  29.  
  30. def delete_request(url):
  31.     try:
  32.         c = add_headers()
  33.         inputcommand = "curl -X DELETE -v "+c+url
  34.         execute_unix(inputcommand)
  35.     except: pass
  36.  
  37. def head_request(url):
  38.     try:
  39.         c = add_headers()
  40.         inputcommand = "curl -I -v "+c+url
  41.         execute_unix(inputcommand)
  42.     except: pass
  43.  
  44. def katy_request(url):
  45.     try:
  46.         c = add_headers()
  47.         inputcommand = "curl -v -X KATY "+c+url
  48.         execute_unix(inputcommand)
  49.     except: pass
  50.  
  51. def options_request(url):
  52.     try:
  53.         c = add_headers()
  54.         inputcommand = "curl -v -X OPTIONS "+c+url
  55.         execute_unix(inputcommand)
  56.     except: pass
  57.  
  58. def post_request_nodata(url):
  59.     try:
  60.         c = add_headers()
  61.         inputcommand = "curl -v -X POST "+c+url
  62.         execute_unix(inputcommand)
  63.     except: pass
  64.  
  65. def put_request_nodata(url):
  66.     try:
  67.         c = add_headers()
  68.         inputcommand = "curl -v -X PUT "+c+url
  69.         execute_unix(inputcommand)
  70.     except: pass
  71.  
  72. def put_request_upload(url):
  73.     try:
  74.         c = add_headers()
  75.         inputcommand = 'curl -v -T "README.txt" '+c+url
  76.         execute_unix(inputcommand)
  77.     except: pass
  78.  
  79. def trace_request(url):
  80.     try:
  81.         c = add_headers()
  82.         inputcommand = "curl -v -X TRACE "+c+url
  83.         execute_unix(inputcommand)
  84.     except: pass
  85.  
  86. def track_request(url):
  87.     try:
  88.         c = add_headers()
  89.         inputcommand = "curl -v -X TRACK "+c+url
  90.         execute_unix(inputcommand)
  91.     except: pass
  92.  
  93. def write_README():
  94.     readmestring = "Examples for Developers\nhttp://drupal.org/project/examples\n\n\nThis set of modules is intended to provide small working examples of Drupal's\nfeatures and APIs.  The modules strive to be simple, well documented and\nmodification friendly to help developers quickly learn their inner workings,\nwith a little reading and hands on experience.\n\nYou can have a quick glimpse at the current Examples in the demo site: \nhttp://d7.drupalexamples.info/\n\nSuggestions, corrections and new examples are welcome.  Don't be shy if you're\njust starting, as precisely because of that you will know the questions and\nproblems of a newcomer better than a seasoned developer!\n\nSetup\n\n1. Install Examples for Developers (unpacking it to your Drupal\n   sites/all/modules directory if you're installing by hand, for example).\n2. Enable any Example modules in Admin menu > Site building > Modules.\n3. Rebuild access permissions if you are prompted to.\n4. Profit!  The examples will appear in your Navigation menu (on the left\n   sidebar by default; you'll need to reenable it if you removed it).\n\nNow you can read the code and its comments and see the result, experiment with\nit, and hopefully quickly grasp how things work.\n\nIf you find a problem, incorrect comment, obsolete or unproper code or such,\nplease let us know by creating a new issue at\nhttp://drupal.org/project/issues/examples\n"
  95.     out = open('README.txt', 'w')
  96.     out.write(readmestring)
  97.     out.close
  98.  
  99. def main():
  100.     os.system('clear')
  101.     ch = """
  102. ###################################
  103. #     HTTP request methods        #
  104. ###################################
  105. # 1   GET                         #
  106. # 2   HEAD                        #
  107. # 3   PUT                         #
  108. # 4   POST                        #
  109. # 5   TRACE                       #
  110. # 6   TRACK                       #
  111. # 7   OPTIONS                     #
  112. # 8   DELETE                      #
  113. # 9   KATY                        #
  114. # 0   PUT with README.txt         #
  115. ###################################
  116. """
  117.     url = str(raw_input('Enter first part of url >'))      # eg http://frooooooooooogtits.com/?test=
  118.     endstring = str(raw_input('Enter end part of url >'))  # eg &me=alon
  119.     n = int(raw_input('enter increment rate >'))
  120.     os.system('clear')
  121.     again = ''
  122.     overflowstring = ''
  123.     count = n
  124.     print ch
  125.     themethod = str(raw_input('Choose a request method >'))
  126.     if themethod == '0':
  127.         print "Do you have a README.txt prepared in this folder"
  128.         doyougot = str(raw_input('Type 2 for yes, Type 3 to prepare one >'))
  129.         if doyougot == '3':
  130.             write_README()
  131.     d = raw_input('Keep pressing <enter> to continue or enter <quit> to quit')
  132.     os.system('clear')
  133.     while again == '':
  134.         overflowstring = ""
  135.         for a in range(count):
  136.             overflowstring+=str(randint(0,9))
  137.         url1 = str(url+(overflowstring)+endstring).strip()
  138.         print "length of string =",count
  139.         if themethod == '1':
  140.             get_request(url1)
  141.         elif themethod == '2':
  142.             head_request(url1)
  143.         elif themethod == '3':
  144.             put_request_nodata(url1)
  145.         elif themethod == '4':
  146.             post_request_nodata(url1)
  147.         elif themethod == '5':
  148.             trace_request(url1)
  149.         elif themethod == '6':
  150.             track_request(url1)
  151.         elif themethod == '7':
  152.             options_request(url1)
  153.         elif themethod == '8':
  154.             delete_request(url1)
  155.         elif themethod == '9':
  156.             katy_request(url1)
  157.         elif themethod == '0':
  158.             put_request_upload(url1)
  159.         else:
  160.             again = 'tits'
  161.             print 'You dun goofed'
  162.             continue
  163.         count += n
  164.         again = raw_input('again >')
  165.  
  166. main()
  167.  
  168. """ ############################
  169.    #  Lola69's BufferOverflow #
  170.    #   A simple pentest-tool  #
  171.    ############################
  172.  
  173.    What is this?
  174.      A simple Buffer Overflow Utility
  175.    
  176.    1 enter first part of url
  177.    2 enter second part of url
  178.    3 enter increment rate
  179.    4 choose the HTTP request method
  180.    5 press enter to continue to begin
  181.    6 enter any letter to exit
  182.  
  183.    to add or remove http headers change headerstring in add_headers()
  184.  
  185.    #########
  186.    # To do #
  187.    #########
  188.    Add rotating headers option?
  189. """
Advertisement
Add Comment
Please, Sign In to add comment