Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New signatures, optimized scanning progress, fixes for Auth #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/scanner/classes/Auth.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private function setNewPassword($password)
}
}

public function auth()
public function authenticate()
{
$result = false;
$isPasswordSet = is_file($this->passwordHashFilepath);
Expand Down
2 changes: 1 addition & 1 deletion src/scanner/classes/DownloadController.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private function startDownload()
public function start()
{
$authenticator = new Auth();
if ($authenticator->auth()) {
if ($authenticator->authenticate()) {
$this->startDownload();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/scanner/classes/ExecutorController.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private function getShortFileName($in_name)
public function start()
{
$authenticator = new Auth();
if ($authenticator->auth()) {
if ($authenticator->authenticate()) {
$this->startExecutor();
}
}
Expand Down
29 changes: 21 additions & 8 deletions src/scanner/classes/MalwareDetector.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

class MalwareDetector
{
private $singatureStruct;

function __construct()
{
global $projectRootDir, $projectTmpDir;
Expand Down Expand Up @@ -41,8 +43,21 @@ function __construct()
$this->signatures = new DOMDocument();
$this->signatures->load($this->SIGNATURE_FILENAME);

$db = $this->signatures->getElementsByTagName('signature');
foreach ($db as $sig) {
$sigContent = $sig->nodeValue;
$attr = $sig->attributes;
$attrId = $attr->getNamedItem('id')->nodeValue;
$attrFormat = $attr->getNamedItem('format')->nodeValue;
$attrChildId = $attr->getNamedItem('child_id')->nodeValue;
$attrSeverity = $attr->getNamedItem('sever')->nodeValue;

$this->singatureStruct[] = array('sig' => $sigContent, 'attr_id' => $attrId, 'frmt' => $attrFormat, 'chid' => $attrChildId, 'sev' => $attrSeverity);
}

}


function setRequestDelay($delay)
{
$this->MAX_EXECUTION_DURATION = $delay;
Expand Down Expand Up @@ -168,9 +183,8 @@ function detectMalware($filePath, &$foundFragment, &$pos, $startTime, $timeout,

$normalized = $this->normalizeContent($content);

$db = $this->signatures->getElementsByTagName('signature');
$detected = false;
foreach ($db as $sig) {
foreach ($this->singatureStruct as $sig) {
if ($detected) break;

$currentTime = time();
Expand All @@ -179,12 +193,11 @@ function detectMalware($filePath, &$foundFragment, &$pos, $startTime, $timeout,
}

$pos = -1;
$sigContent = $sig->nodeValue;
$attr = $sig->attributes;
$attrId = $attr->getNamedItem('id')->nodeValue;
$attrFormat = $attr->getNamedItem('format')->nodeValue;
$attrChildId = $attr->getNamedItem('child_id')->nodeValue;
$attrSeverity = $attr->getNamedItem('sever')->nodeValue;
$sigContent = $sig['sig'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Какое совпадение, я как раз в данный момент пишу этот же код, начав полчаса назад, т.к. сложно разобраться какая сигнатура сработала, не имея её id. Надо довести больше данных о детекте до конечного лога.
Я пришлю альтернативный пулл-реквест вскоре

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/antimalware/manul/pull/99/files посмотри, пожалуйста. Добавлю поддержку в анализатор чуть погодя

$attrId = $sig['attr_id'];
$attrFormat = $sig['frmt'];
$attrChildId = $sig['chid'];
$attrSeverity = $sig['sev'];

switch ($attrFormat) {

Expand Down
2 changes: 1 addition & 1 deletion src/scanner/classes/ScannerController.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function start()
global $projectTmpDir, $php_errormsg;

$authenticator = new Auth();
if ($authenticator->auth()) {
if ($authenticator->authenticate()) {

ob_start();

Expand Down
Loading