Skip to content

批量查询域名是否被注册 (Python脚本)

字数
326 字
阅读时间
2 分钟
更新日期
11/2/2019

虽然没有什么好的想法,但总想买些域名玩玩,但是心仪的域名都被注册了,于是写了这个脚本,可以通过一些排列,来找到未注册的域名。
通过排列组合于是就买下了vulexp.com 这个域名,但目前好像不知道有什么用。

脚本如下

python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2019/10/21 3:46 PM
# @Author  : w8ay
# @File    : domain.py.py

import requests
from bs4 import BeautifulSoup
import time
from itertools import combinations, permutations


# 查询是否注册
def check(domain):
    url = "http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=%s" % domain
    html = requests.get(url)
    bsj = BeautifulSoup(html.text, "lxml")
    onum = bsj.find("original")
    if onum != None:
        num = onum.get_text()[:3]
        if num == '210':
            print("%s可以注册" % domain)
        elif num == "213":
            print("查询超时,请重新查询")
        elif num == "211":
            print("[x] %s" % domain)
        elif num == "212":
            print(f"{domain} 无效域名")
        else:
            print(html.text)
            print("出现未知问题")
        return num
    else:
        print("让我哭一会,ip可能被封了")
        return None


def search(name, suffix):
    domain = name + '.' + suffix
    num = check(domain)
    if num != None:
        if num == '210':
            return domain
    return False


if __name__ == '__main__':
    namepart = ['micro', 'hacking', 'scan']

    qians = ['micro', 'hack', 'sec', 'vul', 'vuln', 'pwn', 'bug', 'i', 'poc','src','exp']
    hous = ['scan', 'scanner', 'sec', 'hub','con','hunter','sploit','exp']

    suffixes = ['com']
    domains = []
    for suffix in suffixes:
        # names = permutations(namepart, 2)
        names = []
        for qian in qians:
            for hou in hous:
                names.append(qian + hou)
        for name in names:
            domains.append((name, suffix))

    for domain in domains:
        oklist = search(domain[0], domain[1])
        time.sleep(0.1)

撰写