marcocesarato / PHP-Antimalware-Scanner

AMWScan (PHP Antimalware Scanner) is a free tool to scan php files and analyze your project to find any malicious code inside it.
https://marcocesarato.github.io/PHP-Antimalware-Scanner/
GNU General Public License v3.0
643 stars 108 forks source link

Crash on Deobfuscator.php:185 #113

Open Bot12313 opened 1 month ago

Bot12313 commented 1 month ago

I encounter crashes and warnings when analyzing a large code base. I can't provide the source code file where the problem occurs - I can't identify it, the crash occurs during analysis, but I was able to get the error log.

PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Warning:  mb_convert_encoding(): Unable to detect character encoding in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Console/CLI.php on line 507
PHP Warning:  preg_match_all(): Unknown modifier ''' in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 202
PHP Fatal error:  Uncaught TypeError: round(): Argument #1 ($num) must be of type int|float, string given in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php:185
Stack trace:
#0 /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php(185): round()
#1 [internal function]: AMWScan\Deobfuscator->AMWScan\{closure}()
#2 /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php(184): preg_replace_callback()
#3 /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php(49): AMWScan\Deobfuscator->deobfuscateBitrix()
#4 /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Scanner.php(921): AMWScan\Deobfuscator->deobfuscate()
#5 /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Scanner.php(1230): AMWScan\Scanner->scanFile()
#6 /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Scanner.php(387): AMWScan\Scanner->scan()
#7 /home/kurisu/projects/amws/index.php(11): AMWScan\Scanner->run()
#8 {main}
  thrown in /home/kurisu/projects/amws/vendor/marcocesarato/amwscan/src/Deobfuscator.php on line 185

Running with

<?php
include("vendor/autoload.php");

use AMWScan\Scanner;

$app = new Scanner();
Scanner::setPathScan("<project path>");
Scanner::enableReport();
Scanner::setPathReport("/home/kurisu/report.html");
Scanner::setSilentMode(true);
$app->run();

PHP Version

PHP 8.2.20 (cli) (built: Jun  8 2024 21:32:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.20, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.20, Copyright (c), by Zend Technologies

composer.json

{
    "require": {
        "marcocesarato/amwscan": "^0.14.0"
    }
}