$setting) { if (!isset($setting['disable'])) { $interfaces['ovpn' . substr($mode, 0, 1) . $setting['vpnid']] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']); } } } } if ($_POST) { $host = $_POST['host']; $selectedif = $_POST['interface']; $count = $_POST['count']; $snaplen = $_POST['snaplen']; $port = $_POST['port']; $detail = $_POST['detail']; $fam = $_POST['fam']; $proto = $_POST['proto']; if (!array_key_exists($selectedif, $interfaces)) { $input_errors[] = gettext("Invalid interface."); } if ($fam !== "" && $fam !== "ip" && $fam !== "ip6") { $input_errors[] = gettext("Invalid address family."); } if ($proto !== "" && !in_array($proto, $protos)) { $input_errors[] = gettext("Invalid protocol."); } if ($host != "") { if (!is_subnet($host) && !is_ipaddr($host)) { $input_errors[] = sprintf(gettext("A valid IP address or CIDR block must be specified. [%s]"), $host); } } if ($port != "") { if (!is_port($port)) { $input_errors[] = gettext("Invalid value specified for port."); } } if ($snaplen == "") { $snaplen = 0; } else { if (!is_numeric($snaplen) || $snaplen < 0) { $input_errors[] = gettext("Invalid value specified for packet length."); } } if ($count == "") { $count = 0; } else { if (!is_numeric($count) || $count < 0) { $input_errors[] = gettext("Invalid value specified for packet count."); } } if (!count($input_errors)) { $do_tcpdump = true; conf_mount_rw(); if ($_POST['promiscuous']) { //if promiscuous mode is checked $disablepromiscuous = ""; } else { //if promiscuous mode is unchecked $disablepromiscuous = "-p"; } if ($_POST['dnsquery']) { //if dns lookup is checked $disabledns = ""; } else { //if dns lookup is unchecked $disabledns = "-n"; } if ($_POST['startbtn'] != "" ) { $action = gettext("Start"); //delete previous packet capture if it exists if (file_exists($fp.$fn)) unlink ($fp.$fn); } elseif ($_POST['stopbtn']!= "") { $action = gettext("Stop"); $processes_running = trim(shell_exec("/bin/ps axw -O pid= | /usr/bin/grep tcpdump | /usr/bin/grep {$fn} | /usr/bin/egrep -v '(pflog|grep)'")); //explode processes into an array, (delimiter is new line) $processes_running_array = explode("\n", $processes_running); //kill each of the packetcapture processes foreach ($processes_running_array as $process) { $process_id_pos = strpos($process, ' '); $process_id = substr($process, 0, $process_id_pos); exec("kill $process_id"); } } elseif ($_POST['downloadbtn']!= "") { //download file $fs = filesize($fp.$fn); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$fn"); header("Content-Length: $fs"); readfile($fp.$fn); exit; } } } else { $do_tcpdump = false; } include("head.inc"); ?>

/>

:









" . gettext("Enter 0 (zero) for no count limit.");?>

" . gettext("Note:") . " " . gettext("This option does not affect the level of detail when downloading the packet capture.");?>
/>

:
   "; else { echo " "; } if (file_exists($fp.$fn) and $processisrunning != true) { echo " "; echo ""; echo "
" . gettext("The packet capture file was last updated:") . " " . date("F jS, Y g:i:s a.", filemtime($fp.$fn)); } ?>
"; if ($processisrunning == true) echo("" . gettext("Packet Capture is running.") . "
"); if ($do_tcpdump) { $matches = array(); if (in_array($fam, $fams)) $matches[] = $fam; if (in_array($proto, $protos)) { if ($proto == "carp") { $matches[] = 'proto 112'; } else { $matches[] = $proto; } } if ($port != "") $matches[] = "port ".$port; if ($host != "") { if (is_ipaddr($host)) $matches[] = "host " . $host; elseif (is_subnet($host)) $matches[] = "net " . $host; } if ($count != "0" ) { $searchcount = "-c " . $count; } else { $searchcount = ""; } $selectedif = convert_friendly_interface_to_real_interface_name($selectedif); if ($action == gettext("Start")) { $matchstr = implode($matches, " and "); echo("" . gettext("Packet Capture is running.") . "
"); mwexec_bg ("/usr/sbin/tcpdump -i $selectedif $disablepromiscuous $searchcount -s $snaplen -w $fp$fn $matchstr"); } else { //action = stop echo("" . gettext("Packet Capture stopped.") . "

" . gettext("Packets Captured:") . "

"); ?> "; ?>