forked from j5oh/synackAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetscope.py
executable file
·123 lines (114 loc) · 4.13 KB
/
getscope.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python3
from synack import synack
import subprocess
import os
import sys
s1 = synack()
s1.gecko=False
s1.getSessionToken()
s1.getAllTargets()
args = len(sys.argv)
arg_1 = str(sys.argv[1].lower())
if arg_1 == "web":
category = "Web Application"
codenames = s1.getCodenames(category)
elif arg_1 == "host":
category = "Host"
codenames = s1.getCodenames(category)
elif arg_1 == "mobile":
category = "mobile"
codenames = s1.getCodenames(category)
elif arg_1 == "re":
category = "reverse engineering"
codenames = s1.getCodenames(category)
elif arg_1 == "hardware":
category = "hardware"
codenames = s1.getCodenames(category)
elif arg_1 == "sc":
category = "source code"
codenames = s1.getCodenames(category)
else:
codenames = [arg_1]
category = s1.getCategory(codenames[0])
if category == "Host":
for i in range(len(codenames)):
codename = codenames[i]
print(codename)
cidrs = s1.getScope(codename)
ips = s1.getIPs(cidrs)
targetPath = "./"+codename.upper()+"/"
if os.path.isdir(targetPath) == False:
os.mkdir(targetPath)
filePath = "./"+codename.upper()+"/scope.txt"
if os.path.exists(filePath):
os.remove(filePath)
with open('./'+codename.upper()+'/scope.txt', mode='wt', encoding='utf-8') as myfile:
myfile.write('\n'.join(ips))
myfile.write('\n')
if category == "Web Application":
for i in range(len(codenames)):
print(codenames[i])
tupleList = set()
oosTupleList = set()
burpSet = set()
oosBurpSet = set()
codename = codenames[i]
scope,oos = s1.getScope(codename)
wildcardRegex = "(.*\.|)"
for j in range(len(scope)):
scheme = scope[j]['scheme']
netloc = scope[j]['netloc']
path = scope[j]['netloc']
port = scope[j]['port']
wildcard = scope[j]['wildcard']
path = scope[j]['path']
netloc = netloc+path
# tupleList.add(netloc)
print(netloc)
if wildcard == True:
tupleList.add(netloc)
burpStr = netloc.replace('.','\.')
burpStr = burpStr.replace('/','\/')
burpSet.add(wildcardRegex + burpStr)
else:
tupleList.add(netloc)
burpStr = netloc.replace('.','\.')
burpStr = burpStr.replace('/','\/')
burpSet.add(burpStr)
for k in range(len(oos)):
scheme = oos[k]['scheme']
netloc = oos[k]['netloc']
path = oos[k]['netloc']
port = oos[k]['port']
wildcard = oos[k]['wildcard']
path = oos[k]['path']
netloc = netloc + path
oosTupleList.add(netloc)
if wildcard == True:
oosTupleList.add(netloc)
oosBurpStr = netloc.replace('.','\.')
oosBurpStr = oosBurpStr.replace('/','\/')
oosBurpSet.add(wildcardRegex + oosBurpStr)
else:
oosBurpStr = netloc.replace('.','\.')
oosBurpStr = oosBurpStr.replace('/','\/')
oosTupleList.add(netloc)
oosBurpSet.add(netloc.replace('.','\.'))
scopeList = list(tupleList)
burpList = list(burpSet)
oosBurpList = list(oosBurpSet)
targetPath = "./"+codename.upper()+"/"
if os.path.isdir(targetPath) == False:
os.mkdir(targetPath)
filePath = "./"+codename.upper()+"/scope.txt"
if os.path.exists(filePath):
os.remove(filePath)
with open('./'+codename.upper()+'/scope.txt', mode='wt', encoding='utf-8') as myfile:
myfile.write('\n'.join(scopeList))
myfile.write('\n')
with open('./'+codename.upper()+'/burpScope.txt', mode='wt', encoding='utf-8') as myfile:
myfile.write('\n'.join(burpList))
myfile.write('\n')
with open('./'+codename.upper()+'/burpOOS.txt', mode='wt', encoding='utf-8') as myfile:
myfile.write('\n'.join(oosBurpList))
myfile.write('\n')