|
8 | 8 | * License: GNU/GPLv2
|
9 | 9 | * @see LICENSE.txt
|
10 | 10 | *
|
11 |
| - * This file: The scanner (last modified: 2024.11.06). |
| 11 | + * This file: The scanner (last modified: 2025.03.21). |
12 | 12 | */
|
13 | 13 |
|
14 | 14 | namespace phpMussel\Core;
|
@@ -1311,6 +1311,9 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
1311 | 1311 | $str_hex_html = bin2hex($str_html);
|
1312 | 1312 | $str_hex_html_len = $str_html_len * 2;
|
1313 | 1313 |
|
| 1314 | + /** Shannon entropy. */ |
| 1315 | + $Entropy = $this->Loader->Demojibakefier->shannonEntropy($str); |
| 1316 | + |
1314 | 1317 | /** Look for potential Linux/ELF indicators. */
|
1315 | 1318 | $is_elf = ($fourcc === '7f454c46' || $xt === 'elf');
|
1316 | 1319 |
|
@@ -1695,6 +1698,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
1695 | 1698 | 'ScanPhase' => $phase,
|
1696 | 1699 | 'Container' => $container,
|
1697 | 1700 | 'FileSwitch' => $fileswitch,
|
| 1701 | + 'Entropy' => $Entropy, |
1698 | 1702 | 'Is_ELF' => $is_elf,
|
1699 | 1703 | 'Is_Graphics' => $is_graphics,
|
1700 | 1704 | 'Is_HTML' => $is_html,
|
@@ -2202,16 +2206,25 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
|
2202 | 2206 | }
|
2203 | 2207 | }
|
2204 | 2208 |
|
| 2209 | + /** Whether the entropy limits have been exceeded. */ |
| 2210 | + $EntropyLimited = ( |
| 2211 | + $Entropy > $this->Loader->Configuration['files']['entropy_limit'] && |
| 2212 | + $StringLength > $this->Loader->readBytes($this->Loader->Configuration['files']['entropy_filesize_limit']) |
| 2213 | + ); |
| 2214 | + |
2205 | 2215 | /** Process mappable signatures. */
|
2206 | 2216 | foreach ([
|
2207 |
| - ['Filename', 'str_hex', 'str_hex_len', 2], |
2208 |
| - ['Standard', 'str_hex', 'str_hex_len', 0], |
2209 |
| - ['Normalised', 'str_hex_norm', 'str_hex_norm_len', 0], |
2210 |
| - ['HTML', 'str_hex_html', 'str_hex_html_len', 0], |
2211 |
| - ['Standard_RegEx', 'str_hex', 'str_hex_len', 1], |
2212 |
| - ['Normalised_RegEx', 'str_hex_norm', 'str_hex_norm_len', 1], |
2213 |
| - ['HTML_RegEx', 'str_hex_html', 'str_hex_html_len', 1] |
| 2217 | + ['Filename', 'str_hex', 'str_hex_len', 2, false], |
| 2218 | + ['Standard', 'str_hex', 'str_hex_len', 0, false], |
| 2219 | + ['Normalised', 'str_hex_norm', 'str_hex_norm_len', 0, $EntropyLimited], |
| 2220 | + ['HTML', 'str_hex_html', 'str_hex_html_len', 0, false], |
| 2221 | + ['Standard_RegEx', 'str_hex', 'str_hex_len', 1, false], |
| 2222 | + ['Normalised_RegEx', 'str_hex_norm', 'str_hex_norm_len', 1, $EntropyLimited], |
| 2223 | + ['HTML_RegEx', 'str_hex_html', 'str_hex_html_len', 1, false] |
2214 | 2224 | ] as $ThisConf) {
|
| 2225 | + if ($ThisConf[4]) { |
| 2226 | + continue; |
| 2227 | + } |
2215 | 2228 | $DataSource = $ThisConf[1];
|
2216 | 2229 | $DataSourceLen = $ThisConf[2];
|
2217 | 2230 |
|
|
0 commit comments