-
Notifications
You must be signed in to change notification settings - Fork 1
/
alldomain.py
51 lines (40 loc) · 1.34 KB
/
alldomain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import requests
from bs4 import BeautifulSoup
ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36"
# 查域名注册邮箱
def whois(domain):
interface = "http://whois.chinaz.com/%s" % domain
r = requests.get(interface, headers={'User-Agent': ua}).text
# 域名注册信息受保护时返回一个不存在的邮箱
tmp = re.findall(r'[\w\-]+\@[\w\-]+\.\w+', r)
return tmp[0] if len(tmp)>0 else "[email protected]"
# 查邮箱注册的域名
def alldomain(email):
domains = []
interface = "http://whois.chinaz.com/reverse?host=%s&ddlSearchMode=1" % email
r = requests.get(interface, headers={'User-Agent': ua}).text
for domain in BeautifulSoup(r, 'lxml').find(id="ajaxInfo").find_all('a'):
if re.match(r'\w+\.\w+', domain.text):
domains.append(domain.text)
return domains
def main():
# domain = "guokr.com"
# reg_email = whois(domain)
# domains = alldomain(reg_email)
# print domains
reader = open("wooyun.txt", "r")
writer = open("result.txt", "a")
for line in reader.readlines():
line = line.rstrip()
print "read ---->"+line
for domain in alldomain(whois(line)):
print "get ----" + domain
writer.write(domain+"\n")
writer.flush()
writer.close()
reader.close()
if __name__ == "__main__":
main()