-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathbazaar_json.py
25 lines (21 loc) · 990 Bytes
/
bazaar_json.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
#!/usr/bin/env python3
import requests
import json
import os
from jq import jq
__author__ = "Corsin Camichel"
__copyright__ = "Copyright 2020, Corsin Camichel"
__license__ = "Creative Commons Attribution-ShareAlike 4.0 International License."
__version__ = "1.0"
__email__ = "[email protected]"
JQ_QUERY = ".data[].sha256_hash"
if __name__ == '__main__':
data = {'query': 'get_recent', 'selector': "time"}
response = requests.post('https://mb-api.abuse.ch/api/v1/', data=data, timeout=15)
json_response = response.content.decode("utf-8", "ignore")
response = jq(JQ_QUERY).transform(text=json_response, multiple_output=True)
for sample_sha256 in response:
if(os.path.isfile(sample_sha256+'.json') == False):
data = {'query': 'get_info', 'hash': sample_sha256}
response = requests.post('https://mb-api.abuse.ch/api/v1/', data=data, timeout=15, allow_redirects=True)
open(sample_sha256+'.json', 'wb').write(response.content)