Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion grouping/pe_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import math
import argparse
import redis
from collections import Counter
try:
from configparser import SafeConfigParser
except ImportError:
Expand Down Expand Up @@ -108,9 +109,10 @@ def H(data):
if not data:
return 0

occurrences = Counter(bytearray(data))
entropy = 0
for x in range(256):
p_x = float(data.count(bytes(x))) / len(data)
p_x = float(occurrences[x]) / len(data)
if p_x > 0:
entropy += - p_x * math.log(p_x, 2)
return entropy
Expand Down