aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/imspector-dev/imspector.inc546
-rw-r--r--config/imspector-dev/imspector.xml251
-rw-r--r--config/imspector-dev/services_imspector_logs.php311
-rw-r--r--config/imspector/imspector.inc370
-rw-r--r--config/imspector/imspector.xml276
-rw-r--r--config/imspector/imspector_acls.xml (renamed from config/imspector-dev/imspector_acls.xml)0
-rw-r--r--config/imspector/imspector_logs.php (renamed from config/imspector-dev/imspector_logs.php)0
-rw-r--r--config/imspector/imspector_replacements.xml (renamed from config/imspector-dev/imspector_replacements.xml)0
-rw-r--r--config/imspector/imspector_sync.xml (renamed from config/imspector-dev/imspector_sync.xml)0
-rw-r--r--config/imspector/services_imspector_logs.php38
-rw-r--r--config/imspector/services_imspector_logs2.php (renamed from config/imspector-dev/services_imspector_logs2.php)0
11 files changed, 406 insertions, 1386 deletions
diff --git a/config/imspector-dev/imspector.inc b/config/imspector-dev/imspector.inc
deleted file mode 100644
index 52c7ae1b..00000000
--- a/config/imspector-dev/imspector.inc
+++ /dev/null
@@ -1,546 +0,0 @@
-<?php
-/*
- imspector.inc
- part of pfSense (http://www.pfsense.com/)
- Copyright (C) 2012 Marcello Coutinho.
- Copyright (C) 2011 Scott Ullrich <sullrich@gmail.com>.
- Copyright (C) 2011 Bill Marquette <billm@gmail.com>.
- Copyright (C) 2007 Ryan Wagoner <rswagoner@gmail.com>.
- 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("config.inc");
- require_once("functions.inc");
- require_once("service-utils.inc");
-
- /* IMSpector */
-
- define('IMSPECTOR_RCFILE', '/usr/local/etc/rc.d/imspector.sh');
- define('IMSPECTOR_ETC', '/usr/local/etc/imspector');
- define('IMSPECTOR_CONFIG', IMSPECTOR_ETC . '/imspector.conf');
-
- function imspector_warn ($msg) { syslog(LOG_WARNING, "imspector: {$msg}"); }
-
- function ims_text_area_decode($text){
- return preg_replace('/\r\n/', "\n",base64_decode($text));
- }
-
- function imspector_action ($action) {
- if (file_exists(IMSPECTOR_RCFILE))
- mwexec(IMSPECTOR_RCFILE.' '.$action);
- }
-
- function write_imspector_config($file, $text) {
- $conf = fopen($file, 'w');
- if(!$conf) {
- imspector_warn("Could not open {$file} for writing.");
- exit;
- }
- fwrite($conf, $text);
- fclose($conf);
- }
-
- function imspector_pf_rdr($iface, $port) {
- return "rdr pass on {$iface} inet proto tcp from any to any port = {$port} -> 127.0.0.1 port 16667\n";
- }
-
- function imspector_pf_rule($iface, $port) {
- return "pass in quick on {$iface} inet proto tcp from any to any port {$port} keep state\n";
- }
-
- function imspector_proto_to_port ($proto)
- {
- switch ($proto) {
- case 'gadu-gadu':
- return 8074;
- case 'jabber':
- return 5222;
- case 'jabber-ssl':
- return 5223;
- case 'msn':
- return 1863;
- case 'icq':
- return 5190;
- case 'yahoo':
- return 5050;
- case 'irc':
- return 6667;
- default:
- return null;
- }
- }
-
- function validate_form_imspector($post, $input_errors) {
- if($post['iface_array'])
- foreach($post['iface_array'] as $iface)
- if($iface == 'wanx')
- $input_errors[] = 'It is a security risk to specify WAN in the \'Interface\' field';
- }
-
- function deinstall_package_imspector() {
- imspector_action('stop');
-
- unlink_if_exists(IMSPECTOR_RCFILE);
- unlink_if_exists(IMSPECTOR_CONFIG);
- unlink_if_exists(IMSPECTOR_ETC . '/badwords_custom.txt');
- unlink_if_exists(IMSPECTOR_ETC . '/acl_blacklist.txt');
- unlink_if_exists(IMSPECTOR_ETC . '/acl_whitelist.txt');
- unlink_if_exists('/usr/local/www/imspector_logs.php');
-
- //exec('pkg_delete imspector-0.4');
- }
-
- function imspector_generate_rules($type) {
-
- $rules = "";
- switch ($type) {
- case 'rdr':
- case 'nat':
- $rules = "# IMSpector rdr anchor\n";
- $rules .= "rdr-anchor \"imspector\"\n";
- break;
- case 'rule':
- $rules = "# IMSpector \n";
- $rules .= "anchor \"imspector\"\n";
- break;
- }
-
- return $rules;
- }
-
- function sync_package_imspector() {
- global $config;
- global $input_errors;
-
- /*detect boot process*/
- if (is_array($_POST)){
- if (preg_match("/\w+/",$_POST['__csrf_magic']))
- unset($boot_process);
- else
- $boot_process="on";
- }
-
- if (is_process_running('imspector') && isset($boot_process))
- return;
-
- /* check default options and sample files*/
- $load_samples=0;
-
- #bannedphraselist
- if (!is_array($config['installedpackages']['imspectoracls'])){
- $config['installedpackages']['imspectoracls']['config'][]=array('enable'=> 'on',
- 'description' => 'allow access to all ids',
- 'action' => 'allow',
- 'localid' => 'all',
- 'remoteid' => base64_encode('all'));
- $load_samples++;
- }
- $ims_acls = $config['installedpackages']['imspectoracls']['config'];
-
- if (is_array($config['installedpackages']['imspectorreplacements'])){
- if ($config['installedpackages']['imspectorreplacements']['config'][0]['badwords_list'] == "" && file_exists(IMSPECTOR_ETC . '/badwords.txt')){
- $config['installedpackages']['imspectorreplacements']['config'][0]['badwords_list'] = base64_encode(file_get_contents(IMSPECTOR_ETC . '/badwords.txt'));
- $load_samples++;
- }
- $ims_replacements = $config['installedpackages']['imspectorreplacements']['config'][0];
- }
-
- if (is_array($config['installedpackages']['imspector']))
- $ims_config = $config['installedpackages']['imspector']['config'][0];
-
- if($load_samples > 0)
- write_config();
-
- /*continue sync process*/
- log_error("Imspector: Saving changes.");
- config_lock();
-
- /* remove existing rules */
- exec('/sbin/pfctl -a imspector -Fr > /dev/null');
- exec('/sbin/pfctl -a imspector -Fn > /dev/null');
-
- $ifaces_active = '';
-
- if($ims_config['enable'] && $ims_config['proto_array'])
- $proto_array = explode(',', $ims_config['proto_array']);
-
- if($ims_config['enable'] && $ims_config['iface_array'])
- $iface_array = explode(',', $ims_config['iface_array']);
-
- if($iface_array && $proto_array) {
- foreach($iface_array as $iface) {
- $if = convert_friendly_interface_to_real_interface_name($iface);
- /* above function returns iface if fail */
- if($if!=$iface) {
- $addr = find_interface_ip($if);
- /* non enabled interfaces are displayed in list on imspector settings page */
- /* check that the interface has an ip address before adding parameters */
- if($addr) {
- foreach($proto_array as $proto) {
- if(imspector_proto_to_port($proto)) {
- /* we can use rdr pass to auto create the filter rule */
- $pf_rules .= imspector_pf_rdr($if,imspector_proto_to_port($proto));
- }
- }
- if(!$ifaces_active)
- $ifaces_active = "{$iface}";
- else
- $ifaces_active .= ", {$iface}";
- } else {
- imspector_warn("Interface {$iface} has no ip address, ignoring");
- }
- } else {
- imspector_warn("Could not resolve real interface for {$iface}");
- }
- }
-
-
- /*reload rules*/
- if($pf_rules) {
- log_error("Imspector: Reloading rules.");
- exec("echo \"{$pf_rules}\" | /sbin/pfctl -a imspector -f -");
-
- conf_mount_rw();
-
- /* generate configuration files */
-
- $conf['plugin_dir'] = '/usr/local/lib/imspector';
-
- foreach($proto_array as $proto)
- $conf[$proto . '_protocol'] = 'on';
-
- if($ims_config['log_file']) {
- @mkdir('/var/imspector');
- $conf['file_logging_dir'] = '/var/imspector';
- }
-
- if($ims_config['log_mysql']) {
- $conf['mysql_server'] = $ims_config['mysql_server'];
- $conf['mysql_database'] = $ims_config['mysql_database'];
- $conf['mysql_username'] = $ims_config['mysql_username'];
- $conf['mysql_password'] = $ims_config['mysql_password'];
- }
-
- if($ims_replacements['filter_badwords']) {
- write_imspector_config(IMSPECTOR_ETC . '/badwords_custom.txt', ims_text_area_decode($ims_replacements["badwords_list"]));
- $conf['badwords_filename'] = IMSPECTOR_ETC . '/badwords_custom.txt';
- }
-
- if($ims_replacements['block_files'])
- $conf['block_files'] = 'on';
-
- if($ims_replacements['block_webcams'])
- $conf['block_webcams'] = 'on';
-
- $acls="";
- $conf['acl_filename'] = IMSPECTOR_ETC . '/acls.txt';
- foreach ($ims_acls as $rule){
- if ($rule['enable']){
- $acls.= "{$rule['action']} {$rule['localid']} ".preg_replace("/\s+/"," ",base64_decode($rule['remoteid']))."\n";
- }
- }
- write_imspector_config(IMSPECTOR_ETC . '/acls.txt', $acls);
-
- // Handle Jabber SSL options
- if(isset($ims_config["ssl_ca_cert"]) && $ims_config["ssl_ca_cert"] != "none" &&
- isset($ims_config["ssl_server_cert"]) && $ims_config["ssl_server_cert"] != "none") {
- $conf['ssl'] = "on";
- if(!is_dir(IMSPECTOR_ETC . "/ssl"))
- mkdir(IMSPECTOR_ETC . "/ssl");
-
- $ca_cert = lookup_ca($ims_config["ssl_ca_cert"]);
- if ($ca_cert != false) {
- if(base64_decode($ca_cert['prv'])) {
- file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_ca_key.pem", base64_decode($ca_cert['prv']));
- $conf['ssl_ca_key'] = IMSPECTOR_ETC . '/ssl/ssl_ca_key.pem';
- }
- if(base64_decode($ca_cert['crt'])) {
- file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_ca_cert.pem", base64_decode($ca_cert['crt']));
- $conf['ssl_ca_cert'] = IMSPECTOR_ETC . "/ssl/ssl_ca_cert.pem";
- }
- $svr_cert = lookup_cert($ims_config["ssl_server_cert"]);
- if ($svr_cert != false) {
- if(base64_decode($svr_cert['prv'])) {
- file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_server_key.pem", base64_decode($svr_cert['prv']));
- $conf['ssl_key'] = IMSPECTOR_ETC . '/ssl/ssl_server_key.pem';
- }
-
- }
- $conf['ssl_cert_dir'] = IMSPECTOR_ETC . '/ssl';
- }
- } else {
- // SSL Not enabled. Make sure Jabber-SSL is not processed.
- unset($conf['jabber-ssl']);
- unset($conf['ssl']);
- }
-
- if (isset($ims_replacements['responder']) && $ims_replacements['responder'] == 'on') {
- $conf['responder_filename'] = IMSPECTOR_ETC . "/responder.db";
- if (isset($ims_replacements['prefix_message']) && $ims_replacements['prefix_message'] != '' ) {
- $conf['response_prefix'] = " .={$ims_replacements['prefix_message']}=.";
- }
- else{
- $conf['response_prefix'] = " .=Your activities are being logged=.";
- }
- if (isset($ims_replacements['notice_days']) && is_numeric($ims_replacements['notice_days'])) {
- if ($ims_replacements['notice_days'] != 0) {
- $conf['notice_days'] = $ims_replacements['notice_days'];
- }
- } else {
- $conf['notice_days'] = 1;
- }
-
- /*Custom recorded message response*/
- if(isset($ims_replacements['recorded_message']) && $ims_replacements['recorded_message'] != '' ){
- $conf['notice_response'] = ims_text_area_decode($ims_replacements['recorded_message']);
- }
- else{
- $conf['notice_response'] = "Your activities are being logged";
- }
-
- /*Filtered Frequency*/
- if (isset($ims_replacements['filtered_minutes']) && is_numeric($ims_replacements['filtered_minutes'])) {
- if ($ims_replacements['filtered_minutes'] != 0) {
- $conf['filtered_mins'] = $ims_replacements['filtered_minutes'];
- }
- } else {
- $conf['filtered_mins'] = 15;
- }
-
- /*Custom filtered message response*/
- if(isset($ims_replacements['filtered_message']) && $ims_replacements['filtered_message'] != '' ){
- $conf['filtered_response'] = ims_text_area_decode($ims_replacements['filtered_message']);
- }
- else{
- $conf['filtered_response'] = "Your message has been filtered";
- }
- }
-
- $conftext = '';
- foreach($conf as $var => $key)
- $conftext .= "{$var}={$key}\n";
- write_imspector_config(IMSPECTOR_CONFIG, $conftext);
-
- /*Check template settings*/
- if ($ims_config['template'] == "")
- $template="services_imspector_logs.php";
- else
- $template=$ims_config['template'];
-
- /*link template file*/
- $link="/usr/local/www/imspector_logs.php";
- unlink_if_exists($link);
- symlink("/usr/local/www/{$template}", $link);
-
- /* generate rc file start and stop */
- $stop = <<<EOD
-/bin/pkill -x imspector
-/bin/sleep 1
-EOD;
- $start = $stop."\n\tldconfig -m /usr/local/lib/mysql\n";
- $start .= "\t/usr/local/sbin/imspector -c \"".IMSPECTOR_CONFIG."\"";
-
- write_rcfile(array(
- 'file' => 'imspector.sh',
- 'start' => $start,
- 'stop' => $stop
- )
- );
-
- conf_mount_ro();
- }
- }
-
- if(!$iface_array || !$proto_array || !$pf_rules) {
- /* no parameters user does not want imspector running */
- /* lets stop the service and remove the rc file */
-
- if(file_exists(IMSPECTOR_RCFILE)) {
- if(!$ims_config['enable'])
- log_error('Impsector: Stopping service: imspector disabled');
- else
- log_error('Impsector: Stopping service: no interfaces and/or protocols selected');
-
- imspector_action('stop');
-
- conf_mount_rw();
- unlink(IMSPECTOR_RCFILE);
- unlink(IMSPECTOR_CONFIG);
- @unlink(IMSPECTOR_ETC . '/badwords_custom.txt');
- @unlink(IMSPECTOR_ETC . '/acl_blacklist.txt');
- @unlink(IMSPECTOR_ETC . '/acl_whitelist.txt');
- conf_mount_ro();
- }
- }
- else{
- /* if imspector not running start it */
- if(!is_process_running('imspector')) {
- log_error("Impsector: Starting service on interface: {$ifaces_active}");
- imspector_action('start');
- }
- /* or restart imspector if settings were changed */
- else{
- log_error("Impsector: Restarting service on interface: {$ifaces_active}");
- imspector_action('restart');
- }
- }
- config_unlock();
-
- /*check xmlrpc sync*/
- imspector_sync_on_changes();
- }
-
- function imspector_get_ca_certs() {
- global $config;
-
- $ca_arr = array();
- $ca_arr[] = array('refid' => 'none', 'descr' => 'none');
- foreach ($config['ca'] as $ca) {
- $ca_arr[] = array('refid' => $ca['refid'], 'descr' => $ca['descr']);
- }
- return $ca_arr;
- }
-
- function imspector_get_server_certs() {
- global $config;
- $cert_arr = array();
- $cert_arr[] = array('refid' => 'none', 'descr' => 'none');
-
- foreach ($config['cert'] as $cert) {
- $cert_arr[] = array('refid' => $cert['refid'], 'descr' => $cert['descr']);
- }
- return $cert_arr;
- }
-
-/* Uses XMLRPC to synchronize the changes to a remote node */
-function imspector_sync_on_changes() {
- global $config, $g;
-
- $synconchanges = $config['installedpackages']['imspectorsync']['config'][0]['synconchanges'];
- if(!$synconchanges)
- return;
- log_error("Imspector: xmlrpc sync is starting.");
- foreach ($config['installedpackages']['imspectorsync']['config'] as $rs ){
- foreach($rs['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $password = $sh['password'];
- if($password && $sync_to_ip)
- imspector_do_xmlrpc_sync($sync_to_ip, $password);
- }
- }
- log_error("Imspector: xmlrpc sync is ending.");
-}
-/* Do the actual XMLRPC sync */
-function imspector_do_xmlrpc_sync($sync_to_ip, $password) {
- global $config, $g;
-
- if(!$password)
- return;
-
- if(!$sync_to_ip)
- return;
- $username="admin";
-
- $xmlrpc_sync_neighbor = $sync_to_ip;
- if($config['system']['webgui']['protocol'] != "") {
- $synchronizetoip = $config['system']['webgui']['protocol'];
- $synchronizetoip .= "://";
- }
- $port = $config['system']['webgui']['port'];
- /* if port is empty lets rely on the protocol selection */
- if($port == "") {
- if($config['system']['webgui']['protocol'] == "http")
- $port = "80";
- else
- $port = "443";
- }
- $synchronizetoip .= $sync_to_ip;
-
- /* xml will hold the sections to sync */
- $xml = array();
- $xml['imspector'] = $config['installedpackages']['imspector'];
- $xml['imspectorreplacements'] = $config['installedpackages']['imspectorreplacements'];
- $xml['imspectoracls'] = $config['installedpackages']['imspectoracls'];
- /* assemble xmlrpc payload */
- $params = array(
- XML_RPC_encode($password),
- XML_RPC_encode($xml)
- );
-
- /* set a few variables needed for sync code borrowed from filter.inc */
- $url = $synchronizetoip;
- log_error("Imspector: Beginning XMLRPC sync to {$url}:{$port}.");
- $method = 'pfsense.merge_installedpackages_section_xmlrpc';
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials($username, $password);
- if($g['debug'])
- $cli->setDebug(1);
- /* send our XMLRPC message and timeout after 250 seconds */
- $resp = $cli->send($msg, "250");
- if(!$resp) {
- $error = "A communications error occurred while attempting imspector XMLRPC sync with {$url}:{$port}.";
- log_error($error);
- file_notice("sync_settings", $error, "imspector Settings Sync", "");
- } elseif($resp->faultCode()) {
- $cli->setDebug(1);
- $resp = $cli->send($msg, "250");
- $error = "An error code was received while attempting imspector XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
- log_error($error);
- file_notice("sync_settings", $error, "imspector Settings Sync", "");
- } else {
- log_error("imspector XMLRPC sync successfully completed with {$url}:{$port}.");
- }
-
- /* tell imspector to reload our settings on the destionation sync host. */
- $method = 'pfsense.exec_php';
- $execcmd = "require_once('/usr/local/pkg/imspector.inc');\n";
- $execcmd .= "sync_package_imspector();";
- /* assemble xmlrpc payload */
- $params = array(
- XML_RPC_encode($password),
- XML_RPC_encode($execcmd)
- );
-
- log_error("imspector XMLRPC reload data {$url}:{$port}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials($username, $password);
- $resp = $cli->send($msg, "250");
- if(!$resp) {
- $error = "A communications error occurred while attempting imspector XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
- log_error($error);
- file_notice("sync_settings", $error, "imspector Settings Sync", "");
- } elseif($resp->faultCode()) {
- $cli->setDebug(1);
- $resp = $cli->send($msg, "250");
- $error = "An error code was received while attempting imspector XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
- log_error($error);
- file_notice("sync_settings", $error, "imspector Settings Sync", "");
- } else {
- log_error("imspector XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
- }
-
-}
-?>
diff --git a/config/imspector-dev/imspector.xml b/config/imspector-dev/imspector.xml
deleted file mode 100644
index c68fc70e..00000000
--- a/config/imspector-dev/imspector.xml
+++ /dev/null
@@ -1,251 +0,0 @@
-<?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[
-/* ========================================================================== */
-/*
- imspector.xml
- part of pfSense (http://www.pfSense.com)
- Copyright (C) 2011 Scott Ullrich <sullrich@gmail.com>
- Copyright (C) 2011 Bill Marquette <billm@gmail.com>
- Copyright (C) 2007 Ryan Wagoner <rswagoner@gmail.com>
- 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>Describe your package here</description>
- <requirements>Describe your package requirements here</requirements>
- <faq>Currently there are no FAQ items provided.</faq>
- <name>imspector</name>
- <version>20111108</version>
- <title>Services: IMSpector</title>
- <savetext>Save</savetext>
- <include_file>/usr/local/pkg/imspector.inc</include_file>
- <menu>
- <name>IMSpector</name>
- <tooltiptext>Set IMSpector settings such as protocols to listen on.</tooltiptext>
- <section>Services</section>
- <url>/services_imspector_logs.php</url>
- </menu>
- <service>
- <name>imspector</name>
- <rcfile>imspector.sh</rcfile>
- <executable>imspector</executable>
- <description><![CDATA[Instant Messenger transparent proxy]]></description>
- </service>
- <tabs>
- <tab>
- <text>Settings</text>
- <url>/pkg_edit.php?xml=imspector.xml&amp;id=0</url>
- <active/>
- </tab>
- <tab>
- <text>Replacements</text>
- <url>/pkg_edit.php?xml=imspector_replacements.xml&amp;id=0</url>
- </tab>
- <tab>
- <text>Access Lists</text>
- <url>/pkg.php?xml=imspector_acls.xml</url>
- </tab>
- <tab>
- <text>Log</text>
- <url>/imspector_logs.php</url>
- </tab>
- <tab>
- <text>Sync</text>
- <url>/pkg_edit.php?xml=imspector_sync.xml</url>
- </tab>
- </tabs>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/imspector_sync.xml</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/imspector_replacements.xml</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/imspector_acls.xml</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/pkg/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/imspector.inc</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/www/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/imspector_logs.php</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/www/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/services_imspector_logs.php</item>
- </additional_files_needed>
- <additional_files_needed>
- <prefix>/usr/local/www/</prefix>
- <chmod>0755</chmod>
- <item>http://www.pfsense.org/packages/config/imspector-dev/services_imspector_logs2.php</item>
- </additional_files_needed>
- <fields>
- <field>
- <name>General Settings</name>
- <type>listtopic</type>
- </field>
- <field>
- <fielddescr>Enable IMSpector</fielddescr>
- <fieldname>enable</fieldname>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>Interfaces</fielddescr>
- <fieldname>iface_array</fieldname>
- <description><![CDATA[<strong>Generally select internal interface(s) like LAN</strong><br>
- You can use the CTRL or COMMAND key to select multiple interfaces.]]></description>
- <type>interfaces_selection</type>
- <size>3</size>
- <required/>
- <value>lan</value>
- <multiple>true</multiple>
- </field>
- <field>
- <fielddescr>Listen on protocols</fielddescr>
- <fieldname>proto_array</fieldname>
- <description><![CDATA[<strong>NOTE: Gtalk/Jabber-SSL requires SSL certificates.</strong><br>
- You can use the CTRL or COMMAND key to select multiple protocols.]]></description>
- <type>select</type>
- <size>7</size>
- <required/>
- <multiple>true</multiple>
- <options>
- <option><name>MSN</name><value>msn</value></option>
- <option><name>ICQ/AIM</name><value>icq</value></option>
- <option><name>Yahoo</name><value>yahoo</value></option>
- <option><name>IRC</name><value>irc</value></option>
- <option><name>Jabber</name><value>jabber</value></option>
- <option><name>Gtalk/Jabber-SSL</name><value>jabber-ssl</value></option>
- <option><name>Gadu-Gadu</name><value>gadu-gadu</value></option>
- </options>
- </field>
- <field>
- <fielddescr>SSL CA Certificate</fielddescr>
- <fieldname>ssl_ca_cert</fieldname>
- <description>
- Choose the SSL CA Certficate here.
- </description>
- <type>select_source</type>
- <source><![CDATA[imspector_get_ca_certs()]]></source>
- <source_name>descr</source_name>
- <source_value>refid</source_value>
- </field>
- <field>
- <fielddescr>SSL Certificate</fielddescr>
- <fieldname>ssl_server_cert</fieldname>
- <description>
- Choose the SSL Server Certificate here.
- </description>
- <type>select_source</type>
- <source><![CDATA[imspector_get_server_certs()]]></source>
- <source_name>descr</source_name>
- <source_value>refid</source_value>
- </field>
- <field>
- <name>Logging</name>
- <type>listtopic</type>
- </field>
- <field>
- <fielddescr>Enable file logging</fielddescr>
- <fieldname>log_file</fieldname>
- <description>Log files stored in /var/imspector.</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>Report limit</fielddescr>
- <fieldname>reportlimit</fieldname>
- <description>Max entries to fetch from log dir(s). Default is 50</description>
- <type>input</type>
- <size>10</size>
- </field>
- <field>
- <fielddescr>Report template</fielddescr>
- <fieldname>template</fieldname>
- <description>Template to use on reports</description>
- <type>select</type>
- <required/>
- <options>
- <option><name>Default Template</name><value>services_imspector_logs.php</value></option>
- <option><name>0guzcan Template</name><value>services_imspector_logs2.php</value></option>
- </options>
- </field>
- <field>
- <fielddescr>Enable mySQL logging</fielddescr>
- <fieldname>log_mysql</fieldname>
- <description>Make sure to specify your MySQL credentials below.</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>mySQL server</fielddescr>
- <fieldname>mysql_server</fieldname>
- <type>input</type>
- <size>35</size>
- </field>
- <field>
- <fielddescr>mySQL database</fielddescr>
- <fieldname>mysql_database</fieldname>
- <type>input</type>
- <size>35</size>
- </field>
- <field>
- <fielddescr>mySQL username</fielddescr>
- <fieldname>mysql_username</fieldname>
- <type>input</type>
- <size>35</size>
- </field>
- <field>
- <fielddescr>mySQL password</fielddescr>
- <fieldname>mysql_password</fieldname>
- <type>password</type>
- <size>35</size>
- </field>
- </fields>
- <custom_php_validation_command>
- validate_form_imspector($_POST, &amp;$input_errors);
- </custom_php_validation_command>
- <custom_php_resync_config_command>
- sync_package_imspector();
- </custom_php_resync_config_command>
- <custom_php_deinstall_command>
- deinstall_package_imspector();
- </custom_php_deinstall_command>
- <filter_rules_needed>imspector_generate_rules</filter_rules_needed>
-</packagegui> \ No newline at end of file
diff --git a/config/imspector-dev/services_imspector_logs.php b/config/imspector-dev/services_imspector_logs.php
deleted file mode 100644
index adb3fa66..00000000
--- a/config/imspector-dev/services_imspector_logs.php
+++ /dev/null
@@ -1,311 +0,0 @@
-<?php
-/*
- services_imspector_logs.php
- part of pfSense (http://www.pfsense.com/)
-
- JavaScript Code is GPL Licensed from SmoothWall Express.
-
- Copyright (C) 2007 Ryan Wagoner <rswagoner@gmail.com>.
- Copyright (C) 2012 Marcello Coutinho
- 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("guiconfig.inc");
-
-/* variables */
-$log_dir = '/var/imspector';
-$imspector_config = $config['installedpackages']['imspector']['config'][0];
-
-$border_color = '#c0c0c0';
-$default_bgcolor = '#eeeeee';
-
-$list_protocol_color = '#000000';
-$list_local_color = '#000000';
-$list_remote_color = '#000000';
-$list_convo_color = '#000000';
-
-$list_protocol_bgcolor = '#cccccc';
-$list_local_bgcolor = '#dddddd';
-$list_remote_bgcolor = '#eeeeee';
-$list_end_bgcolor = '#bbbbbb';
-
-$convo_title_color = 'black';
-$convo_local_color = 'blue';
-$convo_remote_color = 'red';
-
-$convo_title_bgcolor = '#cccccc';
-$convo_local_bgcolor = '#dddddd';
-$convo_remote_bgcolor = '#eeeeee';
-
-/* functions */
-
-function convert_dir_list ($topdir) {
- global $config;
- if (!is_dir($topdir))
- return;
- $imspector_config = $config['installedpackages']['imspector']['config'][0];
- $limit=(preg_match("/\d+/",$imspector_config['reportlimit'])?$imspector_config['reportlimit']:"50");
- $count=0;
- if ($dh = opendir($topdir)) {
- while (($file = readdir($dh)) !== false) {
- if(!preg_match('/^\./', $file) == 0)
- continue;
- if (is_dir("$topdir/$file"))
- $list .= convert_dir_list("$topdir/$file");
- else
- $list .= "$topdir/$file\n";
- $count ++;
- if($count >= $limit){
- closedir($dh);
- return $list;
- }
- }
- closedir($dh);
- }
- return $list;
- }
-
-/* ajax response */
-if ($_POST['mode'] == "render") {
-
- /* user list */
- print(str_replace(array($log_dir,'/'),array('','|'),convert_dir_list($log_dir)));
- print("--END--\n");
-
- /* log files */
- if ($_POST['section'] != "none") {
- $section = explode('|',$_POST['section']);
- $protocol = $section[0];
- $localuser = $section[1];
- $remoteuser = $section[2];
- $conversation = $section[3];
-
- /* conversation title */
- print(implode(', ', $section)."\n");
- print("--END--\n");
-
- /* conversation content */
- $filename = $log_dir.'/'.implode('/', $section);
- if($fd = fopen($filename, 'r')) {
- print("<table width='100%' border='0' cellpadding='2' cellspacing='0'>\n");
- while (!feof($fd)) {
- $line = fgets($fd);
- if(feof($fd)) continue;
- $new_format = '([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),(.*)';
- $old_format = '([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),(.*)';
- preg_match("/${new_format}|${old_format}/", $line, $matches);
- $address = $matches[1];
- $timestamp = $matches[2];
- $direction = $matches[3];
- $type = $matches[4];
- $filtered = $matches[5];
- if(count($matches) == 8) {
- $category = $matches[6];
- $data = $matches[7];
- } else {
- $category = "";
- $data = $matches[6];
- }
-
- if($direction == '0') {
- $bgcolor = $convo_remote_bgcolor;
- $user = "&lt;<span style='color: $convo_remote_color;'>$remoteuser</span>&gt;";
- }
- if($direction == '1') {
- $bgcolor = $convo_local_bgcolor;
- $user = "&lt;<span style='color: $convo_local_color;'>$localuser</span>&gt;";
- }
-
- $time = strftime("%H:%M:%S", $timestamp);
-
- print("<tr bgcolor='$bgcolor'><td style='width: 30px; vertical-align: top;'>[$time]</td>\n
- <td style=' width: 60px; vertical-align: top;'>$user</td>\n
- <td style=' width: 60px; vertical-align: top;'>$category</td>\n
- <td style='vertical-align: top;'>$data</td></tr>\n");
- }
- print("</table>\n");
- fclose($fd);
- }
- }
- exit;
-}
-/* defaults to this page but if no settings are present, redirect to setup page */
-if(!$imspector_config["enable"] || !$imspector_config["iface_array"] || !$imspector_config["proto_array"])
- Header("Location: /pkg_edit.php?xml=imspector.xml&id=0");
-
-$pgtitle = "Services: IMSpector Log Viewer";
-include("head.inc");
-/* put your custom HTML head content here */
-/* using some of the $pfSenseHead function calls */
-//$pfSenseHead->addMeta("<meta http-equiv=\"refresh\" content=\"120;url={$_SERVER['SCRIPT_NAME']}\" />");
-//echo $pfSenseHead->getHTML();
-?>
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php include("fbegin.inc"); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<div id="mainlevel">
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
-<?php
- $tab_array = array();
- $tab_array[] = array(gettext("Settings "), false, "/pkg_edit.php?xml=imspector.xml&id=0");
- $tab_array[] = array(gettext("Replacements "), false, "/pkg_edit.php?xml=imspector_replacements.xml&id=0");
- $tab_array[] = array(gettext("Access Lists "), false, "/pkg.php?xml=imspector_acls.xml");
- $tab_array[] = array(gettext("Log "), true, "/imspector_logs.php");
- $tab_array[] = array(gettext("Sync "), false, "/pkg_edit.php?xml=imspector_sync.xml&id=0");
-
- display_top_tabs($tab_array);
-?>
-</table>
-
-<?php
-$csrf_token= csrf_get_tokens();
-$zz = <<<EOD
-<script type="text/javascript">
-var section = 'none';
-var moveit = 1;
-var the_timeout;
-
-function xmlhttpPost()
-{
- var xmlHttpReq = false;
- var self = this;
-
- if (window.XMLHttpRequest)
- self.xmlHttpReq = new XMLHttpRequest();
- else if (window.ActiveXObject)
- self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
-
- self.xmlHttpReq.open('POST', 'imspector_logs.php', true);
- self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-
- self.xmlHttpReq.onreadystatechange = function() {
- if (self.xmlHttpReq && self.xmlHttpReq.readyState == 4)
- updatepage(self.xmlHttpReq.responseText);
- }
-
- document.getElementById('im_status').style.display = "inline";
- self.xmlHttpReq.send("mode=render&section=" + section + "&__csrf_magic={$csrf_token}");
-}
-
-function updatepage(str)
-{
- /* update the list of conversations ( if we need to ) */
- var parts = str.split("--END--\\n");
- var lines = parts[0].split("\\n");
-
- for (var line = 0 ; line < lines.length ; line ++) {
- var a = lines[line].split("|");
-
- if (!a[1] || !a[2] || !a[3]) continue;
-
- /* create titling information if needed */
- if (!document.getElementById(a[1])) {
- document.getElementById('im_convos').innerHTML +=
- "<div id='" + a[1] + "_t' style='width: 100%; background-color: $list_protocol_bgcolor; color: $list_protocol_color;'>" + a[1] + "</div>" +
- "<div id='" + a[1] + "' style='width: 100%; background-color: $list_local_bgcolor;'></div>";
- }
- if (!document.getElementById(a[1] + "_" + a[2])) {
- var imageref = "";
- if (a[0]) imageref = "<img src='" + a[0] + "' alt='" + a[1] + "'/>";
- document.getElementById(a[1]).innerHTML +=
- "<div id='" + a[1] + "_" + a[2] + "_t' style='width: 100%; color: $list_local_color; padding-left: 5px;'>" + imageref + a[2] + "</div>" +
- "<div id='" + a[1] + "_" + a[2] + "' style='width: 100%; background-color: $list_remote_bgcolor; border-bottom: solid 1px $list_end_bgcolor;'></div>";
- }
- if (!document.getElementById(a[1] + "_" + a[2] + "_" + a[3])) {
- document.getElementById(a[1] + "_" + a[2]).innerHTML +=
- "<div id='" + a[1] + "_" + a[2] + "_" + a[3] + "_t' style='width: 100%; color: $list_remote_color; padding-left: 10px;'>" + a[3] + "</div>" +
- "<div id='" + a[1] + "_" + a[2] + "_" + a[3] + "' style='width: 100%;'></div>";
- }
- if (!document.getElementById(a[1] + "_" + a[2] + "_" + a[3] + "_" + a[4])) {
- document.getElementById(a[1] + "_" + a[2] + "_" + a[3]).innerHTML +=
- "<div id='" + a[1] + "_" + a[2] + "_" + a[3] + "_" + a[4] +
- "' style='width: 100%; color: $list_convo_color; cursor: pointer; padding-left: 15px;' onClick=" +
- '"' + "setsection('" + a[1] + "|" + a[2] + "|" + a[3] + "|" + a[4] + "');" + '"' + "' + >&raquo;" + a[4] + "</div>";
- }
- }
-
- /* determine the title of this conversation */
- var details = parts[1].split(",");
- var title = details[0] + " conversation between <span style='color: $convo_local_color;'>" + details[ 1 ] +
- "</span> and <span style='color: $convo_remote_color;'>" + details[2] + "</span>";
- if (!details[1]) title = "&nbsp;";
- if (!parts[2]) parts[2] = "&nbsp;";
-
- document.getElementById('im_status').style.display = "none";
- var bottom = parseInt(document.getElementById('im_content').scrollTop);
- var bottom2 = parseInt(document.getElementById('im_content').style.height);
- var absheight = parseInt( bottom + bottom2 );
- if (absheight == document.getElementById('im_content').scrollHeight) {
- moveit = 1;
- } else {
- moveit = 0;
- }
- document.getElementById('im_content').innerHTML = parts[2];
- if (moveit == 1) {
- document.getElementById('im_content').scrollTop = 0;
- document.getElementById('im_content').scrollTop = document.getElementById('im_content').scrollHeight;
- }
- document.getElementById('im_content_title').innerHTML = title;
- the_timeout = setTimeout( "xmlhttpPost();", 5000 );
-}
-
-function setsection(value)
-{
- section = value;
- clearTimeout(the_timeout);
- xmlhttpPost();
- document.getElementById('im_content').scrollTop = 0;
- document.getElementById('im_content').scrollTop = document.getElementById('im_content').scrollHeight;
-}
-</script>
-EOD;
-print($zz);
-?>
-
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td class="tabcont">
- <div style='width: 100%; text-align: right;'><span id='im_status' style='display: none;'>Updating</span>&nbsp;</div>
- <table width="100%">
- <tr>
- <td width="15%" bgcolor="<?=$default_bgcolor?>" style="overflow: auto; border: solid 1px <?=$border_color?>;">
- <div id="im_convos" style="height: 400px; overflow: auto; overflow-x: hidden;"></div>
- </td>
- <td width="75%" bgcolor="<?=$default_bgcolor?>" style="border: solid 1px <?=$border_color?>;">
- <div id="im_content_title" style="height: 20px; overflow: auto; vertical-align: top;
- color: <?=$convo_title_color?>; background-color: <?=$convo_title_bgcolor?>;"></div>
- <div id="im_content" style="height: 380px; overflow: auto; vertical-align: bottom; overflow-x: hidden;"></div>
- </td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-<script type="text/javascript">xmlhttpPost();</script>
-
-</div>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/config/imspector/imspector.inc b/config/imspector/imspector.inc
index d2757be8..52c7ae1b 100644
--- a/config/imspector/imspector.inc
+++ b/config/imspector/imspector.inc
@@ -2,6 +2,7 @@
/*
imspector.inc
part of pfSense (http://www.pfsense.com/)
+ Copyright (C) 2012 Marcello Coutinho.
Copyright (C) 2011 Scott Ullrich <sullrich@gmail.com>.
Copyright (C) 2011 Bill Marquette <billm@gmail.com>.
Copyright (C) 2007 Ryan Wagoner <rswagoner@gmail.com>.
@@ -31,6 +32,7 @@
require_once("config.inc");
require_once("functions.inc");
+ require_once("service-utils.inc");
/* IMSpector */
@@ -38,20 +40,17 @@
define('IMSPECTOR_ETC', '/usr/local/etc/imspector');
define('IMSPECTOR_CONFIG', IMSPECTOR_ETC . '/imspector.conf');
- function imspector_notice ($msg) { syslog(LOG_NOTICE, "imspector: {$msg}"); }
function imspector_warn ($msg) { syslog(LOG_WARNING, "imspector: {$msg}"); }
+ function ims_text_area_decode($text){
+ return preg_replace('/\r\n/', "\n",base64_decode($text));
+ }
+
function imspector_action ($action) {
if (file_exists(IMSPECTOR_RCFILE))
mwexec(IMSPECTOR_RCFILE.' '.$action);
}
- function imspector_running () {
- if((int)exec('pgrep imspector | wc -l') > 0)
- return true;
- return false;
- }
-
function write_imspector_config($file, $text) {
$conf = fopen($file, 'w');
if(!$conf) {
@@ -95,18 +94,19 @@
function validate_form_imspector($post, $input_errors) {
if($post['iface_array'])
foreach($post['iface_array'] as $iface)
- if($iface == 'wan')
+ if($iface == 'wanx')
$input_errors[] = 'It is a security risk to specify WAN in the \'Interface\' field';
}
function deinstall_package_imspector() {
imspector_action('stop');
- @unlink(IMSPECTOR_RCFILE);
- @unlink(IMSPECTOR_CONFIG);
- @unlink(IMSPECTOR_ETC . '/badwords_custom.txt');
- @unlink(IMSPECTOR_ETC . '/acl_blacklist.txt');
- @unlink(IMSPECTOR_ETC . '/acl_whitelist.txt');
+ unlink_if_exists(IMSPECTOR_RCFILE);
+ unlink_if_exists(IMSPECTOR_CONFIG);
+ unlink_if_exists(IMSPECTOR_ETC . '/badwords_custom.txt');
+ unlink_if_exists(IMSPECTOR_ETC . '/acl_blacklist.txt');
+ unlink_if_exists(IMSPECTOR_ETC . '/acl_whitelist.txt');
+ unlink_if_exists('/usr/local/www/imspector_logs.php');
//exec('pkg_delete imspector-0.4');
}
@@ -122,7 +122,7 @@
break;
case 'rule':
$rules = "# IMSpector \n";
- $rules .= "anchor \"miniupnpd\"\n";
+ $rules .= "anchor \"imspector\"\n";
break;
}
@@ -133,21 +133,60 @@
global $config;
global $input_errors;
+ /*detect boot process*/
+ if (is_array($_POST)){
+ if (preg_match("/\w+/",$_POST['__csrf_magic']))
+ unset($boot_process);
+ else
+ $boot_process="on";
+ }
+
+ if (is_process_running('imspector') && isset($boot_process))
+ return;
+
+ /* check default options and sample files*/
+ $load_samples=0;
+
+ #bannedphraselist
+ if (!is_array($config['installedpackages']['imspectoracls'])){
+ $config['installedpackages']['imspectoracls']['config'][]=array('enable'=> 'on',
+ 'description' => 'allow access to all ids',
+ 'action' => 'allow',
+ 'localid' => 'all',
+ 'remoteid' => base64_encode('all'));
+ $load_samples++;
+ }
+ $ims_acls = $config['installedpackages']['imspectoracls']['config'];
+
+ if (is_array($config['installedpackages']['imspectorreplacements'])){
+ if ($config['installedpackages']['imspectorreplacements']['config'][0]['badwords_list'] == "" && file_exists(IMSPECTOR_ETC . '/badwords.txt')){
+ $config['installedpackages']['imspectorreplacements']['config'][0]['badwords_list'] = base64_encode(file_get_contents(IMSPECTOR_ETC . '/badwords.txt'));
+ $load_samples++;
+ }
+ $ims_replacements = $config['installedpackages']['imspectorreplacements']['config'][0];
+ }
+
+ if (is_array($config['installedpackages']['imspector']))
+ $ims_config = $config['installedpackages']['imspector']['config'][0];
+
+ if($load_samples > 0)
+ write_config();
+
+ /*continue sync process*/
+ log_error("Imspector: Saving changes.");
config_lock();
-
- $imspector_config = $config['installedpackages']['imspector']['config'][0];
-
+
/* remove existing rules */
- exec('/sbin/pfctl -a imspector -Fr');
- exec('/sbin/pfctl -a imspector -Fn');
+ exec('/sbin/pfctl -a imspector -Fr > /dev/null');
+ exec('/sbin/pfctl -a imspector -Fn > /dev/null');
$ifaces_active = '';
- if($imspector_config['enable'] && $imspector_config['proto_array'])
- $proto_array = explode(',', $imspector_config['proto_array']);
+ if($ims_config['enable'] && $ims_config['proto_array'])
+ $proto_array = explode(',', $ims_config['proto_array']);
- if($imspector_config['enable'] && $imspector_config['iface_array'])
- $iface_array = explode(',', $imspector_config['iface_array']);
+ if($ims_config['enable'] && $ims_config['iface_array'])
+ $iface_array = explode(',', $ims_config['iface_array']);
if($iface_array && $proto_array) {
foreach($iface_array as $iface) {
@@ -175,8 +214,11 @@
imspector_warn("Could not resolve real interface for {$iface}");
}
}
-
+
+
+ /*reload rules*/
if($pf_rules) {
+ log_error("Imspector: Reloading rules.");
exec("echo \"{$pf_rules}\" | /sbin/pfctl -a imspector -f -");
conf_mount_rw();
@@ -188,69 +230,59 @@
foreach($proto_array as $proto)
$conf[$proto . '_protocol'] = 'on';
- if($imspector_config['log_file']) {
+ if($ims_config['log_file']) {
@mkdir('/var/imspector');
$conf['file_logging_dir'] = '/var/imspector';
}
- if($imspector_config['log_mysql']) {
- $conf['mysql_server'] = $imspector_config['mysql_server'];
- $conf['mysql_database'] = $imspector_config['mysql_database'];
- $conf['mysql_username'] = $imspector_config['mysql_username'];
- $conf['mysql_password'] = $imspector_config['mysql_password'];
+ if($ims_config['log_mysql']) {
+ $conf['mysql_server'] = $ims_config['mysql_server'];
+ $conf['mysql_database'] = $ims_config['mysql_database'];
+ $conf['mysql_username'] = $ims_config['mysql_username'];
+ $conf['mysql_password'] = $ims_config['mysql_password'];
}
- if($imspector_config['filter_badwords']) {
- if(!empty($imspector_config["badwords_list"])) {
- $conf['badwords_filename'] = IMSPECTOR_ETC . '/badwords_custom.txt';
- write_imspector_config(IMSPECTOR_ETC . '/badwords_custom.txt',
- str_replace("\r", '', base64_decode($imspector_config["badwords_list"])));
- } else
- $conf['badwords_filename'] = IMSPECTOR_ETC . '/badwords.txt';
- }
+ if($ims_replacements['filter_badwords']) {
+ write_imspector_config(IMSPECTOR_ETC . '/badwords_custom.txt', ims_text_area_decode($ims_replacements["badwords_list"]));
+ $conf['badwords_filename'] = IMSPECTOR_ETC . '/badwords_custom.txt';
+ }
- if($imspector_config['block_files'])
+ if($ims_replacements['block_files'])
$conf['block_files'] = 'on';
-
- if($imspector_config['block_unlisted'])
- $conf['block_unlisted'] = 'on';
-
- if(!empty($imspector_config['acl_whitelist'])) {
- $conf['whitelist_filename'] = IMSPECTOR_ETC . '/acl_whitelist.txt';
- write_imspector_config(IMSPECTOR_ETC . '/acl_whitelist.txt',
- str_replace("\r", '', base64_decode($imspector_config["acl_whitelist"])));
- }
-
- if(!empty($imspector_config['acl_blacklist'])) {
- $conf['blacklist_filename'] = IMSPECTOR_ETC . '/acl_blacklist.txt';
- write_imspector_config(IMSPECTOR_ETC . '/acl_blacklist.txt',
- str_replace("\r", '', base64_decode($imspector_config["acl_blacklist"])));
- }
+
+ if($ims_replacements['block_webcams'])
+ $conf['block_webcams'] = 'on';
+
+ $acls="";
+ $conf['acl_filename'] = IMSPECTOR_ETC . '/acls.txt';
+ foreach ($ims_acls as $rule){
+ if ($rule['enable']){
+ $acls.= "{$rule['action']} {$rule['localid']} ".preg_replace("/\s+/"," ",base64_decode($rule['remoteid']))."\n";
+ }
+ }
+ write_imspector_config(IMSPECTOR_ETC . '/acls.txt', $acls);
// Handle Jabber SSL options
- if(isset($imspector_config["ssl_ca_cert"]) && $imspector_config["ssl_ca_cert"] != "none" &&
- isset($imspector_config["ssl_server_cert"]) && $imspector_config["ssl_server_cert"] != "none") {
+ if(isset($ims_config["ssl_ca_cert"]) && $ims_config["ssl_ca_cert"] != "none" &&
+ isset($ims_config["ssl_server_cert"]) && $ims_config["ssl_server_cert"] != "none") {
$conf['ssl'] = "on";
if(!is_dir(IMSPECTOR_ETC . "/ssl"))
mkdir(IMSPECTOR_ETC . "/ssl");
- $ca_cert = lookup_ca($imspector_config["ssl_ca_cert"]);
+ $ca_cert = lookup_ca($ims_config["ssl_ca_cert"]);
if ($ca_cert != false) {
if(base64_decode($ca_cert['prv'])) {
- file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_ca_key.pem",
- base64_decode($ca_cert['prv']));
+ file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_ca_key.pem", base64_decode($ca_cert['prv']));
$conf['ssl_ca_key'] = IMSPECTOR_ETC . '/ssl/ssl_ca_key.pem';
}
if(base64_decode($ca_cert['crt'])) {
- file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_ca_cert.pem",
- base64_decode($ca_cert['crt']));
+ file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_ca_cert.pem", base64_decode($ca_cert['crt']));
$conf['ssl_ca_cert'] = IMSPECTOR_ETC . "/ssl/ssl_ca_cert.pem";
}
- $svr_cert = lookup_cert($imspector_config["ssl_server_cert"]);
+ $svr_cert = lookup_cert($ims_config["ssl_server_cert"]);
if ($svr_cert != false) {
if(base64_decode($svr_cert['prv'])) {
- file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_server_key.pem",
- base64_decode($svr_cert['prv']));
+ file_put_contents(IMSPECTOR_ETC . "/ssl/ssl_server_key.pem", base64_decode($svr_cert['prv']));
$conf['ssl_key'] = IMSPECTOR_ETC . '/ssl/ssl_server_key.pem';
}
@@ -263,42 +295,68 @@
unset($conf['ssl']);
}
- if (isset($imspector_config['resonder']) && $imspector_config['resonder'] == 'on') {
+ if (isset($ims_replacements['responder']) && $ims_replacements['responder'] == 'on') {
$conf['responder_filename'] = IMSPECTOR_ETC . "/responder.db";
- if (isset($imspector_config['prefix_message']) && $imspector_config['prefix_message'] != '' ) {
- $conf['response_prefix'] = base64_decode($imspector_config['prefix_message']) . " -=";
+ if (isset($ims_replacements['prefix_message']) && $ims_replacements['prefix_message'] != '' ) {
+ $conf['response_prefix'] = " .={$ims_replacements['prefix_message']}=.";
}
- if (isset($imspector_config['notice_days']) && is_numeric($imspector_config['notice_days'])) {
- if ($imspector_config['notice_days'] != 0) {
- $conf['notice_days'] = $imspector_config['notice_days'];
+ else{
+ $conf['response_prefix'] = " .=Your activities are being logged=.";
+ }
+ if (isset($ims_replacements['notice_days']) && is_numeric($ims_replacements['notice_days'])) {
+ if ($ims_replacements['notice_days'] != 0) {
+ $conf['notice_days'] = $ims_replacements['notice_days'];
}
} else {
$conf['notice_days'] = 1;
}
- $conf['notice_response'] = "Your activities are being logged";
- if (isset($imspector_config['filtered_minutes']) && is_numeric($imspector_config['filtered_minutes'])) {
- if ($imspector_config['filtered_minutes'] != 0) {
- $conf['filtered_mins'] = $imspector_config['filtered_minutes'];
+
+ /*Custom recorded message response*/
+ if(isset($ims_replacements['recorded_message']) && $ims_replacements['recorded_message'] != '' ){
+ $conf['notice_response'] = ims_text_area_decode($ims_replacements['recorded_message']);
+ }
+ else{
+ $conf['notice_response'] = "Your activities are being logged";
+ }
+
+ /*Filtered Frequency*/
+ if (isset($ims_replacements['filtered_minutes']) && is_numeric($ims_replacements['filtered_minutes'])) {
+ if ($ims_replacements['filtered_minutes'] != 0) {
+ $conf['filtered_mins'] = $ims_replacements['filtered_minutes'];
}
} else {
$conf['filtered_mins'] = 15;
}
- $conf['filtered_response'] = "Your message has been filtered";
+
+ /*Custom filtered message response*/
+ if(isset($ims_replacements['filtered_message']) && $ims_replacements['filtered_message'] != '' ){
+ $conf['filtered_response'] = ims_text_area_decode($ims_replacements['filtered_message']);
+ }
+ else{
+ $conf['filtered_response'] = "Your message has been filtered";
+ }
}
$conftext = '';
foreach($conf as $var => $key)
$conftext .= "{$var}={$key}\n";
write_imspector_config(IMSPECTOR_CONFIG, $conftext);
+
+ /*Check template settings*/
+ if ($ims_config['template'] == "")
+ $template="services_imspector_logs.php";
+ else
+ $template=$ims_config['template'];
+ /*link template file*/
+ $link="/usr/local/www/imspector_logs.php";
+ unlink_if_exists($link);
+ symlink("/usr/local/www/{$template}", $link);
+
/* generate rc file start and stop */
$stop = <<<EOD
-if [ `pgrep imspector | wc -l` != 0 ]; then
- /usr/bin/killall imspector
- while [ `pgrep imspector | wc -l` != 0 ]; do
- sleep 1
- done
- fi
+/bin/pkill -x imspector
+/bin/sleep 1
EOD;
$start = $stop."\n\tldconfig -m /usr/local/lib/mysql\n";
$start .= "\t/usr/local/sbin/imspector -c \"".IMSPECTOR_CONFIG."\"";
@@ -310,18 +368,7 @@ EOD;
)
);
- conf_mount_ro();
-
- /* if imspector not running start it */
- if(!imspector_running()) {
- imspector_notice("Starting service on interface: {$ifaces_active}");
- imspector_action('start');
- }
- /* or restart imspector if settings were changed */
- elseif($_POST['iface_array']) {
- imspector_notice("Restarting service on interface: {$ifaces_active}");
- imspector_action('restart');
- }
+ conf_mount_ro();
}
}
@@ -330,10 +377,10 @@ EOD;
/* lets stop the service and remove the rc file */
if(file_exists(IMSPECTOR_RCFILE)) {
- if(!$imspector_config['enable'])
- imspector_notice('Stopping service: imspector disabled');
+ if(!$ims_config['enable'])
+ log_error('Impsector: Stopping service: imspector disabled');
else
- imspector_notice('Stopping service: no interfaces and/or protocols selected');
+ log_error('Impsector: Stopping service: no interfaces and/or protocols selected');
imspector_action('stop');
@@ -345,9 +392,23 @@ EOD;
@unlink(IMSPECTOR_ETC . '/acl_whitelist.txt');
conf_mount_ro();
}
+ }
+ else{
+ /* if imspector not running start it */
+ if(!is_process_running('imspector')) {
+ log_error("Impsector: Starting service on interface: {$ifaces_active}");
+ imspector_action('start');
+ }
+ /* or restart imspector if settings were changed */
+ else{
+ log_error("Impsector: Restarting service on interface: {$ifaces_active}");
+ imspector_action('restart');
+ }
}
-
- config_unlock();
+ config_unlock();
+
+ /*check xmlrpc sync*/
+ imspector_sync_on_changes();
}
function imspector_get_ca_certs() {
@@ -371,4 +432,115 @@ EOD;
}
return $cert_arr;
}
-?> \ No newline at end of file
+
+/* Uses XMLRPC to synchronize the changes to a remote node */
+function imspector_sync_on_changes() {
+ global $config, $g;
+
+ $synconchanges = $config['installedpackages']['imspectorsync']['config'][0]['synconchanges'];
+ if(!$synconchanges)
+ return;
+ log_error("Imspector: xmlrpc sync is starting.");
+ foreach ($config['installedpackages']['imspectorsync']['config'] as $rs ){
+ foreach($rs['row'] as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $password = $sh['password'];
+ if($password && $sync_to_ip)
+ imspector_do_xmlrpc_sync($sync_to_ip, $password);
+ }
+ }
+ log_error("Imspector: xmlrpc sync is ending.");
+}
+/* Do the actual XMLRPC sync */
+function imspector_do_xmlrpc_sync($sync_to_ip, $password) {
+ global $config, $g;
+
+ if(!$password)
+ return;
+
+ if(!$sync_to_ip)
+ return;
+ $username="admin";
+
+ $xmlrpc_sync_neighbor = $sync_to_ip;
+ if($config['system']['webgui']['protocol'] != "") {
+ $synchronizetoip = $config['system']['webgui']['protocol'];
+ $synchronizetoip .= "://";
+ }
+ $port = $config['system']['webgui']['port'];
+ /* if port is empty lets rely on the protocol selection */
+ if($port == "") {
+ if($config['system']['webgui']['protocol'] == "http")
+ $port = "80";
+ else
+ $port = "443";
+ }
+ $synchronizetoip .= $sync_to_ip;
+
+ /* xml will hold the sections to sync */
+ $xml = array();
+ $xml['imspector'] = $config['installedpackages']['imspector'];
+ $xml['imspectorreplacements'] = $config['installedpackages']['imspectorreplacements'];
+ $xml['imspectoracls'] = $config['installedpackages']['imspectoracls'];
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($xml)
+ );
+
+ /* set a few variables needed for sync code borrowed from filter.inc */
+ $url = $synchronizetoip;
+ log_error("Imspector: Beginning XMLRPC sync to {$url}:{$port}.");
+ $method = 'pfsense.merge_installedpackages_section_xmlrpc';
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials($username, $password);
+ if($g['debug'])
+ $cli->setDebug(1);
+ /* send our XMLRPC message and timeout after 250 seconds */
+ $resp = $cli->send($msg, "250");
+ if(!$resp) {
+ $error = "A communications error occurred while attempting imspector XMLRPC sync with {$url}:{$port}.";
+ log_error($error);
+ file_notice("sync_settings", $error, "imspector Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting imspector XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "imspector Settings Sync", "");
+ } else {
+ log_error("imspector XMLRPC sync successfully completed with {$url}:{$port}.");
+ }
+
+ /* tell imspector to reload our settings on the destionation sync host. */
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('/usr/local/pkg/imspector.inc');\n";
+ $execcmd .= "sync_package_imspector();";
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($execcmd)
+ );
+
+ log_error("imspector XMLRPC reload data {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials($username, $password);
+ $resp = $cli->send($msg, "250");
+ if(!$resp) {
+ $error = "A communications error occurred while attempting imspector XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
+ log_error($error);
+ file_notice("sync_settings", $error, "imspector Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting imspector XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "imspector Settings Sync", "");
+ } else {
+ log_error("imspector XMLRPC reload data success with {$url}:{$port} (pfsense.exec_php).");
+ }
+
+}
+?>
diff --git a/config/imspector/imspector.xml b/config/imspector/imspector.xml
index d42e7a18..72969778 100644
--- a/config/imspector/imspector.xml
+++ b/config/imspector/imspector.xml
@@ -43,10 +43,9 @@
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>imspector</name>
- <version>0.9</version>
+ <version>20111108</version>
<title>Services: IMSpector</title>
- <savetext>Change</savetext>
- <aftersaveredirect>/services_imspector_logs.php</aftersaveredirect>
+ <savetext>Save</savetext>
<include_file>/usr/local/pkg/imspector.inc</include_file>
<menu>
<name>IMSpector</name>
@@ -58,38 +57,81 @@
<name>imspector</name>
<rcfile>imspector.sh</rcfile>
<executable>imspector</executable>
+ <description><![CDATA[Instant Messenger transparent proxy]]></description>
</service>
<tabs>
<tab>
- <text>IMSpector Log Viewer</text>
- <url>/services_imspector_logs.php</url>
- </tab>
- <tab>
- <text>IMSpector Settings</text>
+ <text>Settings</text>
<url>/pkg_edit.php?xml=imspector.xml&amp;id=0</url>
<active/>
</tab>
+ <tab>
+ <text>Replacements</text>
+ <url>/pkg_edit.php?xml=imspector_replacements.xml&amp;id=0</url>
+ </tab>
+ <tab>
+ <text>Access Lists</text>
+ <url>/pkg.php?xml=imspector_acls.xml</url>
+ </tab>
+ <tab>
+ <text>Log</text>
+ <url>/imspector_logs.php</url>
+ </tab>
+ <tab>
+ <text>Sync</text>
+ <url>/pkg_edit.php?xml=imspector_sync.xml</url>
+ </tab>
</tabs>
<additional_files_needed>
<prefix>/usr/local/pkg/</prefix>
<chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/imspector/imspector_sync.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/imspector/imspector_replacements.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/imspector/imspector_acls.xml</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/imspector/imspector.inc</item>
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/imspector/imspector_logs.php</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
<item>http://www.pfsense.org/packages/config/imspector/services_imspector_logs.php</item>
</additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/www/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.org/packages/config/imspector/services_imspector_logs2.php</item>
+ </additional_files_needed>
<fields>
<field>
+ <name>General Settings</name>
+ <type>listtopic</type>
+ </field>
+ <field>
<fielddescr>Enable IMSpector</fielddescr>
<fieldname>enable</fieldname>
<type>checkbox</type>
</field>
<field>
- <fielddescr>Interfaces (generally LAN)</fielddescr>
+ <fielddescr>Interfaces</fielddescr>
<fieldname>iface_array</fieldname>
- <description>You can use the CTRL or COMMAND key to select multiple interfaces.</description>
+ <description><![CDATA[<strong>Generally select internal interface(s) like LAN</strong><br>
+ You can use the CTRL or COMMAND key to select multiple interfaces.]]></description>
<type>interfaces_selection</type>
<size>3</size>
<required/>
@@ -99,203 +141,101 @@
<field>
<fielddescr>Listen on protocols</fielddescr>
<fieldname>proto_array</fieldname>
- <description>You can use the CTRL or COMMAND key to select multiple protocols. NOTE: Gtalk/Jabber-SSL requires SSL certificates.</description>
+ <description><![CDATA[<strong>NOTE: Gtalk/Jabber-SSL requires SSL certificates.</strong><br>
+ You can use the CTRL or COMMAND key to select multiple protocols.]]></description>
<type>select</type>
<size>7</size>
<required/>
<multiple>true</multiple>
<options>
- <option>
- <name>MSN</name>
- <value>msn</value>
- </option>
- <option>
- <name>ICQ/AIM</name>
- <value>icq</value>
- </option>
- <option>
- <name>Yahoo</name>
- <value>yahoo</value>
- </option>
- <option>
- <name>IRC</name>
- <value>irc</value>
- </option>
- <option>
- <name>Jabber</name>
- <value>jabber</value>
- </option>
- <option>
- <name>Gtalk/Jabber-SSL</name>
- <value>jabber-ssl</value>
- </option>
- <option>
- <name>Gadu-Gadu</name>
- <value>gadu-gadu</value>
- </option>
+ <option><name>MSN</name><value>msn</value></option>
+ <option><name>ICQ/AIM</name><value>icq</value></option>
+ <option><name>Yahoo</name><value>yahoo</value></option>
+ <option><name>IRC</name><value>irc</value></option>
+ <option><name>Jabber</name><value>jabber</value></option>
+ <option><name>Gtalk/Jabber-SSL</name><value>jabber-ssl</value></option>
+ <option><name>Gadu-Gadu</name><value>gadu-gadu</value></option>
</options>
</field>
<field>
- <fielddescr>Enable file logging</fielddescr>
- <fieldname>log_file</fieldname>
- <description>Log files stored in /var/imspector.</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>Enable mySQL logging</fielddescr>
- <fieldname>log_mysql</fieldname>
- <description>Make sure to specify your MySQL credentials below.</description>
- <type>checkbox</type>
- </field>
- <field>
- <fielddescr>mySQL server</fielddescr>
- <fieldname>mysql_server</fieldname>
- <type>input</type>
- </field>
- <field>
- <fielddescr>mySQL database</fielddescr>
- <fieldname>mysql_database</fieldname>
- <type>input</type>
- </field>
- <field>
- <fielddescr>mySQL username</fielddescr>
- <fieldname>mysql_username</fieldname>
- <type>input</type>
- </field>
- <field>
- <fielddescr>mySQL password</fielddescr>
- <fieldname>mysql_password</fieldname>
- <type>password</type>
- </field>
- <field>
- <fielddescr>SSL Certificate</fielddescr>
- <fieldname>ssl_server_cert</fieldname>
+ <fielddescr>SSL CA Certificate</fielddescr>
+ <fieldname>ssl_ca_cert</fieldname>
<description>
- Choose the SSL Server Certificate here.
+ Choose the SSL CA Certficate here.
</description>
<type>select_source</type>
- <source><![CDATA[imspector_get_server_certs()]]></source>
+ <source><![CDATA[imspector_get_ca_certs()]]></source>
<source_name>descr</source_name>
<source_value>refid</source_value>
</field>
<field>
- <fielddescr>SSL CA Certificate</fielddescr>
- <fieldname>ssl_ca_cert</fieldname>
+ <fielddescr>SSL Certificate</fielddescr>
+ <fieldname>ssl_server_cert</fieldname>
<description>
- Choose the SSL CA Certficate here.
+ Choose the SSL Server Certificate here.
</description>
<type>select_source</type>
- <source><![CDATA[imspector_get_ca_certs()]]></source>
+ <source><![CDATA[imspector_get_server_certs()]]></source>
<source_name>descr</source_name>
<source_value>refid</source_value>
</field>
<field>
- <fielddescr>Enable bad word filtering</fielddescr>
- <fieldname>filter_badwords</fieldname>
- <description>Replace characters of matched bad word with *.</description>
- <type>checkbox</type>
+ <name>Logging</name>
+ <type>listtopic</type>
</field>
<field>
- <fielddescr>Enable response messages</fielddescr>
- <fieldname>resonder</fieldname>
- <description>
- Inform the users (both local and remote) that the conversation they are having is being recorded. This might be needed for legal reasons.
- Inform the sender that a file (or message) was blocked. This is useful because the sender will know a block occured, instead of the transfer simply failing.</description>
+ <fielddescr>Enable file logging</fielddescr>
+ <fieldname>log_file</fieldname>
+ <description>Log files stored in /var/imspector.</description>
<type>checkbox</type>
</field>
<field>
- <fielddescr>Notification frequency</fielddescr>
- <fieldname>notice_days</fieldname>
- <type>input</type>
- <description>Frequency in number of days for notifying users they are being logged. Default 1 day if responses are enabled, set to 0 to disable</description>
- </field>
- <field>
- <fielddescr>Filtered frequency</fielddescr>
- <fieldname>filtered_minutes</fieldname>
+ <fielddescr>Report limit</fielddescr>
+ <fieldname>reportlimit</fieldname>
+ <description>Max entries to fetch from log dir(s). Default is 50</description>
<type>input</type>
- <description>The time between sending "filtered" in minutes. Default 15 minutes if responses are enabled, set to 0 to disable</description>
- </field>
- <field>
- <fielddescr>Custom message prefix</fielddescr>
- <fieldname>prefix_message</fieldname>
- <description>
- Message to prepend to all IMSpector generated messages. The default is "Message from IMSpector"
- </description>
- <type>textarea</type>
- <encoding>base64</encoding>
- <rows>5</rows>
- <cols>40</cols>
- </field>
- <field>
- <fielddescr>Custom recorded message response</fielddescr>
- <fieldname>recorded_message</fieldname>
- <description>
- Message to send to users to let them know they are being recorded. The default is "Your activities are being logged"
- </description>
- <type>textarea</type>
- <encoding>base64</encoding>
- <rows>5</rows>
- <cols>40</cols>
+ <size>10</size>
</field>
<field>
- <fielddescr>Custom filtered message response</fielddescr>
- <fieldname>filtered_message</fieldname>
- <description>
- Message to send to users to let them know about filtered messages.
- </description>
- <type>textarea</type>
- <encoding>base64</encoding>
- <rows>5</rows>
- <cols>40</cols>
+ <fielddescr>Report template</fielddescr>
+ <fieldname>template</fieldname>
+ <description>Template to use on reports</description>
+ <type>select</type>
+ <required/>
+ <options>
+ <option><name>Default Template</name><value>services_imspector_logs.php</value></option>
+ <option><name>0guzcan Template</name><value>services_imspector_logs2.php</value></option>
+ </options>
</field>
-
<field>
- <fielddescr>Bad words list</fielddescr>
- <fieldname>badwords_list</fieldname>
- <description>
- Place one word or phrase to match per line.&lt;br /&gt;
- If left blank the default list in /usr/local/etc/imspector/badwords.txt will be used.
- </description>
- <type>textarea</type>
- <encoding>base64</encoding>
- <rows>5</rows>
- <cols>40</cols>
+ <fielddescr>Enable mySQL logging</fielddescr>
+ <fieldname>log_mysql</fieldname>
+ <description>Make sure to specify your MySQL credentials below.</description>
+ <type>checkbox</type>
</field>
<field>
- <fielddescr>Block file transfers</fielddescr>
- <fieldname>block_files</fieldname>
- <description>Block file transfers on supported protocols.</description>
- <type>checkbox</type>
+ <fielddescr>mySQL server</fielddescr>
+ <fieldname>mysql_server</fieldname>
+ <type>input</type>
+ <size>35</size>
</field>
<field>
- <fielddescr>Block non ACL defined</fielddescr>
- <fieldname>block_unlisted</fieldname>
- <description>Overide the default of allowing user's not defined the whitelist or blacklist ACLs.</description>
- <type>checkbox</type>
+ <fielddescr>mySQL database</fielddescr>
+ <fieldname>mysql_database</fieldname>
+ <type>input</type>
+ <size>35</size>
</field>
<field>
- <fielddescr>ACL whitelist</fielddescr>
- <fieldname>acl_whitelist</fieldname>
- <description>
- Example (allow specific access): localuser: remoteuser1 remoteuser2&lt;br /&gt;
- Example (allow full access): localuser:
- </description>
- <type>textarea</type>
- <encoding>base64</encoding>
- <rows>5</rows>
- <cols>40</cols>
+ <fielddescr>mySQL username</fielddescr>
+ <fieldname>mysql_username</fieldname>
+ <type>input</type>
+ <size>35</size>
</field>
<field>
- <fielddescr>ACL blacklist</fielddescr>
- <fieldname>acl_blacklist</fieldname>
- <description>
- Example (block specifc access): localuser: remoteuser1 remoteuser2&lt;br /&gt;
- Example (block all access): localuser:
- </description>
- <type>textarea</type>
- <encoding>base64</encoding>
- <rows>5</rows>
- <cols>40</cols>
+ <fielddescr>mySQL password</fielddescr>
+ <fieldname>mysql_password</fieldname>
+ <type>password</type>
+ <size>35</size>
</field>
</fields>
<custom_php_validation_command>
@@ -308,4 +248,4 @@
deinstall_package_imspector();
</custom_php_deinstall_command>
<filter_rules_needed>imspector_generate_rules</filter_rules_needed>
-</packagegui> \ No newline at end of file
+</packagegui>
diff --git a/config/imspector-dev/imspector_acls.xml b/config/imspector/imspector_acls.xml
index 3176c75f..3176c75f 100644
--- a/config/imspector-dev/imspector_acls.xml
+++ b/config/imspector/imspector_acls.xml
diff --git a/config/imspector-dev/imspector_logs.php b/config/imspector/imspector_logs.php
index e44ef35f..e44ef35f 100644
--- a/config/imspector-dev/imspector_logs.php
+++ b/config/imspector/imspector_logs.php
diff --git a/config/imspector-dev/imspector_replacements.xml b/config/imspector/imspector_replacements.xml
index 7f53bbd4..7f53bbd4 100644
--- a/config/imspector-dev/imspector_replacements.xml
+++ b/config/imspector/imspector_replacements.xml
diff --git a/config/imspector-dev/imspector_sync.xml b/config/imspector/imspector_sync.xml
index 3ff88d41..3ff88d41 100644
--- a/config/imspector-dev/imspector_sync.xml
+++ b/config/imspector/imspector_sync.xml
diff --git a/config/imspector/services_imspector_logs.php b/config/imspector/services_imspector_logs.php
index fce9b892..adb3fa66 100644
--- a/config/imspector/services_imspector_logs.php
+++ b/config/imspector/services_imspector_logs.php
@@ -6,6 +6,7 @@
JavaScript Code is GPL Licensed from SmoothWall Express.
Copyright (C) 2007 Ryan Wagoner <rswagoner@gmail.com>.
+ Copyright (C) 2012 Marcello Coutinho
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -60,20 +61,30 @@ $convo_remote_bgcolor = '#eeeeee';
/* functions */
function convert_dir_list ($topdir) {
- if (!is_dir($topdir)) return;
+ global $config;
+ if (!is_dir($topdir))
+ return;
+ $imspector_config = $config['installedpackages']['imspector']['config'][0];
+ $limit=(preg_match("/\d+/",$imspector_config['reportlimit'])?$imspector_config['reportlimit']:"50");
+ $count=0;
if ($dh = opendir($topdir)) {
while (($file = readdir($dh)) !== false) {
- if(!preg_match('/^\./', $file) == 0) continue;
- if (is_dir("$topdir/$file")) {
+ if(!preg_match('/^\./', $file) == 0)
+ continue;
+ if (is_dir("$topdir/$file"))
$list .= convert_dir_list("$topdir/$file");
- } else {
+ else
$list .= "$topdir/$file\n";
+ $count ++;
+ if($count >= $limit){
+ closedir($dh);
+ return $list;
+ }
}
- }
closedir($dh);
- }
+ }
return $list;
-}
+ }
/* ajax response */
if ($_POST['mode'] == "render") {
@@ -157,13 +168,18 @@ include("head.inc");
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php
$tab_array = array();
- $tab_array[] = array(gettext("IMSpector Log Viewer "), true, "/services_imspector_logs.php");
- $tab_array[] = array(gettext("IMSpector Settings "), false, "/pkg_edit.php?xml=imspector.xml&id=0");
+ $tab_array[] = array(gettext("Settings "), false, "/pkg_edit.php?xml=imspector.xml&id=0");
+ $tab_array[] = array(gettext("Replacements "), false, "/pkg_edit.php?xml=imspector_replacements.xml&id=0");
+ $tab_array[] = array(gettext("Access Lists "), false, "/pkg.php?xml=imspector_acls.xml");
+ $tab_array[] = array(gettext("Log "), true, "/imspector_logs.php");
+ $tab_array[] = array(gettext("Sync "), false, "/pkg_edit.php?xml=imspector_sync.xml&id=0");
+
display_top_tabs($tab_array);
?>
</table>
<?php
+$csrf_token= csrf_get_tokens();
$zz = <<<EOD
<script type="text/javascript">
var section = 'none';
@@ -180,7 +196,7 @@ function xmlhttpPost()
else if (window.ActiveXObject)
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
- self.xmlHttpReq.open('POST', 'services_imspector_logs.php', true);
+ self.xmlHttpReq.open('POST', 'imspector_logs.php', true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
@@ -189,7 +205,7 @@ function xmlhttpPost()
}
document.getElementById('im_status').style.display = "inline";
- self.xmlHttpReq.send("mode=render&section=" + section);
+ self.xmlHttpReq.send("mode=render&section=" + section + "&__csrf_magic={$csrf_token}");
}
function updatepage(str)
diff --git a/config/imspector-dev/services_imspector_logs2.php b/config/imspector/services_imspector_logs2.php
index 30f63058..30f63058 100644
--- a/config/imspector-dev/services_imspector_logs2.php
+++ b/config/imspector/services_imspector_logs2.php