跳转到帖子

游客您好,欢迎来到黑客世界论坛!您可以在这里进行注册。

赤队小组-代号1949(原CHT攻防小组)在这个瞬息万变的网络时代,我们保持初心,创造最好的社区来共同交流网络技术。您可以在论坛获取黑客攻防技巧与知识,您也可以加入我们的Telegram交流群 共同实时探讨交流。论坛禁止各种广告,请注册用户查看我们的使用与隐私策略,谢谢您的配合。小组成员可以获取论坛隐藏内容!

TheHackerWorld官方

python扫描web路径小工具

精选回复

发布于

前言:

今天逛朋友圈的时候。发现了车王说,用python写web路径扫描的小伙伴门用head别用get。
后来我去百度了查了一下发现Head和Get的不同之处。所以有了以下这篇文章。

请求对比:

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

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

1.检查资源的有效性。

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

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

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

EM4AYjv.png

正文:

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

代码:

import requests
import os

urlw=[]
okurl=[]
noturl=[]
error=['404','Not Found','403','找不到','没有权限','360','云锁','网站防火墙','D盾','百度云加速'] //过滤列表
headers={'user-agent':'Opera/9.80(WindowsNT6.1;U;en)Presto/2.8.131Version/11.11'}
ld=os.listdir('dict')
print('[+]Discovery directory')
for l in ld:
    print('[+]find',l)

print('')
user=input('Please choose:')
user2=input('Enter your URL:')
if os.path.exists('dict/{}'.format(user)):
    print('[+]File existence {}'.format(user))
else:
    print('[-]file does not exist {}'.format(user))
    exit()

ope=open('dict/{}'.format(user),'r')
for r in ope.readlines():
    url=user2.strip()+"".join(r.split('\n'))
    urlw.append(url)

def ether(urls):
    try:
        reqt=requests.head(url=urls,headers=headers,allow_redirects=True)
        for e in error:
            if reqt.status_code==200 and e not in reqt.text: //判断
                yes='[200]=>Discovery path:{}'.format(reqt.url)
                if yes in okurl:continue //去重
                okurl.append(yes)
                print(yes)

            else:
                no='[{}]=>Can t find:{}'.format(reqt.status_code,reqt.url)
                if no in noturl:continue //去重
                noturl.append(no)
                print(no)
    except Exception as g:
        print('[-]Error in {} url:{}'.format(g,reqt.url))

for w in urlw:
    ether(w)

测试效果:
eAIMARt.png

谢谢

创建帐户或登录后发表意见

最近浏览 0

  • 没有会员查看此页面。