From 696d5117a8520f69a511ef9f5f5cc5760e8d0db9 Mon Sep 17 00:00:00 2001 From: jim-p Date: Thu, 24 Jun 2010 11:09:57 -0400 Subject: Adding antivirus status widget from dvserg. --- config/widget-antivirus/antivirus_status.inc | 7 + .../widget-antivirus/antivirus_status.widget.php | 160 +++++++++++++++++++++ config/widget-antivirus/widget-antivirus.inc | 8 ++ config/widget-antivirus/widget-antivirus.xml | 70 +++++++++ 4 files changed, 245 insertions(+) create mode 100644 config/widget-antivirus/antivirus_status.inc create mode 100644 config/widget-antivirus/antivirus_status.widget.php create mode 100644 config/widget-antivirus/widget-antivirus.inc create mode 100644 config/widget-antivirus/widget-antivirus.xml diff --git a/config/widget-antivirus/antivirus_status.inc b/config/widget-antivirus/antivirus_status.inc new file mode 100644 index 00000000..48c06f9e --- /dev/null +++ b/config/widget-antivirus/antivirus_status.inc @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/config/widget-antivirus/antivirus_status.widget.php b/config/widget-antivirus/antivirus_status.widget.php new file mode 100644 index 00000000..650c0f95 --- /dev/null +++ b/config/widget-antivirus/antivirus_status.widget.php @@ -0,0 +1,160 @@ +. + Part of pfSense widgets (www.pfsense.com) + originally based on m0n0wall (http://m0n0.ch/wall) + + Copyright (C) 2004-2005 T. Lechat , Manuel Kasper + and Jonathan Watt . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once("guiconfig.inc"); +require_once("pfsense-utils.inc"); +require_once("functions.inc"); + +define('PATH_CLAMDB', '/var/db/clamav'); +define('PATH_HAVPLOG', '/var/log/havp/access.log'); +define('PATH_AVSTATUS', '/var/tmp/havp.status'); + +function havp_avdb_info($filename) +{ + $stl = "style='padding-top: 0px; padding-bottom: 0px; padding-left: 4px; padding-right: 4px; border-left: 1px solid #999999;'"; + $r = ''; + $path = PATH_CLAMDB . "/{$filename}"; + if (file_exists($path)) { + $handle = ''; + if ($handle = fopen($path, "r")) { + $s = fread($handle, 1024); + $s = explode(':', $s); + + # datetime + $dt = explode(" ", $s[1]); + $s[1] = strftime("%d.%m.%Y", strtotime("{$dt[0]} {$dt[1]} {$dt[2]}")); + if ($s[0] == 'ClamAV-VDB') + $r .= "{$filename}{$s[1]}{$s[2]}{$s[7]}"; + } + fclose($handle); + } + return $r; +} + +function dwg_avbases_info() +{ + $db = ''; + $db .= ''; + $db .= havp_avdb_info("daily.cld"); + $db .= havp_avdb_info("main.cvd"); + $db .= havp_avdb_info("safebrowsing.cld"); + $db .= '
DatabaseDateVer.Builder
'; + return $db; +} + +function dwg_av_statistic() +{ + $s = "Unknown."; + if (file_exists(PATH_HAVPLOG)) { + $log = file_get_contents(PATH_HAVPLOG); + +$count = substr_count(strtolower($log), "virus clamd:"); +$s = "Found $count viruses (total)."; + +/* +# slowly worked - need apply cache or preparse stat + + $log = explode("\n", $log); + # counters: day, week, mon, total + $count = 0; + foreach($log as $ln) { + $ln = explode(' ', $ln); + # 0:date 1:time 2:ip 3:get 4:len 5:url 6:xx 7:status + if (strpos(strtolower($ln[7]), "virus") !== false) { + $count++; + } + } + $s = "Found viruses:
"; + $s .= ""; + $s .= ""; + $s .= ""; + $s .= "
todayweekmontotal
000$count
"; +*/ + } + + return $s; +} + +?> + + + + + + + + + + + + + + + + + + + + + + + + +
HTTP Scanner + +
Antivirus Scanner + +
Antivirus Bases + +
Last Update + +
Statistic + +
+ diff --git a/config/widget-antivirus/widget-antivirus.inc b/config/widget-antivirus/widget-antivirus.inc new file mode 100644 index 00000000..620d8e82 --- /dev/null +++ b/config/widget-antivirus/widget-antivirus.inc @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/config/widget-antivirus/widget-antivirus.xml b/config/widget-antivirus/widget-antivirus.xml new file mode 100644 index 00000000..90580769 --- /dev/null +++ b/config/widget-antivirus/widget-antivirus.xml @@ -0,0 +1,70 @@ + + + + + + . + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + ]]> + + Antivirus status widget add-on for Dashboard package and HAVP + Dashboard package and HAVP + Currently there are no FAQ items provided. + widget-antivirus + 0.1 + Widget - Antivirus Status + /usr/local/pkg/widget-antivirus.inc + + /usr/local/pkg/ + 077 + http://www.pfsense.com/packages/config/widget-antivirus/widget-antivirus.inc + + + /usr/local/www/widgets/include/ + 0644 + http://www.pfsense.com/packages/config/widget-antivirus/antivirus_status.inc + + + /usr/local/www/widgets/widgets/ + 0644 + http://www.pfsense.com/packages/config/widget-antivirus/antivirus_status.widget.php + + + widget_antivirus_uninstall(); + + -- cgit v1.2.3