forked from yanminglai/Malware-GAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_apistats.py
21 lines (20 loc) · 921 Bytes
/
extract_apistats.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import glob, os, json
reports_dir = 'C:/Users/Kuan/Desktop/malgan_exp*'
dirs = glob.glob(reports_dir)
for d in dirs:
loadpath = os.path.join(d, 'reports', 'report.json')
if os.path.exists(loadpath):
with open(loadpath, 'r') as f:
data = json.load(f)
name = data['target']['file']['name']
print(name)
if 'behavior' in data:
if 'apistats' in data['behavior']:
data = data['behavior']['apistats']
apistats = {}
for apistat in data.values():
apistats = dict(apistats, **apistat)
savejson = {'name': name, 'apistats': apistats, 'class': 'benign'}
savepath = os.path.join('../apistats', name[:-3]+'json')
with open(savepath, 'w') as s:
json.dump(savejson, s, ensure_ascii=False)