python扫描网站目录
#!/usr/bin/python#coding: utf-8import httplib2import sysdef subscan(subpath):for fileLine in fileList:newline=fileLine.strip()#去掉每行头尾空白path=subpath+newlinerespo
·
#!/usr/bin/python
#coding: utf-8
import httplib2
import sys
def subscan(subpath):
for fileLine in fileList:
newline=fileLine.strip() #去掉每行头尾空白
path=subpath+newline
response,content=http.request(path,"GET")
if response.status!=nonpathstatus and response.status!=nonpathextstatus:
st=str(response.status)
print(st+" : "+path)
if __name__=="__main__":
if(len(sys.argv)<3):
print "written by lanz...."
print "usage: "+sys.argv[0]+" host "+" wordlist"+" ext"
sys.exit(0)
host=sys.argv[1]
filename=sys.argv[2]
ext=sys.argv[3]
print host
http=httplib2.Http(".cache")
response,content=http.request(host)
#测试两个肯定不存在的网址,记录下返回的状态值,便于后面比较用
response,content=http.request(host+"/mustnotexistpath/")
nonpathstatus=response.status
response,content=http.request(host+"/mustnotexitspath/"+ext)
nonpathextstatus=response.status
print "NoneExistPathStatus",nonpathstatus
print "NoneExistFilestatus",nonpathextstatus
f=open(filename,'r')
fileList=f.readlines()
subscan(host)
f.close()
更多推荐
已为社区贡献2条内容
所有评论(0)