0) { foreach($states as $line) { $line_split = preg_split("/\s+/", $line); $type = array_shift($line_split); $proto = array_shift($line_split); $state = array_pop($line_split); $info = implode(" ", $line_split); /* break up info and extract $srcip and $dstip */ $ends = preg_split("/\-\>?/", $info); if (strpos($info, '->') === FALSE) { $srcinfo = $ends[count($ends) - 1]; $dstinfo = $ends[0]; } else { $srcinfo = $ends[0]; $dstinfo = $ends[count($ends) - 1]; } /* Handle IPv6 */ $parts = explode(":", $srcinfo); $partcount = count($parts) -1; $partsip = $parts; if($partcount == 1) { array_pop($partsip); } else { $srcip = trim(preg_replace("/\[[0-9]+\]/i", "", implode(":", $partsip))); } if($partcount > 1) { preg_match("/\[[0-9]+\]/i", $parts[$partcount], $matches); $srcport = $matches[0]; // $srcport = trim($parts[$partcount]); } else { $srcport = trim($parts[$partcount]); } $parts = explode(":", $dstinfo); $partsip = $parts; $partcount = count($parts) -1; if($partcount == 1) { array_pop($partsip); } else { $dstip = trim(preg_replace("/\[[0-9]+\]/i", "", implode(":", $partsip))); } if($partcount > 1) { preg_match("/\[[0-9]+\]/i", $parts[$partcount], $matches); $dstport = $matches[0]; // $dstport = trim($parts[$partcount]); } else { $dstport = trim($parts[$partcount]); } addipinfo($srcipinfo, $srcip, $proto, $srcport, $dstport); addipinfo($dstipinfo, $dstip, $proto, $srcport, $dstport); addipinfo($pairipinfo, "{$srcip} -> {$dstip}", $proto, $srcport, $dstport); addipinfo($allipinfo, $srcip, $proto, $srcport, $dstport); addipinfo($allipinfo, $dstip, $proto, $srcport, $dstport); } } function sort_by_ip($a, $b) { return ip2ulong($a) < ip2ulong($b) ? -1 : 1; } function build_port_info($portarr, $proto) { $ports = array(); asort($portarr); foreach (array_reverse($portarr, TRUE) as $port => $count) { $str = ""; $service = getservbyport($port, strtolower($proto)); $port = "{$proto}/{$port}"; if ($service) $port = "{$port} ({$service})"; $ports[] = "{$port}: {$count}"; } return implode($ports, ', '); } function print_summary_table($label, $iparr, $sort = TRUE) { ?>
=gettext("IP");?> | # =gettext("States");?> | =gettext("Proto");?> | # =gettext("States");?> | =gettext("Src Ports");?> | =gettext("Dst Ports");?> |