zoukankan      html  css  js  c++  java
  • python批量测试域名能否被访问

    最近在挖洞,emmm,实习不好找,Boss直聘上的HR都只看在线简历,而我的确又没想过往上写什么。

    因此,基本没有HR理我。挺想去长亭的,但是吧,那个很漂亮的HR小姐姐拒绝我了。害,等我多挖点src,再去试试。

    估计现阶段也就只能先从运维做起,看后阶段能不能跳到大佬那去。难搞。

    因此最近一直了解自动化挖洞(公益SRC)(xray+crawlergo+crawlergo_x_crawlergo+下面这个代码)

    前面三个工具,github就有,直接就能搜出来。

    挖洞,第一件事是要做资产收集,资产收集方法很多,我懒得写了。

    但是子域名收集后,能否被访问,还不可知,因此我写了一个批处理的脚本。用来测试连通性的。测试还行。

    import urllib.request
    url_file = '资产.txt'
    opener = urllib.request.build_opener()
    opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.9 Safari/537.36')]
    new = open('200.txt','w',encoding='UTF-8',newline='')
    with open(url_file, "r", encoding='utf-8',) as f:
        for line in f:
            u =('http://'+line).strip('
    ')
            try :
                opener.open(u)
                print(u+"正常")
                new.write(u+'
    ')
            except urllib.error.HTTPError:
                print(u+"不正常")
            except urllib.error.URLError:
                print(u+"不正常")
    new.close

    解释一下:

    资产.txt:代表的是你收集的子域名。我这里的子域名都是主机头,没有http和Https协议,因此是中途加的。

    User-agent:打开开发者模式。在console下输入navigator.userAgent,你就能看见你的User-agent了。

    200.txt:代表能够正常访问的域名。

    注意哈、有些公司它的域名可能是有SSL的,但是它的子域名可能就没有SSL,并且还都可以访问,所以在这里我懒得写这方面的验证了,有空再补。

    所以有时候,你得自己替换https和http。

    网安小菜鸡
  • 相关阅读:
    [LeetCode] 148. Sort List 解题思路
    [LeetCode] 21. Merge Two Sorted Lists 解题思路
    [LeetCode] 160. Intersection of Two Linked Lists 解题思路
    [LeetCode] 203. Remove Linked List Elements 解题思路
    是否是最美的6年
    Apache的Order Allow,Deny 详解
    apache 2.4 访问权限配置
    apache如何设置http自动跳转到https
    linux ssh_config和sshd_config配置文件
    mysql命令查询表的个数
  • 原文地址:https://www.cnblogs.com/jdr-gbl/p/13190980.html
Copyright © 2011-2022 走看看