Skip to content

Commit e08a2ac

Browse files
committed
feat: add new funtions encoded and add new decoders for functions
1 parent f360b77 commit e08a2ac

File tree

2 files changed

+68
-7
lines changed

2 files changed

+68
-7
lines changed

src/Definitions.php

+53
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,59 @@ class Definitions
483483
"escapeshellcmd",*/
484484
];
485485

486+
/**
487+
* Default encoded functions definitions.
488+
*
489+
* @var array
490+
*/
491+
public static $FUNCTIONS_ENCODED = [
492+
'il_exec',
493+
'shell_exec',
494+
'eval',
495+
'system',
496+
'create_function',
497+
'exec',
498+
'assert',
499+
'syslog',
500+
'passthru',
501+
'define_syslog_variables',
502+
'debugger_off',
503+
'debugger_on',
504+
'parse_ini_file',
505+
'show_source',
506+
'symlink',
507+
'popen',
508+
'posix_kill',
509+
'posix_getpwuid',
510+
'posix_mkfifo',
511+
'posix_setpgid',
512+
'posix_setsid',
513+
'posix_setuid',
514+
'posix_uname',
515+
'proc_close',
516+
'proc_get_status',
517+
'proc_nice',
518+
'proc_open',
519+
'proc_terminate',
520+
'ini_alter',
521+
'ini_get_all',
522+
'ini_restore',
523+
'parse_ini_file',
524+
'inject_code',
525+
'apache_child_terminate',
526+
'apache_setenv',
527+
'apache_note',
528+
'define_syslog_variables',
529+
'escapeshellarg',
530+
'escapeshellcmd',
531+
'base64_decode',
532+
'urldecode',
533+
'rawurldecode',
534+
'str_rot13',
535+
'preg_replace',
536+
'create_function',
537+
];
538+
486539
/**
487540
* Signatures.
488541
*

src/Scanner.php

+15-7
Original file line numberDiff line numberDiff line change
@@ -927,12 +927,19 @@ public function scanFile($info)
927927
* Encoded functions.
928928
*/
929929
if (in_array($funcRaw, self::$functionsEncoded)) {
930-
// Check base64 functions
931-
$regexPatternBase64 = '/' . base64_encode($funcRaw) . '/s';
932-
foreach ($contents as $content) {
933-
if (@preg_match_all($regexPatternBase64, $content, $matches, PREG_OFFSET_CAPTURE)) {
934-
foreach ($matches[0] as $match) {
935-
$checkFunction($match, $regexPatternBase64, Definitions::LVL_DANGEROUS, 'base64');
930+
$decoders = [
931+
'str_rot13',
932+
'base64_decode',
933+
'strrev',
934+
];
935+
foreach ($decoders as $decoder) {
936+
// Check encoded functions
937+
$regexPatternEncoded = '/' . @$decoder($funcRaw) . '/s';
938+
foreach ($contents as $content) {
939+
if (@preg_match_all($regexPatternEncoded, $content, $matches, PREG_OFFSET_CAPTURE)) {
940+
foreach ($matches[0] as $match) {
941+
$checkFunction($match, $regexPatternEncoded, Definitions::LVL_DANGEROUS, $decoder);
942+
}
936943
}
937944
}
938945
}
@@ -2020,7 +2027,8 @@ public static function setFunctions($functions)
20202027
*/
20212028
public static function setFunctionsEncoded($functions)
20222029
{
2023-
self::$functionsEncoded = $functions;
2030+
$encodedFunc = array_unique(array_merge($functions, Definitions::$FUNCTIONS_ENCODED));
2031+
self::$functionsEncoded = $encodedFunc;
20242032

20252033
return new static();
20262034
}

0 commit comments

Comments
 (0)