diff options
author | jim-p <jimp@pfsense.org> | 2010-06-24 11:09:57 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2010-06-24 11:09:57 -0400 |
commit | 696d5117a8520f69a511ef9f5f5cc5760e8d0db9 (patch) | |
tree | 9511b95bb50721a584c7b99b0c321e1adef33d96 /config | |
parent | a16850621d7fd847a20cad3cb94234ba4a9d500f (diff) | |
download | pfsense-packages-696d5117a8520f69a511ef9f5f5cc5760e8d0db9.tar.gz pfsense-packages-696d5117a8520f69a511ef9f5f5cc5760e8d0db9.tar.bz2 pfsense-packages-696d5117a8520f69a511ef9f5f5cc5760e8d0db9.zip |
Adding antivirus status widget from dvserg.
Diffstat (limited to 'config')
-rw-r--r-- | config/widget-antivirus/antivirus_status.inc | 7 | ||||
-rw-r--r-- | config/widget-antivirus/antivirus_status.widget.php | 160 | ||||
-rw-r--r-- | config/widget-antivirus/widget-antivirus.inc | 8 | ||||
-rw-r--r-- | config/widget-antivirus/widget-antivirus.xml | 70 |
4 files changed, 245 insertions, 0 deletions
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 @@ +<?php + +//set variable for custom title +$antivirus_status_title = "Antivirus Status"; +$antivirus_status_title_link = ""; + +?>
\ 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 @@ +<?php +/* + $Id: antivirus_statistics.widget.php + Copyright (C) 2010 Serg Dvoriancev <dv_serg@mail.ru>. + Part of pfSense widgets (www.pfsense.com) + originally based on m0n0wall (http://m0n0.ch/wall) + + Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net> + and Jonathan Watt <jwatt@jwatt.org>. + 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 .= "<tr class='listr'><td>{$filename}</td><td $stl>{$s[1]}</td><td $stl>{$s[2]}</td><td $stl>{$s[7]}</td></tr>"; + } + fclose($handle); + } + return $r; +} + +function dwg_avbases_info() +{ + $db = '<table width="100%" border="0" cellspacing="0" cellpadding="1" ><tbody>'; + $db .= '<tr class="vncellt" ><td>Database</td><td>Date</td><td>Ver.</td><td>Builder</td></tr>'; + $db .= havp_avdb_info("daily.cld"); + $db .= havp_avdb_info("main.cvd"); + $db .= havp_avdb_info("safebrowsing.cld"); + $db .= '</tbody></table>'; + 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:<br>"; + $s .= "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tbody>"; + $s .= "<tr align='center'><td>today</td><td>week</td><td>mon</td><td>total</td></tr>"; + $s .= "<tr align='center'><td>0</td><td>0</td><td>0</td><td>$count</td></tr>"; + $s .= "</tbody></table>"; +*/ + } + + return $s; +} + +?> + + <table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tbody> + <tr> + <td class="vncellt">HTTP Scanner</td> + <td class="listr" width=75%> + <?php + # havp version + echo exec("pkg_info | grep \"[h]avp\""); + ?> + </td> + </tr> + <tr> + <td class="vncellt">Antivirus Scanner</td> + <td class="listr" width=75%> + <?php + # Clamd version + echo exec("clamd -V"); + ?> + </td> + </tr> + <tr> + <td class="vncellt">Antivirus Bases</td> + <td class="listr" width=75%> + <?php + # Antivirus bases + if (function_exists("dwg_avbases_info")) + echo dwg_avbases_info(); + ?> + </td> + </tr> + <tr> + <td class="vncellt">Last Update</td> + <td class="listr" width=75%> + <?php + if (file_exists(PATH_AVSTATUS)) + echo file_get_contents(PATH_AVSTATUS); + else echo "Unknown." + ?> + </td> + </tr> + <tr> + <td class="vncellt">Statistic</td> + <td class="listr" width=75%> + <?php + echo dwg_av_statistic(); + ?> + </td> + </tr> + </tbody> + </table> + 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 @@ +<?php + +function widget_antivirus_uninstall() { + unlink("/usr/local/www/widgets/include/antivirus_status.inc"); + unlink("/usr/local/www/widgets/widgets/antivirus_status.widget.php"); +} + +?>
\ 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 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ========================================================================== */ +/* + widget-antivirus.xml + part of pfSense (http://www.pfSense.com) + Copyright (C) 2009 Jim Pingle + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + 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. + */ +/* ========================================================================== */ + ]]> + </copyright> + <description>Antivirus status widget add-on for Dashboard package and HAVP</description> + <requirements>Dashboard package and HAVP</requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>widget-antivirus</name> + <version>0.1</version> + <title>Widget - Antivirus Status</title> + <include_file>/usr/local/pkg/widget-antivirus.inc</include_file> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>077</chmod> + <item>http://www.pfsense.com/packages/config/widget-antivirus/widget-antivirus.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/widgets/include/</prefix> + <chmod>0644</chmod> + <item>http://www.pfsense.com/packages/config/widget-antivirus/antivirus_status.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/www/widgets/widgets/</prefix> + <chmod>0644</chmod> + <item>http://www.pfsense.com/packages/config/widget-antivirus/antivirus_status.widget.php</item> + </additional_files_needed> + <custom_php_deinstall_command> + widget_antivirus_uninstall(); + </custom_php_deinstall_command> +</packagegui> |