python扫描web路径小工具

python扫描web路径小工具

hackersec已验证会员

黑客倉庫站長

管理成员
贡献: 3%

请求对比:​

GET:使用GET请求某个路径获取返回的响应。请求参数会暴露在外

HEAD:特别适用在优先的速度和带宽下

1.检查资源的有效性。

2.检查超链接的有效性。

3.检查网页是否被串改。

4.多用于自动搜索机器人获取网页的标志信息,获取rss种子信息,或者传递安全认证信息等。

python扫描web路径小工具-1.png




思路:让使用者可以调用指定的web字典进行扫描,添加过滤信息。
当返回的URL的状态码为200并且无过滤列表里面关键字则判定为存在该路径。


代码:


<span>import</span> requests<br><span>import</span> os<br><br>urlw=[]<br>okurl=[]<br>noturl=[]<br>error=[<span>'404'</span>,<span>'Not Found'</span>,<span>'403'</span>,<span>'找不到'</span>,<span>'没有权限'</span>,<span>'360'</span>,<span>'云锁'</span>,<span>'网站防火墙'</span>,<span>'D盾'</span>,<span>'百度云加速'</span>] <span>//</span>过滤列表<br>headers={<span>'user-agent'</span>:<span>'Opera/9.80(WindowsNT6.1;U;en)Presto/2.8.131Version/11.11'</span>}<br>ld=os.listdir(<span>'dict'</span>)<br><span>print</span>(<span>'[+]Discovery directory'</span>)<br><span>for</span> l <span>in</span> ld:<br> <span>print</span>(<span>'[+]find'</span>,l)<br><br><span>print</span>(<span>''</span>)<br>user=input(<span>'Please choose:'</span>)<br>user2=input(<span>'Enter your URL:'</span>)<br><span>if</span> os.path.exists(<span>'dict/{}'</span>.format(user)):<br> <span>print</span>(<span>'[+]File existence {}'</span>.format(user))<br>else:<br> <span>print</span>(<span>'[-]file does not exist {}'</span>.format(user))<br> exit()<br><br>ope=open(<span>'dict/{}'</span>.format(user),<span>'r'</span>)<br><span>for</span> r <span>in</span> ope.readlines():<br> url=user2.strip()+<span>""</span>.join(r.split(<span>'\n'</span>))<br> urlw.append(url)<br><br>def ether(urls):<br> try:<br> reqt=requests.head(url=urls,headers=headers,allow_redirects=True)<br> <span>for</span> e <span>in</span> error:<br> <span>if</span> reqt.status_code==<span>200</span> <span>and</span> e <span>not</span> <span>in</span> reqt.text: <span>//</span>判断<br> <span>yes</span>=<span>'[200]=&gt;Discovery path:{}'</span>.format(reqt.url)<br> <span>if</span> <span>yes</span> <span>in</span> okurl:<span>continue</span> <span>//</span>去重<br> okurl.append(<span>yes</span>)<br> <span>print</span>(<span>yes</span>)<br><br> else:<br> <span>no</span>=<span>'[{}]=&gt;Can t find:{}'</span>.format(reqt.status_code,reqt.url)<br> <span>if</span> <span>no</span> <span>in</span> noturl:<span>continue</span> <span>//</span>去重<br> noturl.append(<span>no</span>)<br> <span>print</span>(<span>no</span>)<br> except Exception <span>as</span> g:<br> <span>print</span>(<span>'[-]Error in {} url:{}'</span>.format(g,reqt.url))<br><br><span>for</span> w <span>in</span> urlw:<br> ether(w)<br>

测试效果:

python扫描web路径小工具-2.png
 
后退
顶部