-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhash_fliter.py
More file actions
43 lines (26 loc) · 854 Bytes
/
hash_fliter.py
File metadata and controls
43 lines (26 loc) · 854 Bytes
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
import hashlib
import os
import angr
from collections import defaultdict
def gethashcode(path):
md5 = hashlib.md5()
if not path.endswith(".bin"):
return
proj=angr.Project(path,auto_load_libs=False)
obj=proj.loader.main_object
for sec in obj.sections:
md5.update(str(sec).encode(encoding="utf-8"))
return md5.hexdigest()
def get_flitered_files(filedir):
dict_one_to_more = defaultdict(list)
for r, d, f in os.walk(filedir):
for file in f:
try:
hash = gethashcode(os.path.join(r, file))
if not hash == None:
print(hash)
print(os.path.join(r, file))
dict_one_to_more[hash].append(os.path.join(r, file))
except:
continue
return dict_one_to_more