开发者社区> 问答> 正文

收藏 写了一个目录扫描脚本,大家看看吧?:报错

目的:
1、读取出url.txt文件里的网站地址
2、读取出dict.txt 文件里的目录,如(manager/login.html)
3、最后判断某网站是否存在dict.txt文件里所包含的内容。

请教:
1、此程序目前不能循环,只能分别从url.txt和dict.txt里读取一条内容。
2、针对此脚本,请大家多指点,提出不足或错误之处;还有需要改进、提高的地方。 非常感谢~

欢迎py 达人拍砖,菜鸟初学中!呵呵.

import httplib,time,fileinput
 
url=file('url.txt','r')
for site in url.readlines():
    dict=file('dict.txt','r')
    for admin_path in dict.readlines():
        admin = admin_path
print "\n[-] %s" % time.strftime("%X")
print "[+]Check paths............"
try:    
        admin = admin.replace("\n","")
        admin = "/" + admin
        connection = httplib.HTTPConnection(site)
        connection.request("GET",admin)
        response = connection.getresponse()
        print "%s %s %s" % (site+admin, response.status, response.reason)
        connection.close()
 
except:
    pass
fileinput.close()


展开
收起
kun坤 2020-06-06 16:54:24 405 0
1 条回答
写回答
取消 提交回答
  • mark!######

    没有判断302之类的转移代码那?

    扫目录的程序仔细写起来好庞大的~能程序自动学习就好很多了


    2020-06-06 16:54:28
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载