forked from cocaman/malware-bazaar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbazaar_list_samples.py
More file actions
35 lines (26 loc) · 1.19 KB
/
bazaar_list_samples.py
File metadata and controls
35 lines (26 loc) · 1.19 KB
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
#!/usr/bin/env python3
import requests
import sys
import argparse
import json
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__ = "cocaman@gmail.com"
parser = argparse.ArgumentParser(description='Get most recent samples on Malware Bazaar by abuse.ch')
parser.add_argument('-s', '--selector', help='Selector type you want', type=str, metavar="SELECTOR", required=False, default="100", choices=['100', 'time'])
parser.add_argument('-f', '--field', help='Single field you want', type=str, metavar="FIELD", required=False, choices=['sha256_hash', 'sha1_hash', 'md5_hash', 'file_name', 'signature', 'imphash'])
args = parser.parse_args()
headers = { 'API-KEY': '' }
data = {
'query': 'get_recent',
'selector': str(args.selector),
}
response = requests.post('https://mb-api.abuse.ch/api/v1/', data=data, timeout=15, headers=headers)
json_response = response.content.decode("utf-8", "ignore")
if(args.field):
query = ".data[]." + args.field
json_response = jq(query).transform(text=json_response, text_output=True)
print(json_response)