Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/undo-ransomware/ransomware_detection.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Analyzer/EntropyAnalyzer.php12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Analyzer/EntropyAnalyzer.php b/lib/Analyzer/EntropyAnalyzer.php
index d3c7fdb..744ffe9 100644
--- a/lib/Analyzer/EntropyAnalyzer.php
+++ b/lib/Analyzer/EntropyAnalyzer.php
@@ -138,7 +138,7 @@ class EntropyAnalyzer
while (!feof($handle)) {
$data = fread($handle, $blockSize);
if (strlen($data) === $blockSize) {
- $entropyArray[$i] = $this->entropy->calculateEntropy($block);
+ array_push($entropyArray, $this->entropy->calculateEntropy($data));
}
}
fclose($handle);
@@ -176,16 +176,22 @@ class EntropyAnalyzer
return 0.0;
}
+ $entropy = 0.0;
+ $total = 0;
+
while (!feof($handle)) {
$data = fread($handle, 1024);
+ $total = $total + 1;
if (strlen($data) === 1024) {
- $entropy = $entropy + $this->entropy->calculateEntropy($block);
+ $entropy = $entropy + $this->entropy->calculateEntropy($data);
}
}
fclose($handle);
+ $entropy = $entropy / $total;
+
if ($entropy >= 0) {
- return $entopry;
+ return $entropy;
} else {
return -$entropy;
}