From fdcc94c973d61600bddc38c11844357ab8949ba3 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sat, 1 Aug 2015 16:23:13 +0200 Subject: nmap - code style fixes, add copyright headers --- config/nmap/nmap.inc | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) (limited to 'config/nmap') diff --git a/config/nmap/nmap.inc b/config/nmap/nmap.inc index 632d4b2d..3f17d447 100644 --- a/config/nmap/nmap.inc +++ b/config/nmap/nmap.inc @@ -1,9 +1,9 @@ + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -43,20 +43,16 @@ function nmap_install() { } /* Only copy the file if it doesn't exist */ if (file_exists($source_file) && !file_exists($destination_file)) { - if (!is_dir(dirname($destination_file))) { - @mkdir(dirname($destination_file), 0644, true); - } + safe_mkdir(dirname($destination_file)); @symlink($source_file, $destination_file); } } -function nmap_custom_php_validation_command($post, & $input_errors) { +function nmap_custom_php_validation_command($post, &$input_errors) { global $_POST, $savemsg, $config; if (empty($_POST['hostname'])) { $input_errors[] = gettext("You must enter an IP address to scan."); - } elseif (!(is_ipaddr($_POST['hostname']) || - is_subnet($_POST['hostname']) || - is_hostname($_POST['hostname']))) { + } elseif (!(is_ipaddr($_POST['hostname']) || is_subnet($_POST['hostname']) || is_hostname($_POST['hostname']))) { $input_errors[] = gettext("You must enter a valid IP address to scan."); } @@ -71,9 +67,11 @@ function nmap_custom_php_validation_command($post, & $input_errors) { function nmap_custom_add_php_command() { $nmap_options = ""; - if (function_exists("is_ipaddrv6") && function_exists("is_subnetv6")) - if (is_ipaddrv6($_POST['hostname']) || is_subnetv6($_POST['hostname'])) + if (function_exists("is_ipaddrv6") && function_exists("is_subnetv6")) { + if (is_ipaddrv6($_POST['hostname']) || is_subnetv6($_POST['hostname'])) { $nmap_options .= " -6"; + } + } switch($_POST['scanmethod']) { case 'syn': @@ -93,14 +91,23 @@ function nmap_custom_add_php_command() { break; } - if($_POST['noping']) $nmap_options .= " -P0"; - if($_POST['servicever']) $nmap_options .= " -sV"; - if($_POST['osdetect']) $nmap_options .= " -O"; - if(!empty($_POST['interface'])) $nmap_options .= " -e " . get_real_interface($_POST['interface']); + if ($_POST['noping']) { + $nmap_options .= " -P0"; + } + if ($_POST['servicever']) { + $nmap_options .= " -sV"; + } + if ($_POST['osdetect']) { + $nmap_options .= " -O"; + } + if (!empty($_POST['interface'])) { + $nmap_options .= " -e " . get_real_interface($_POST['interface']); + } $nmap_options .= " " . escapeshellarg($_POST['hostname']); - echo "Running: /usr/local/bin/nmap {$nmap_options}
"; + echo "Running: /usr/local/bin/nmap {$nmap_options}
"; system("/usr/local/bin/nmap" . $nmap_options); + echo "

"; } function nmap_get_interfaces() { -- cgit v1.2.3