Wednesday, 14 August 2013

Python urllib2 Authentication Will not return whether it was successful or not

Python urllib2 Authentication Will not return whether it was successful or
not

I am using minecraft.net as an example: When i type
http://minecraft.net/login it always comes back as "Password Found" and
When I type http://minecraft.net/login.php it always comes back as "Brute
Failed:" I have also tried (h t t p s : / / w w w.facebook.com/login.php)
and (h t t p s : / / w w w.facebook.com/login.php) . My goal is for the
code to tell me weather the password is correct or incorrect (Obviously).
Is it the link i'm typing or is it my code? If it is my code what am i
doing wrong! I have spend over 8 hours just trying to figure it out and
progress on my program is being held back! Iv tried Many different
scripts. Code that works is appreciated but i am completely ok with you
telling me how to fix this! Note: Facebook links seperated because i dont
have 10 rep Thank you. (Windows65)
import urllib2
import os
os.system("color 09")
print "URL To Brute: "
URL = raw_input("> ")
os.system("cls")
print "User Name To Brute: "
username = raw_input("> ")
os.system("cls")
print "Password As Test: "
password = raw_input("> ")
os.system("cls")
import urllib2, base64
request = urllib2.Request(URL)
base64string = base64.encodestring('%s:%s' % (username,
password)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
try:
result = urllib2.urlopen(request)
print "Password Found: " + password
except:
print "Brute Failed: "

No comments:

Post a Comment