2014-05-28 Alejandro Gallardo <alejandro.gallardo@artica.es>
* include/functions_snmp.php: Improved the security on the function "snmp_generate_trap" by escaping the command arguments. * include/functions_snmp_browser.php: Improved the Windows compatibility of some commands. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10030 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
f68815faf6
commit
baf5cedde8
|
@ -1,3 +1,12 @@
|
|||
2014-05-28 Alejandro Gallardo <alejandro.gallardo@artica.es>
|
||||
|
||||
* include/functions_snmp.php: Improved the security
|
||||
on the function "snmp_generate_trap" by escaping the
|
||||
command arguments.
|
||||
|
||||
* include/functions_snmp_browser.php: Improved the
|
||||
Windows compatibility of some commands.
|
||||
|
||||
2014-05-28 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* godmode/agentes/configurar_agente.php: Fixed field that
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
* @param string Snmp especific OID.
|
||||
*/
|
||||
function snmp_generate_trap($snmp_host_address, $snmp_community, $snmp_oid, $snmp_agent, $snmp_data, $snmp_type) {
|
||||
$command = "snmptrap -v 1 -c $snmp_community $snmp_host_address $snmp_oid $snmp_agent $snmp_type $snmp_data 0 2>&1";
|
||||
$command = "snmptrap -v 1 -c " . escapeshellarg($snmp_community) . " " . escapeshellarg($snmp_host_address) . " " . escapeshellarg($snmp_oid) . " "
|
||||
. escapeshellarg($snmp_agent) . " " . escapeshellarg($snmp_type) . " " . escapeshellarg($snmp_data) . " 0 2>&1";
|
||||
|
||||
$output = null;
|
||||
exec($command, $output, $return);
|
||||
|
|
|
@ -162,12 +162,24 @@ function snmp_browser_get_tree ($target_ip, $community, $starting_oid = '.', $ve
|
|||
else {
|
||||
$snmpwalk_bin = $config['snmpwalk'];
|
||||
}
|
||||
|
||||
switch (PHP_OS) {
|
||||
case "WIN32":
|
||||
case "WINNT":
|
||||
case "Windows":
|
||||
$error_redir_dir = 'NUL';
|
||||
break;
|
||||
default:
|
||||
$error_redir_dir = '/dev/null';
|
||||
break;
|
||||
}
|
||||
|
||||
$oid_tree = array('__LEAVES__' => array());
|
||||
if ($version == "3") {
|
||||
exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc);
|
||||
exec ($snmpwalk_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redir_dir, $output, $rc);
|
||||
}
|
||||
else {
|
||||
exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2>/dev/null', $output, $rc);
|
||||
exec ($snmpwalk_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -Cc -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($starting_oid) . ' 2> ' . $error_redirection, $output, $rc);
|
||||
}
|
||||
//if ($rc != 0) {
|
||||
// return __('No data');
|
||||
|
@ -264,11 +276,23 @@ function snmp_browser_get_oid ($target_ip, $community, $target_oid, $version = '
|
|||
else {
|
||||
$snmpget_bin = $config['snmpget'];
|
||||
}
|
||||
|
||||
switch (PHP_OS) {
|
||||
case "WIN32":
|
||||
case "WINNT":
|
||||
case "Windows":
|
||||
$error_redir_dir = 'NUL';
|
||||
break;
|
||||
default:
|
||||
$error_redir_dir = '/dev/null';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($version == "3") {
|
||||
exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc);
|
||||
exec ($snmpget_bin . ' -m ALL -v 3 -u ' . escapeshellarg($snmp3_auth_user) . ' -A ' . escapeshellarg($snmp3_auth_pass) . ' -l ' . escapeshellarg($snmp3_security_level) . ' -a ' . escapeshellarg($snmp3_auth_method) . ' -x ' . escapeshellarg($snmp3_privacy_method) . ' -X ' . escapeshellarg($snmp3_privacy_pass) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc);
|
||||
}
|
||||
else {
|
||||
exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2>/dev/null', $output, $rc);
|
||||
exec ($snmpget_bin . ' -m ALL -M +' . escapeshellarg($config['homedir'] . '/attachment/mibs') . ' -On -c ' . escapeshellarg($community) . ' -v ' . escapeshellarg($version) . ' ' . escapeshellarg($target_ip) . ' ' . escapeshellarg($target_oid) . ' 2> ' . $error_redir_dir, $output, $rc);
|
||||
}
|
||||
|
||||
if ($rc != 0) {
|
||||
|
|
Loading…
Reference in New Issue