-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathwrapper.py
70 lines (51 loc) · 1.55 KB
/
wrapper.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os, subprocess, json
home = os.environ['HOME']
def read_config():
config = open(home + '/.config/subfinder/config.yaml', 'r').read()
return [home, config]
def save_config(data):
with open(home + '/.config/subfinder/config.yaml', 'w') as config_file:
config_file.write(data)
def run_subfinder(domain, args):
open('./tmp/{}.lock'.format(domain), 'w').close()
if args:
command = 'subfinder -d {} -o ./tmp/{}.json -oJ -nW {}'.format(domain, domain, args).split()
else:
command = 'subfinder -d {} -o ./tmp/{}.json -oJ -nW'.format(domain, domain).split()
p = subprocess.Popen(command, stdout=subprocess.PIPE)
p.communicate()
os.remove('./tmp/{}.lock'.format(domain))
def load_scans():
scans = []
filtered = []
for (path, dirname, filename) in os.walk('./tmp'):
scans.extend(filename)
for i,s in enumerate(scans):
if not s.endswith('.lock'):
filtered.append(s.split('.json')[0])
return filtered
def get_result(domain):
result = []
data = open('./tmp/{}.json'.format(domain), 'r').read().splitlines()
for d in data:
d = json.loads(d)
result.append([d['host'], d['ip']])
return result
def get_idle():
idle = []
for i in os.listdir('./tmp'):
if i.endswith('.lock'):
idle.append(i.split('.lock')[0])
return idle
def delete_target(domain):
os.remove('./tmp/{}.json'.format(domain))
def get_text(domain, type):
text = ''
data = open('./tmp/{}.json'.format(domain), 'r').read().splitlines()
for d in data:
d = json.loads(d)
if type == 'sub':
text = text + d['host'] + '\n'
else:
text = text + d['ip'] + '\n'
return text