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

use named virus regex; added avast regexp; fix nod32-1.99 virus regex #1133

Merged
merged 2 commits into from
Dec 13, 2019
Merged
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
45 changes: 24 additions & 21 deletions mailscanner/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,61 +178,64 @@ function getVirusRegex($scanner = null)
$regex = '/^Dummy$/';
break;
case 'sophos':
$regex = '/(>>>) Virus \'(\S+)\' found/';
$regex = '/>>> Virus \'(?P<virus>\S+)\' found in (?P<file>.*)/';
break;
case 'sophossavi':
$regex = '/(\S+) was infected by (\S+)/';
$regex = '/(?P<file>\S+) was infected by (?P<virus>\S+)/';
break;
case 'clamav':
$regex = '/(.+) contains (\S+)/';
$regex = '/(?P<file>.+) contains (?P<virus>\S+)/';
break;
case 'clamd':
$regex = '/(.+) was infected: (\S+)/';
$regex = '/(?P<file>.+) was infected: (?P<virus>\S+)/';
break;
case 'clamavmodule':
$regex = '/(.+) was infected: (\S+)/';
$regex = '/(?P<file>.+) was infected: (?P<virus>\S+)/';
break;
case 'f-prot':
$regex = '/(.+) Infection: (\S+)/';
$regex = '/(?P<file>.+) Infection: (?P<virus>\S+)/';
break;
case 'f-prot-6':
$regex = '/(.+) Infection: (\S+)/';
$regex = '/(?P<file>.+) Infection: (?P<virus>\S+)/';
break;
case 'f-protd-6':
$regex = '/(.+) Infection: (\S+)/';
$regex = '/(?P<file>.+) Infection: (?P<virus>\S+)/';
break;
case 'mcafee':
$regex = '/(.+) Found the (\S+) virus !!!/';
$regex = '/(?P<file>.+) Found the (?P<virus>\S+) virus !!!/';
break;
case 'mcafee6':
$regex = '/(.+) Found the (\S+) virus !!!/';
$regex = '/(?P<file>.+) Found the (?P<virus>\S+) virus !!!/';
break;
case 'f-secure':
$regex = '/(.+) Infected: (\S+)/';
$regex = '/(?P<file>.+) Infected: (?P<virus>\S+)/';
break;
case 'trend':
$regex = '/(Found virus) (\S+) in file (\S+)/';
$regex = '/Found virus (?P<virus>\S+) in file (?P<file>\S+)/';
break;
case 'bitdefender':
$regex = '/(\S+) Found virus (\S+)/';
$regex = '/(?P<file>\S+) Found virus (?P<virus>\S+)/';
break;
case 'kaspersky-4.5':
$regex = '/(.+) INFECTED (\S+)/';
$regex = '/(?P<file>.+) INFECTED (?P<virus>\S+)/';
break;
case 'etrust':
$regex = '/(\S+) is infected by virus: (\S+)/';
$regex = '/(?P<file>\S+) is infected by virus: (?P<virus>\S+)/';
break;
case 'avg':
$regex = '/(Found virus) (\S+) in file (\S+)/';
$regex = '/Found virus (?P<virus>\S+) in file (?P<file>\S+)/';
break;
case 'norman':
$regex = '/(Found virus) (\S+) in file (\S+)/';
$regex = '/Found virus (?P<virus>\S+) in file (?P<file>\S+)/';
break;
case 'nod32-1.99':
$regex = '/(Found virus) (\S+) in (\S+)/';
$regex = '/Found virus (?P<virus>\S+) in (?P<file>\S+)/';
break;
case 'antivir':
$regex = '/(ALERT:) \[(\S+) \S+\]/';
$regex = '/ALERT: \[(?P<virus>\S+) \S+\]/';
break;
case 'avast':
$regex = '/Avast: found (?P<virus>.+) in (?P<file>.*)';
break;
//default:
// die("<B>" . __('dieerror03') . "</B><BR>\n&nbsp;" . __('diescanner03' . "\n");
Expand Down Expand Up @@ -4924,8 +4927,8 @@ function getVirus($report)
}
}
}
if (count($match) > 2) {
return $match[2];
if (isset($match['virus'])) {
return $match['virus'];
}
return $report;
}
42 changes: 23 additions & 19 deletions mailscanner/rep_viruses.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,69 +42,73 @@
switch ($vscanner) {
case('sophos'):
$scanner[$vscanner]['name'] = 'Sophos';
$scanner[$vscanner]['regexp'] = "/(>>>) Virus \'(\S+)\' found/";
$scanner[$vscanner]['regexp'] = "/>>> Virus \'(?P<virus>\S+)\' found in (?P<file>\S+)/";
break;
case('sophossavi'):
$scanner[$vscanner]['name'] = 'Sophos SAVI';
$scanner[$vscanner]['regexp'] = "/(\S+) was infected by (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>\S+) was infected by (?P<virus>\S+)/";
break;
case('clamav'):
$scanner[$vscanner]['name'] = 'ClamAV';
$scanner[$vscanner]['regexp'] = "/(.+) contains (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) contains (?P<virus>\S+)/";
break;
case('clamd'):
$scanner[$vscanner]['name'] = 'ClamD';
#ORIG#$scanner[$vscanner]['regexp'] = "/(.+) contains (\S+)/";
$scanner[$vscanner]['regexp'] = "/(.+) was infected: (\S+)/";
#ORIG#$scanner[$vscanner]['regexp'] = "/(?P<file>.+) contains (?P<virus>\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) was infected: (?P<virus>\S+)/";
break;
case('clamavmodule'):
$scanner[$vscanner]['name'] = 'Clam AV Module';
$scanner[$vscanner]['regexp'] = "/(.+) was infected: (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) was infected: (?P<virus>\S+)/";
break;
case('f-prot'):
$scanner[$vscanner]['name'] = 'F-Prot';
$scanner[$vscanner]['regexp'] = "/(.+) Infection: (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) Infection: (?P<virus>\S+)/";
break;
case('mcafee'):
case('mcafee6'):
$scanner[$vscanner]['name'] = 'McAfee';
$scanner[$vscanner]['regexp'] = "/(.+) Found the (\S+) (trojan|virus) !!!/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) Found the (?P<virus>\S+) (trojan|virus) !!!/";
break;
case('f-secure'):
$scanner[$vscanner]['name'] = 'F-Secure';
$scanner[$vscanner]['regexp'] = "/(.+) Infected: (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) Infected: (?P<virus>\S+)/";
break;
case('trend'):
$scanner[$vscanner]['name'] = 'Trend';
$scanner[$vscanner]['regexp'] = "/(Found virus) (\S+) in file (\S+)/";
$scanner[$vscanner]['regexp'] = "/Found virus (?P<virus>\S+) in file (?P<file>\S+)/";
break;
case('bitdefender'):
$scanner[$vscanner]['name'] = 'BitDefender';
$scanner[$vscanner]['regexp'] = "/(.+) Found virus (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) Found virus (?P<virus>\S+)/";
break;
case('kaspersky-4.5'):
$scanner[$vscanner]['name'] = 'Kaspersky';
$scanner[$vscanner]['regexp'] = "/(.+) INFECTED (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>.+) INFECTED (?P<virus>\S+)/";
break;
case('etrust'):
$scanner[$vscanner]['name'] = 'E-Trust';
$scanner[$vscanner]['regexp'] = "/(\S+) is infected by virus: (\S+)/";
$scanner[$vscanner]['regexp'] = "/(?P<file>\S+) is infected by virus: (?P<virus>\S+)/";
break;
case('avg'):
$scanner[$vscanner]['name'] = 'AVG';
$scanner[$vscanner]['regexp'] = "/(Found virus) (\S+) in file (\S+)/";
$scanner[$vscanner]['regexp'] = "/Found virus (?P<virus>\S+) in file (?P<file>\S+)/";
break;
case('norman'):
$scanner[$vscanner]['name'] = 'Norman';
$scanner[$vscanner]['regexp'] = "/(Found virus) (\S+) in file (\S+)/";
$scanner[$vscanner]['regexp'] = "/Found virus (?P<virus>\S+) in file (?P<file>\S+)/";
break;
case('nod32-1.99'):
$scanner[$vscanner]['name'] = "NOD32';
$scanner[$vscanner]['regexp'] = '/(Found virus) (\S+) in (\S+)/";
$scanner[$vscanner]['name'] = 'NOD32';
$scanner[$vscanner]['regexp'] = "/Found virus (?P<virus>\S+) in (?P<file>\S+)/";
break;
case('antivir'):
$scanner[$vscanner]['name'] = 'AntiVir';
$scanner[$vscanner]['regexp'] = "/(ALERT:) \[(\S+) \S+\]/";
$scanner[$vscanner]['regexp'] = "/ALERT: \[(?P<virus>\S+) \S+\]/";
break;
case('avast'):
$scanner[$vscanner]['name'] = 'Avast';
$scanner[$vscanner]['regexp'] = "/Avast: found (?P<virus>.*) in (?P<file>.*)/";
break;
}
}
Expand Down Expand Up @@ -133,7 +137,7 @@
while ($row = $result->fetch_object()) {
foreach ($scanner as $scan => $vals) {
if (preg_match($vals['regexp'], $row->report, $virus_report)) {
$virus = $virus_report[2];
$virus = $virus_report['virus'];
if (!isset($virus_array[$virus])) {
$virus_array[$virus]['first_seen'] = $row->timestamp;
$virus_array[$virus]['scanner'] = $vals['name'];
Expand Down