$ip, 'resolve_text' => $res); else $response = array('resolve_ip' => $ip, 'resolve_text' => gettext("Cannot resolve")); echo json_encode(str_replace("\\","\\\\", $response)); // single escape chars can break JSON decode exit; } # --- AJAX REVERSE DNS RESOLVE End --- if ($_POST['todelete']) { $ip = ""; if ($_POST['ip']) $ip = $_POST['ip']; if (is_ipaddr($ip)) exec("/sbin/pfctl -t snort2c -T delete {$ip}"); else $input_errors[] = gettext("An invalid IP address was provided as a parameter."); } if ($_POST['remove']) { exec("/sbin/pfctl -t snort2c -T flush"); header("Location: /snort/snort_blocked.php"); exit; } /* TODO: build a file with block ip and disc */ if ($_POST['download']) { $blocked_ips_array_save = ""; exec('/sbin/pfctl -t snort2c -T show', $blocked_ips_array_save); /* build the list */ if (is_array($blocked_ips_array_save) && count($blocked_ips_array_save) > 0) { $save_date = date("Y-m-d-H-i-s"); $file_name = "snort_blocked_{$save_date}.tar.gz"; safe_mkdir("{$g['tmp_path']}/snort_blocked"); file_put_contents("{$g['tmp_path']}/snort_blocked/snort_block.pf", ""); foreach($blocked_ips_array_save as $counter => $fileline) { if (empty($fileline)) continue; $fileline = trim($fileline, " \n\t"); file_put_contents("{$g['tmp_path']}/snort_blocked/snort_block.pf", "{$fileline}\n", FILE_APPEND); } // Create a tar gzip archive of blocked host IP addresses exec("/usr/bin/tar -czf {$g['tmp_path']}/{$file_name} -C{$g['tmp_path']}/snort_blocked snort_block.pf"); // If we successfully created the archive, send it to the browser. if(file_exists("{$g['tmp_path']}/{$file_name}")) { ob_start(); //important or other posts will fail if (isset($_SERVER['HTTPS'])) { header('Pragma: '); header('Cache-Control: '); } else { header("Pragma: private"); header("Cache-Control: private, must-revalidate"); } header("Content-Type: application/octet-stream"); header("Content-length: " . filesize("{$g['tmp_path']}/{$file_name}")); header("Content-disposition: attachment; filename = {$file_name}"); ob_end_clean(); //important or other post will fail readfile("{$g['tmp_path']}/{$file_name}"); // Clean up the temp files and directory unlink_if_exists("{$g['tmp_path']}/{$file_name}"); rmdir_recursive("{$g['tmp_path']}/snort_blocked"); } else $savemsg = gettext("An error occurred while creating archive"); } else $savemsg = gettext("No content on snort block list"); } if ($_POST['save']) { /* no errors */ if (!$input_errors) { $config['installedpackages']['snortglobal']['alertsblocks']['brefresh'] = $_POST['brefresh'] ? 'on' : 'off'; $config['installedpackages']['snortglobal']['alertsblocks']['blertnumber'] = $_POST['blertnumber']; write_config("Snort pkg: updated BLOCKED tab settings."); header("Location: /snort/snort_blocked.php"); exit; } } $pgtitle = gettext("Snort: Blocked Hosts"); include_once("head.inc"); ?> \n"; /* Display Alert message */ if ($input_errors) { print_input_errors($input_errors); // TODO: add checks } if ($savemsg) { print_info_box($savemsg); } ?>
"/>     " onClick="return confirm('');"/>   
"/>    />  ', '', '', ''); ?>    ', '', '', ''); ?>
$blocked_msg) { $blocked_desc = implode("
", $blocked_msg); if($counter > $bnentries) break; else $counter++; /* Add zero-width space as soft-break opportunity after each colon if we have an IPv6 address */ $tmp_ip = str_replace(":", ":​", $blocked_ip); /* Add reverse DNS lookup icons (two different links if pfSense version supports them) */ $rdns_link = ""; $rdns_link .= "\"Icon"; /* use one echo to do the magic*/ echo "\n"; } } ?>
#
{$counter} {$tmp_ip}
{$rdns_link}
{$blocked_desc}
1) echo "{$counter}" . gettext(" host IP addresses are currently being blocked."); else echo "{$counter}" . gettext(" host IP address is currently being blocked."); } else { echo gettext("There are currently no hosts being blocked by Snort."); } ?>