IP转域名 :param base:原始IP :param timeout:超时时间 :return 域名 / False :except 返回False
(base, timeout=3)
| 88 | |
| 89 | |
| 90 | def IP2domain(base, timeout=3): |
| 91 | """ |
| 92 | IP转域名 |
| 93 | |
| 94 | :param base:原始IP |
| 95 | :param timeout:超时时间 |
| 96 | :return 域名 / False |
| 97 | :except 返回False |
| 98 | """ |
| 99 | try: |
| 100 | domains = set() |
| 101 | ip = base.split(':')[0] if ':' in base else base |
| 102 | q = "https://www.bing.com/search?q=ip%3A" + ip |
| 103 | c = requests.get(url=q, |
| 104 | headers={ |
| 105 | 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0'}, |
| 106 | timeout=timeout |
| 107 | ).content |
| 108 | p = re.compile(r'<cite>(.*?)</cite>') |
| 109 | l = re.findall(p, c) |
| 110 | for each in l: |
| 111 | domain = each.split('://')[-1].split('/')[0] |
| 112 | domains.add(domain) |
| 113 | if len(domains) > 0: |
| 114 | ans_1 = base + ' -> ' |
| 115 | for each in domains: |
| 116 | ans_1 += '|' + each |
| 117 | return ans_1 |
| 118 | else: |
| 119 | return False |
| 120 | except Exception: |
| 121 | return False |
| 122 | |
| 123 | |
| 124 | def checkPortTcp(target, port, timeout=3): |