-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIRequests.py
More file actions
33 lines (25 loc) · 935 Bytes
/
APIRequests.py
File metadata and controls
33 lines (25 loc) · 935 Bytes
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
import requests
import os
from requests.structures import CaseInsensitiveDict
url = "https://api.sep.securitycloud.symantec.com/v1/threat-intel/insight/file/"
print("File: ")
fileH = input()
print("Token: ")
token = input()
with open('results.txt', 'w+') as output:
with open(fileH, 'r') as file:
headers = CaseInsensitiveDict()
headers["Authorization"] = "Bearer " + token
for i in file:
item = i.strip()
ver = url + item
print(ver)
resp = requests.get(ver, headers=headers)
try :
line = item + "," + str(resp.status_code) + "," + str(resp.reputation) + "\n"
except AttributeError:
line = item + "," + str(resp.status_code) + "\n"
output.write(line)
print(resp.status_code)
print(resp.content)
os.system("start results.txt")