python扫描网站目录
来源:互联网 发布:js点击显示隐藏div 编辑:程序博客网 时间:2024/06/07 16:50
#!/usr/bin/python#coding: utf-8import httplib2import sysdef 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()