Created
August 11, 2019 04:49
-
-
Save kohnakagawa/aa37f1385f06805964cf840dfe2050a7 to your computer and use it in GitHub Desktop.
r2pipe を使ってセクションのエントロピーを計算し、パックされているものがあった場合には表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import r2pipe | |
import glob | |
import os | |
target_path = "data/malware" | |
def is_packed(entropy): | |
return any(filter(lambda x: x > 6.8, entropy)) | |
cnt = 0 | |
cnt_pck = 0 | |
for f in glob.glob(os.path.join(target_path, "*")): | |
r = r2pipe.open(f) | |
entropy = list(map(lambda x: float(x[8:]), filter(lambda x: "entropy" in x, r.cmd("iS entropy").split()))) | |
print(entropy) | |
if is_packed(entropy): | |
cnt_pck += 1 | |
cnt += 1 | |
print(f"{cnt} {cnt_pck}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment