mirror of
https://github.com/scr34m/php-malware-scanner.git
synced 2026-06-16 12:30:35 +00:00
New arguments to follow symlinked directories, default is not to follow
This commit is contained in:
@@ -14,7 +14,8 @@ Usage scan.php -d <directory> [-e=.php] [--hide-ok] [--hide-whitelist]
|
||||
-e=.php Extension
|
||||
--hide-ok Hide OK aka not infected messages
|
||||
--hide-whitelist Hide whitelisted messages
|
||||
--extra-check Adds GoogleBot and htaccess to Scan List.
|
||||
--extra-check Adds GoogleBot and htaccess to Scan List
|
||||
--follow-symlink Follow symlinked directories
|
||||
```
|
||||
|
||||
Whitelisting
|
||||
|
||||
18
scan.php
18
scan.php
@@ -26,17 +26,18 @@ class MalwareScanner
|
||||
private $extension = '.php';
|
||||
private $flagHideOk = false;
|
||||
private $flagHideWhitelist = false;
|
||||
private $ExtraCheck = false;
|
||||
private $extraCheck = false;
|
||||
private $whitelist = array();
|
||||
private $stat = array(
|
||||
'directories' => 0,
|
||||
'files_scanned' => 0,
|
||||
'files_infected' => 0,
|
||||
);
|
||||
private $followSymlink = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$options = getopt('hd:e::', array('hide-ok', 'hide-whitelist', 'extra-check'));
|
||||
$options = getopt('hd:e::', array('hide-ok', 'hide-whitelist', 'extra-check', 'follow-symlink'));
|
||||
if (isset($options['h'])) {
|
||||
$this->showHelp();
|
||||
} else {
|
||||
@@ -54,7 +55,10 @@ class MalwareScanner
|
||||
$this->flagHideWhitelist = true;
|
||||
}
|
||||
if (isset($options['extra-check'])) {
|
||||
$this->ExtraCheck = true;
|
||||
$this->extraCheck = true;
|
||||
}
|
||||
if (isset($options['follow-symlink'])) {
|
||||
$this->followSymlink = true;
|
||||
}
|
||||
if (isset($options['d'])) {
|
||||
$this->run($options['d']);
|
||||
@@ -106,6 +110,9 @@ class MalwareScanner
|
||||
if ($file == '.' || $file == '..') {
|
||||
continue;
|
||||
}
|
||||
if (!$this->followSymlink && is_link($dir . $file)) {
|
||||
continue;
|
||||
}
|
||||
if (is_dir($dir . $file)) {
|
||||
$this->process($dir . $file . '/');
|
||||
} elseif (is_file($dir . $file)) {
|
||||
@@ -300,7 +307,7 @@ class MalwareScanner
|
||||
'C0derz.com',
|
||||
'Mr.HiTman',
|
||||
);
|
||||
if ($this->ExtraCheck) {
|
||||
if ($this->extraCheck) {
|
||||
array_push($patterns, "googleBot", "htaccess");
|
||||
}
|
||||
foreach ($patterns as $toSearch) {
|
||||
@@ -389,7 +396,8 @@ class MalwareScanner
|
||||
echo ' -e=.php Extension' . PHP_EOL;
|
||||
echo ' --hide-ok Hide OK aka not infected messages' . PHP_EOL;
|
||||
echo ' --hide-whitelist Hide whitelisted messages' . PHP_EOL;
|
||||
echo ' --extra-check Adds GoogleBot and htaccess to Scan List.' . PHP_EOL;
|
||||
echo ' --extra-check Adds GoogleBot and htaccess to Scan List' . PHP_EOL;
|
||||
echo ' --follow-symlink Follow symlinked directories' . PHP_EOL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user