New arguments to follow symlinked directories, default is not to follow

This commit is contained in:
Gabor Gyorvari
2016-12-27 17:51:39 +01:00
parent 1f6efc124b
commit 5675fb8e79
2 changed files with 15 additions and 6 deletions

View File

@@ -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;
}
}