diff --git a/usr/local/www/diag_logs_filter.php b/usr/local/www/diag_logs_filter.php
index 2e4045f212..960956f322 100755
--- a/usr/local/www/diag_logs_filter.php
+++ b/usr/local/www/diag_logs_filter.php
@@ -38,13 +38,15 @@
##|-PRIV
require("guiconfig.inc");
+require_once("filter_log.inc");
if($_GET['getrulenum'] or $_POST['getrulenum']) {
if($_GET['getrulenum'])
- $rulenum = escapeshellarg($_GET['getrulenum']);
+ $rulenum = $_GET['getrulenum'];
if($_POST['getrulenum'])
- $rulenum = escapeshellarg($_POST['getrulenum']);
- $rule = `pfctl -vvsr | grep '@{$rulenum} '`;
+ $rulenum = $_POST['getrulenum'];
+ list($rulenum, $type) = explode(',', $rulenum);
+ $rule = find_rule_by_number($rulenum, $type);
echo "The rule that triggered this action is:\n\n{$rule}";
exit;
}
@@ -58,126 +60,12 @@ if (!$nentries)
if ($_POST['clear'])
clear_log_file($filter_logfile);
-/* format filter logs */
-function conv_clog($logfile, $tail = 50) {
- global $config, $nentries, $g;
- $logarr = "";
- /* make interface/port table */
- $iftable = array();
- $iflist = get_configured_interface_with_descr();
- foreach ($iflist as $if => $ifdesc)
- $iftable[get_real_interface($if)] = $ifdesc;
-
- $sor = isset($config['syslog']['reverse']) ? "-r" : "";
-
- if(isset($config['system']['usefifolog']))
- exec("/usr/sbin/fifolog_reader {$logfile} | /usr/bin/tail {$sor} -n 500", $logarr);
- else
- exec("/usr/sbin/clog {$logfile} | grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n 500", $logarr);
-
- $filterlog = array();
-
- $counter = 1;
-
- foreach ($logarr as $logent) {
-
- if($counter > $nentries)
- break;
-
- $log_split = "";
-
-
- preg_match("/(\b(?:\d{1,3}\.){3}\d{1,3}(\.\w+)?)\s.*\s(\b(?:\d{1,3}\.){3}\d{1,3}(\.\w+)?)/", $logent, $log_split);
-
- $flent['src'] = convert_port_period_to_colon($log_split[1]);
- $flent['dst'] = convert_port_period_to_colon($log_split[3]);
-
- preg_match("/(.*)\s.*\spf:\s.*\srule\s(.*)\(match\)\:\s(.*)\s\w+\son\s(\w+)\:\s(.*)\s>\s(.*)\:\s.*/", $logent, $log_split);
-
- $beforeupper = $logent;
- $logent = strtoupper($logent);
-
- if(stristr(strtoupper($logent), "UDP") == true)
- $flent['proto'] = "UDP";
- else if(stristr(strtoupper($logent), "TCP") == true)
- $flent['proto'] = "TCP";
- else if(stristr(strtoupper($logent), "ICMP") == true)
- $flent['proto'] = "ICMP";
- else if(stristr(strtoupper($logent), "HSRP") == true)
- $flent['proto'] = "HSRP";
- else if(stristr(strtoupper($logent), "ESP") == true)
- $flent['proto'] = "ESP";
- else if(stristr(strtoupper($logent), "AH") == true)
- $flent['proto'] = "AH";
- else if(stristr(strtoupper($logent), "GRE") == true)
- $flent['proto'] = "GRE";
- else if(stristr(strtoupper($logent), "IGMP") == true)
- $flent['proto'] = "IGMP";
- else if(stristr(strtoupper($logent), "CARP") == true)
- $flent['proto'] = "CARP";
- else if(stristr(strtoupper($logent), "VRRP") == true)
- $flent['proto'] = "VRRP";
- else if(stristr(strtoupper($logent), "PFSYNC") == true)
- $flent['proto'] = "PFSYNC";
- else if(stristr($logent, "sack") == true)
- $flent['proto'] = "TCP";
- else
- $flent['proto'] = "TCP";
-
- $flent['time'] = $log_split[1];
- $flent['act'] = $log_split[3];
- $flent['interface'] = empty($iftable[$log_split[4]]) ? $log_split[4] : $iftable[$log_split[4]];
-
- $tmp = split("/", $log_split[2]);
- $flent['rulenum'] = $tmp[0];
-
- $shouldadd = true;
-
- if(trim($flent['src']) == "")
- $shouldadd = false;
- if(trim($flent['dst']) == "")
- $shouldadd = false;
- if(trim($flent['time']) == "")
- $shouldadd = false;
-
- if($shouldadd == true) {
- $counter++;
- $filterlog[] = $flent;
- } else {
- if($g['debug']) {
- log_error("There was a error parsing rule: $beforeupper . Please report to mailing list or forum.");
- }
- }
-
- }
-
- return $filterlog;
-}
-
-function convert_port_period_to_colon($addr) {
- $addr_split = split("\.", $addr);
- if($addr_split[4] == "")
- $newvar = $addr_split[0] . "." . $addr_split[1] . "." . $addr_split[2] . "." . $addr_split[3];
- else
- $newvar = $addr_split[0] . "." . $addr_split[1] . "." . $addr_split[2] . "." . $addr_split[3] . ":" . $addr_split[4];
- if($newvar == "...")
- return $addr;
- return $newvar;
-}
-
-function format_ipf_ip($ipfip) {
- list($ip,$port) = explode(",", $ipfip);
- if (!$port)
- return $ip;
-
- return $ip . ", port " . $port;
-}
-
$pgtitle = array("Status","System logs","Firewall");
include("head.inc");
?>
+
@@ -201,11 +89,11 @@ include("head.inc");
|
- Last =$nentries;?> firewall log entries (switch to dynamic view) |
+ Last firewall log entries (switch to dynamic view)
| Act |
@@ -218,79 +106,37 @@ include("head.inc");
-
-
-
+ ', outputrule);">
+
|
- =htmlspecialchars($filterent['time']);?> |
- =htmlspecialchars($filterent['interface']);?> |
- =htmlspecialchars($filterent['src']);?> |
- =htmlspecialchars($filterent['dst']);?> |
- =htmlspecialchars($filterent['proto']);?> |
+ |
+ |
+ |
+ |
+
+ |
|
- Last =$nentries;?> firewall log entries |
+ Last firewall log entries
-
|
+
|
|
-
+TCP Flags: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, C - CWR
+