[- use DBI; -]
[- use POSIX; -]
[- use Socket; -]
[- $req = shift; -]
[# Lets look for UNIX Metacharacters in the query string from the browser #]
[$ if $ENV{'QUERY_STRING'} =~ /([;\*\/'\$!#\(\)\[\]\{\}:'"])/ $]
[- Execute ('error.html') -]
[- exit -]
[$ endif $]
[- $LanChoice = $fdat{LanChoice}; -]
[- chomp $LanChoice; -]
[- $HostChoice = $fdat{HostChoice} -]
[- chomp $HostChoice; -]
[- $Event = $fdat{Event} -]
[- chomp $Event; -]
[$ if $Event eq "Inbnd" $]
[- $TableName = "InBnd" -]
[$ elsif $Event eq "Outbnd" $]
[- $TableName = "OutBnd" -]
[$ endif $]
[- ($dsn) = "DBI:mysql:FireWatch"; -]
[- $dsn .= ";mysql_read_default_file=./sql.epl"; -]
[- $dbh = DBI->connect($dsn); -]
[+ $LanChoice +] [+ $Event +] Blocked TCP to [+ $HostChoice +]
[- $ResultsPerPage = 50; -]
[- $k =0 -]
[- $sth = $dbh -> prepare ("SELECT count(SRC_IP) from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol like 'TCP' and Lan = '$LanChoice' and Event like '$Event%' group by SRC_IP,DST_Port"); -]
[- $sth -> execute; -]
[$ while @row = $sth -> fetchrow_array $]
[- $k++ -]
[$ endwhile $]
[- $sth -> finish (); -]
[- $Returned = $k -]
[- chomp $Returned; -]
[- $PagesNeeded = ceil(($Returned / $ResultsPerPage)); -]
[- chomp $PagesNeeded; -]
[$ if $PagesNeeded <= "1" $]
Retrieved [+ $Returned +] records
[$ else $]
Retrieved [+ $Returned +] records listed on [+ $PagesNeeded +] pages
[$ endif $]
[- $Choice = $fdat{Choice} -]
[- $LowerLimit = $fdat{LowerLimit} -]
[$ if $LowerLimit == "" && $fdat{Choice} eq "" $]
[- $LowerLimit = 0 -]
[$ endif $]
[# Default for fresh page load #]
[$ if $Choice eq "" $]
[- $sth = $dbh -> prepare ("SELECT count(*) as Event_Count,DateStamp,SRC_IP,SRC_Port,DST_Port,Protocol
from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol = 'TCP' and Lan = '$LanChoice' and Event like '$Event%'
group by SRC_IP,DST_Port
order by DateStamp desc limit $LowerLimit, $ResultsPerPage"); -]
[- $sth -> execute; -]
[$ elsif $Choice eq "DateStamp" $]
[- $sth = $dbh -> prepare ("SELECT count(*) as Event_Count,DateStamp,SRC_IP,SRC_Port,DST_Port,Protocol
from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol = 'TCP' and Lan = '$LanChoice' and Event like '$Event%'
group by SRC_IP,DST_Port
order by DateStamp desc limit $LowerLimit, $ResultsPerPage"); -]
[- $sth -> execute; -]
[$ elsif $Choice eq "EventCount" $]
[- $sth = $dbh -> prepare ("SELECT count(*) as Event_Count,DateStamp,SRC_IP,SRC_Port,DST_Port,Protocol
from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol = 'TCP' and Lan = '$LanChoice' and Event like '$Event%'
group by SRC_IP,DST_Port order
by Event_Count desc limit $LowerLimit, $ResultsPerPage"); -]
[- $sth -> execute; -]
[$ elsif $Choice eq "SrcIP" $]
[- $sth = $dbh -> prepare ("SELECT count(*) as Event_Count,DateStamp,SRC_IP,SRC_Port,DST_Port,Protocol
from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol = 'TCP' and Lan = '$LanChoice' and Event like '$Event%'
group by SRC_IP,DST_Port
order by SRC_IP desc limit $LowerLimit, $ResultsPerPage"); -]
[- $sth -> execute; -]
[$ elsif $Choice eq "SrcPort" $]
[- $sth = $dbh -> prepare ("SELECT count(*) as Event_Count,DateStamp,SRC_IP,SRC_Port,DST_Port,Protocol
from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol = 'TCP' and Lan = '$LanChoice' and Event like '$Event%'
group by SRC_IP,DST_Port
order by SRC_Port desc limit $LowerLimit, $ResultsPerPage"); -]
[- $sth -> execute; -]
[$ elsif $Choice eq "DstPort" $]
[- $sth = $dbh -> prepare ("SELECT count(*) as Event_Count,DateStamp,SRC_IP,SRC_Port,DST_Port,Protocol
from `${HostChoice}_${TableName}_Week$req->{weeknum}`
where Protocol = 'TCP' and Lan = '$LanChoice' and Event like '$Event%'
group by SRC_IP,DST_Port
order by DST_Port desc limit $LowerLimit, $ResultsPerPage"); -]
[- $sth -> execute; -]
[$ endif $]
Protocol |
[$ while @row = $sth -> fetchrow_array $]
[+ @row[1] +] |
[+ @row[0] +] |
[+ inet_ntoa(pack"N", hex(@row[2])) +] |
[+ @row[3] +] |
[+ @row[4] +] |
[+ @row[5] +] |
[$ endwhile $]
[- $dbh->disconnect -]
[- $j = 0 -]
[- $i = 0 -]
|
[$ if $PagesNeeded <= "1" $]
Page [+ $i +] |
[$ else $]
[$ while $j,$i <= ($PagesNeeded - 1) $]
Page [+ $i++ +] |
[$ endwhile $]
[$ endif $]