-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipriskiq.py
32 lines (26 loc) · 1.07 KB
/
ipriskiq.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
import requests
import sys
# Usage example: python ipriskiq.py <your_riskiq_username> <your_riskiq_token> file.txt
username = str(sys.argv[1])
key = str(sys.argv[2])
auth = (username, key)
url = 'https://api.passivetotal.org/'
path_passive = 'v2/dns/passive'
path_classification = 'v2/actions/classification'
path_tags = 'v2/actions/tags'
def main_request(path, query):
data = {"query": query}
res = requests.get(url + path, auth=auth, json=data)
return res.json()
with open(str(sys.argv[3])) as file:
line = file.readline()
while line:
results = main_request(path_passive, line.strip())
for i in results['results']:
tags = main_request(path_tags, i['resolve'])
classification = main_request(path_classification, i['resolve'])
print('{} | Classification: "{}" | Tags: "{}" | Domain: {}'.format(line.strip(),
classification['classification'], tags['tags'], i['resolve']))
# Uncomment the print comment to get a line break for each IP output
# print('')
line = file.readline()