-
Notifications
You must be signed in to change notification settings - Fork 1
/
malpedia.py
31 lines (26 loc) · 1007 Bytes
/
malpedia.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
#!/usr/bin/env python3
import json
import re
import requests
from sharedutils import openjson
response = requests.get('https://malpedia.caad.fkie.fraunhofer.de/api/get/families')
if response.status_code != 200:
print(response.text)
exit(0)
families = json.loads(response.text)
groups = openjson("groups.json")
for family in families:
names = []
names.append(families[family]['common_name'])
names.extend(families[family]['alt_names'])
names = [x.lower() for x in names]
#print(family)
#print(names)
for group in groups:
if group.get('description') is None:
if group['name'] in names:
if families[family]['description'].lower() != "ransomware.":
group['description'] = re.sub(r'[\n\t\r]', '', families[family]['description'])
with open('groups.json', 'w', encoding='utf-8') as groupsfile:
json.dump(groups, groupsfile, ensure_ascii=False, indent=4)
groupsfile.close()