diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3b1d28988a..c511e6a5a9 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2011-08-19 Miguel de Dios + + * extensions/net_tools.php: fixed the try to execute any commands in the + extensions. + + Fixes: #3393861 + 2011-08-18 Dario Rodriguez * operation/menu.php: Fixed a bug which hide extension icons. diff --git a/pandora_console/extensions/net_tools.php b/pandora_console/extensions/net_tools.php index 371b3598c4..633e36ab28 100644 --- a/pandora_console/extensions/net_tools.php +++ b/pandora_console/extensions/net_tools.php @@ -53,58 +53,116 @@ function main_net_tools () { switch($operation){ - case 1: echo "

".__("Traceroute to "). $ip. "

"; - echo "
";
-                echo system ("/usr/sbin/traceroute $ip");
-                echo "
"; + case 1: + if (!file_exists('/usr/sbin/traceroute')) { + ui_print_error_message(__('Traceroute executable does not exist.')); + } + else { + echo "

".__("Traceroute to "). $ip. "

"; + echo "
";
+	                echo system ("/usr/sbin/traceroute $ip");
+	                echo "
"; + } break; - case 2: echo "

".__("Ping to "). $ip. "

"; - echo "
";
-                echo system ("ping -c 5 $ip");
-                echo "
"; + case 2: + ob_start(); + system('whereis ping'); + $output = ob_get_clean(); + $result = explode(':', $output); + $result = trim($result[1]); + if (empty($result)) { + ui_print_error_message(__('Ping executable does not exist.')); + } + else { + echo "

".__("Ping to "). $ip. "

"; + echo "
";
+	                echo system ("ping -c 5 $ip");
+	                echo "
"; + } break; - case 4: echo "

".__("Basic TCP Scan on "). $ip. "

"; - echo "
";
-                echo system ("nmap -F $ip");
-                echo "
"; + case 4: + ob_start(); + system('whereis nmap'); + $output = ob_get_clean(); + $result = explode(':', $output); + $result = trim($result[1]); + if (empty($result)) { + ui_print_error_message(__('Nmap executable does not exist.')); + } + else { + echo "

".__("Basic TCP Scan on "). $ip. "

"; + echo "
";
+                	echo system ("nmap -F $ip");
+                	echo "
"; + } break; - case 5: echo "

".__("Domain and IP information for "). $ip. "

"; - echo "
";
-                echo system ("dig $ip");
-                echo system ("whois $ip");
-                echo "
"; + case 5: + echo "

".__("Domain and IP information for "). $ip. "

"; + ob_start(); + system('whereis dig'); + $output = ob_get_clean(); + $result = explode(':', $output); + $result = trim($result[1]); + if (empty($result)) { + ui_print_error_message(__('Dig executable does not exist.')); + } + else { + echo "
";
+                	echo system ("dig $ip");
+                	echo "
"; + } + ob_start(); + system('whereis whois'); + $output = ob_get_clean(); + $result = explode(':', $output); + $result = trim($result[1]); + if (empty($result)) { + ui_print_error_message(__('Whois executable does not exist.')); + } + else { + echo "
";
+                	echo system ("whois $ip");
+                	echo "
"; + + } break; case 3: echo "

".__("SNMP information for "). $ip. "

"; - - echo "

Uptime

"; - echo "
";
-                echo exec ("snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
-
-                echo "
"; - - echo "

Device info

"; - echo "
";
-
-                echo system ("snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.1.0 ");
-                echo "
"; - - echo "

Interface Information

"; - echo ""; - echo "
".__("Interface"); - echo "".__("Status"); - - $int_max = exec ("snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.1.0 "); - - for ($ax=0; $ax < $int_max; $ax++){ - $interface = exec ("snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.2.$ax "); - $estado = exec ("snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.8.$ax "); - echo "
$interface$estado"; - } - - echo "
"; + ob_start(); + system('whereis snmpget'); + $output = ob_get_clean(); + $result = explode(':', $output); + $result = trim($result[1]); + if (empty($result)) { + ui_print_error_message(__('SNMPget executable does not exist.')); + } + else { + echo "

Uptime

"; + echo "
";
+                	echo exec ("snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
+                	echo "
"; + echo "

Device info

"; + echo "
";
+	
+	                echo system ("snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.1.0 ");
+	                echo "
"; + + echo "

Interface Information

"; + echo ""; + echo "
".__("Interface"); + echo "".__("Status"); + + $int_max = exec ("snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.1.0 "); + + for ($ax=0; $ax < $int_max; $ax++){ + $interface = exec ("snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.2.$ax "); + $estado = exec ("snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.8.$ax "); + echo "
$interface$estado"; + } + echo "
"; + } break; }