我是靠谱客的博主 激动流沙,这篇文章主要介绍python写一个web目录扫描器,现在分享给大家,希望可以做个参考。

用到的模块urliib error

#coding = utf-8
#web目录扫描器
by
qianxiao996
#博客地址:https://blog.csdn.net/qq_36374896
import urllib.request
from urllib import error
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
}
url = input("输入你要扫描到的网址:")
txt = input("输入字典的完整路径(默认php.txt):")
#从字典中读取每一行与url组合,然后添加到url_list
url_list = []
if txt == "":
txt = "php.txt"
try:
with open(txt,'r') as f:
for each in f:
each = each.replace('n','')
url_list.append(each)
f.close()
except:
print("打开字典失败!")
for li in url_list:
#设置一个请求体
conn = "http://" + url +"/"+ li
req = urllib.request.Request(conn,headers = headers)
#发起请求
try:
response = urllib.request.urlopen(req)
# 返回状态码
print("%s------------->%s" % (conn, response.getcode()))
except error.HTTPError as e: #http错误
print('%s------------->%s' %(conn, e.code))
except error.URLError :
# URL错误
print("域名访问失败!")
exit(1)

小白学python,大神勿喷。

最后

以上就是激动流沙最近收集整理的关于python写一个web目录扫描器的全部内容,更多相关python写一个web目录扫描器内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(129)

评论列表共有 0 条评论

立即
投稿
返回
顶部