-
Notifications
You must be signed in to change notification settings - Fork 17
/
scope_download.py
34 lines (30 loc) · 1.38 KB
/
scope_download.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
import requests
import warnings
import json
import os
warnings.filterwarnings("ignore")
token = raw_input("Please enter your Synack Auth Header (Command from web console: sessionStorage.getItem('shared-session-com.synack.accessToken')): ")
target_code = raw_input("Please enter your target codename: ")
blocks = []
x = 1
print ("Downloading scope for target.")
response = requests.get('https://platform.synack.com/api/targets/'+target_code+'/cidrs',params={'page': x},headers={'Authorization': 'Bearer '+token},verify=False)
temp = json.dumps(response.json()['cidrs']).replace("[","").replace("]","").replace("\"","").replace(", ","\n").split("\n")
blocks.extend(temp)
print("Page "+str(x)+" done.")
while len(temp) > 1:
x = x + 1
response = requests.get('https://platform.synack.com/api/targets/'+target_code+'/cidrs',params={'page': x},headers={'Authorization': 'Bearer '+token},verify=False)
if (response.json().get("cidrs")==None):
break
else:
temp = json.dumps(response.json()['cidrs']).replace("[","").replace("]","").replace("\"","").replace(", ","\n").split("\n")
blocks.extend(temp)
print("Page "+str(x)+" done.")
if os.path.isfile("blocks.txt"):
os.remove("blocks.txt")
f = open("blocks.txt","w+")
for i in range (len(blocks)):
if blocks[i] != "": f.write(blocks[i]+"\n")
f.close()
print ("All done! Blocks have been added to blocks.txt file.")