网络编程
位置:首页>> 网络编程>> Python编程>> Python 实现敏感目录扫描的示例代码

Python 实现敏感目录扫描的示例代码

作者:Vista、  发布时间:2021-08-21 05:47:14 

标签:python,敏感,目录,扫描

01 实现背景

1、PHPdict.txt,一个文本文件,包含可能的敏感目录后缀

Python 实现敏感目录扫描的示例代码

2、HackRequests模块,安全测试人员专用的类Requests模块

02 实现目标

利用HackRequests模块,配合敏感目录字典PHPdict.txt,实现一个简单的敏感目录扫描Python文件

03 注意事项

1、输入URL时要输全:如 https://www.baidu.com/、 https://www.csdn.net/

2、为防止网站可能存在的简单反爬机制,我们简单添加headers信息,尝试绕过反爬

04 实现代码


import HackRequests
def HR(url):
h = HackRequests.hackRequests()
header = {
"Connection": "keep-alive",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0"
}
try:
u = h.http(url=url,headers=header)
if u.status_code == 200:
 print("%s is success!" %url)
else:
 print("%s is failed! %d" %(url,u.status_code))
except:
pass
with open("C:\\Users\\Dell\\Desktop\\Python\\PHPdict.txt","r") as file:
lines = file.readlines()
urls = []
url_begin = input('请输入你要扫描的网站:')
for line in lines:
url = f'{url_begin}{line}'
urls.append(url)

for url in urls:
print(url)
HR(url)

05 实现效果

Python 实现敏感目录扫描的示例代码

来源:https://blog.csdn.net/qq2539879928/article/details/106173070

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com