diff --git a/scan.php b/scan.php index d54dbc4..044880a 100644 --- a/scan.php +++ b/scan.php @@ -164,6 +164,14 @@ class MalwareScanner $list = array(); if (is_readable($file)) { foreach (file($file) as $pattern) { + //Check if the line is only whitespace and skips. + if (strlen(trim($pattern)) == 0) { + continue; + } + //Check if first char in pattern is a '#' which indicates a comment and skips. + if ($pattern[0] === '#') { + continue; + } $list[] = trim($pattern); } } @@ -183,12 +191,6 @@ class MalwareScanner array_push($this->patterns_raw, "googleBot", "htaccess"); } foreach ($this->patterns_raw as $toSearch) { - if (!$toSearch) { - continue; - } - if ($toSearch[0] === '#') { - continue; - } if (strpos($fileContent, $toSearch) !== FALSE){ $found = true; if ($hash === ''){ @@ -203,12 +205,6 @@ class MalwareScanner if (!$found || $this->verbose) { foreach ($this->patterns_iraw as $toSearch) { - if (!$toSearch) { - continue; - } - if ($toSearch[0] === '#') { - continue; - } if (stripos($fileContent, $toSearch) !== FALSE){ $found = true; if ($hash === ''){ @@ -224,12 +220,6 @@ class MalwareScanner if (!$found || $this->verbose) { foreach ($this->patterns_re as $toSearch) { - if (!$toSearch) { - continue; - } - if ($toSearch[0] === '#') { - continue; - } if (preg_match('/' . $toSearch . '/im', $fileContent)) { $found = true; if ($hash === ''){