-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathget_subdomains.py
31 lines (26 loc) · 932 Bytes
/
get_subdomains.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
#!/usr/bin/env python3
import requests
import os
import sys
import json
import argparse
from passivetotal.libs.dns import DnsRequest
from passivetotal.libs.enrichment import EnrichmentRequest
def get_config():
conf_file = os.path.join(os.path.expanduser("~"), ".config/passivetotal/api_config.json")
if os.path.isfile(conf_file):
with open(conf_file, 'r') as f:
conf = json.loads(f.read())
else:
print('No config file')
sys.exit(1)
return conf
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='List subdomains for a domain')
parser.add_argument('DOMAIN', help='Domain')
args = parser.parse_args()
conf = get_config()
client = EnrichmentRequest(conf['username'], conf['api_key'])
raw_results = client.get_subdomains(query=args.DOMAIN)
for s in raw_results['subdomains']:
print(s + '.' + raw_results['primaryDomain'])