scr34m / php-malware-scanner

Scans PHP files for malwares and known threats
GNU General Public License v3.0
556 stars 96 forks source link

Multi Directory Scan doesn't work #56

Closed puneetjain321 closed 4 years ago

puneetjain321 commented 4 years ago

Hi,

I am no sure if this is a bug or it can be considered a new feature request, but when I run the below command, it seems to just scan the first directory in the list

php scan.php -k -w -L -s -p -m --combined-whitelist -d /var/www/{simplesamlphp,drupal,moodle}

I have also tried to pass multiple directories by using -d option multiple times, but it throws an error and displays the help menu

php scan.php -k -w -L -s -p -m --combined-whitelist -d /var/www/simplesamlphp -d /var/www/drupal -d /var/www/moodle

I am not sure if the OS version helps but I am running these commands on Ubuntu 18.x

Thanks.

scr34m commented 4 years ago

Yes, using "{" and "}" is not supported and multiple "-d" option neither, but i will implement multiple use of "-d".

puneetjain321 commented 4 years ago

Thanks for that.

I also made a small change in scan.php to make the code compatible with braces "{' and "}" If you like you can use it

  public function __construct($cli = true)
    {
        if ($cli === true) {
            //Read Run Options
            $this->parseArgs();
            $pathArr = glob($this->dir,GLOB_BRACE);

            //Make sure a directory was specified.
            if (count($pathArr) === 0) {
                $this->error('No directory specified or directory doesn\'t exist');
                exit(-1);
            }
            foreach ($pathArr as $dirPath){
                $this->dir = realpath($dirPath);
                echo 'scanning for ' . $this->dir . PHP_EOL ;
                //Make sure a directory was specified.
                if ($this->dir === '') {
                    $this->error('No directory specified or directory doesn\'t exist');
                    exit(-1);
                }

                //Initiate Scan
                if (!$this->run($this->dir)) {
                    exit(-1);
                }
            }
        }
    }

The only issue is, it keeps printing the report for each folder I have added in the braces.

Command I used was

php scan.php -k -w -L -s -p -m --combined-whitelist -d '/var/www/{simplesamlphp,drupal,moodle}'

Thanks.

scr34m commented 4 years ago

With the new 1.0.6 version now you can use: