diff --git a/code_igniter/application/helpers/audit_helper.php b/code_igniter/application/helpers/audit_helper.php index 62efb5e7d..5650e7a7d 100644 --- a/code_igniter/application/helpers/audit_helper.php +++ b/code_igniter/application/helpers/audit_helper.php @@ -338,8 +338,6 @@ function audit_format_system($parameters) if (!filter_var($input->hostname, FILTER_VALIDATE_IP)) { if (strpos($input->hostname, '.') !== false) { # we have a fqdn in the hostname field - $mylog->message = "FQDN supplied in hostname, converting."; - discovery_log($mylog); if (empty($input->fqdn)) { $input->fqdn = $input->hostname; } @@ -350,6 +348,9 @@ function audit_format_system($parameters) $input->domain = implode('.', $temp); } unset($temp); + $mylog->message = "FQDN supplied in hostname, converting."; + $mylog->command_output = 'Hostname: ' . $input->hostname . ' Domain: ' . $input->domain; + discovery_log($mylog); } } @@ -358,6 +359,7 @@ function audit_format_system($parameters) if (empty($input->ip)) { $input->ip = $input->hostname; $mylog->message = "IP supplied in hostname, setting device IP."; + $mylog->command_output = 'IP: ' . $input->ip; discovery_log($mylog); } $input->hostname = ''; @@ -370,9 +372,12 @@ function audit_format_system($parameters) (strripos($input->manufacturer, "virtual") !== false))) { $input->form_factor = 'Virtual'; $mylog->message = "Manufacturer match, setting form factor to Virtual."; + $mylog->command_output = 'Manufacturer: ' . $input->manufacturer; discovery_log($mylog); } + $mylog->command_output = ''; + # Mac Model if (!empty($input->os_family) and $input->os_family == 'Apple OSX') { $CI->load->helper('mac_model'); diff --git a/code_igniter/application/helpers/snmp_helper.php b/code_igniter/application/helpers/snmp_helper.php index 28369ac08..96cc62600 100644 --- a/code_igniter/application/helpers/snmp_helper.php +++ b/code_igniter/application/helpers/snmp_helper.php @@ -364,8 +364,8 @@ function snmp_audit($ip, $credentials, $log) discovery_log($log); return false; } else { - $log->message = 'SNMP PHP function loaded and attempting to run snmp_helper::snmp_audit function'; - discovery_log($log); + #$log->message = 'SNMP PHP function loaded and attempting to run snmp_helper::snmp_audit function'; + #discovery_log($log); } # we need an ip address @@ -380,8 +380,8 @@ function snmp_audit($ip, $credentials, $log) discovery_log($log); return false; } else { - $log->message = 'Received ip ' . $ip; - discovery_log($log); + #$log->message = 'Received ip ' . $ip; + #discovery_log($log); } if (empty($credentials) or !is_object($credentials)) { @@ -390,8 +390,8 @@ function snmp_audit($ip, $credentials, $log) discovery_log($log); return false; } else { - $log->message = 'Received credentials for ip ' . $ip; - discovery_log($log); + #$log->message = 'Received credentials for ip ' . $ip; + #discovery_log($log); } # new in 1.5 - remove the type from the returned SNMP query. @@ -488,14 +488,14 @@ function snmp_audit($ip, $credentials, $log) } else { $details->uptime = intval($details->sysUpTime / 100); } - if (!empty($details->uptime)) { - $log->message = 'derive uptime from sysUpTime for '.$ip; - $log->command = ''; - $log->command_output = (string)$details->uptime; - $log->command_time_to_execute = (microtime(true) - $item_start); - discovery_log($log); - unset($log->id, $log->command, $log->command_time_to_execute, $log->command_output); - } + // if (!empty($details->uptime)) { + // $log->message = 'derive uptime from sysUpTime for '.$ip; + // $log->command = ''; + // $log->command_output = (string)$details->uptime; + // $log->command_time_to_execute = (microtime(true) - $item_start); + // discovery_log($log); + // unset($log->id, $log->command, $log->command_time_to_execute, $log->command_output); + // } $log->message = 'sysObjectID retrieval for '.$ip; $log->command = 'snmpget 1.3.6.1.2.1.1.2.0'; @@ -804,11 +804,14 @@ function snmp_audit($ip, $credentials, $log) unset($log->id, $log->command, $log->command_time_to_execute, $log->command_output); } - $log->message = 'SNMP audit thinks '.$ip.' is of type:'.$details->type; + $log->message = 'SNMP audit thinks '.$ip.' is of type: '.$details->type; + $log->command_output = $details->type; discovery_log($log); - $log->message = 'SNMP audit thinks '.$ip.' is a model:' . $details->model; + $log->message = 'SNMP audit thinks '.$ip.' is a model: ' . $details->model; + $log->command_output = $details->model; discovery_log($log); - $log->message = 'SNMP audit thinks '.$ip.' has a serial:' . $details->serial; + $log->message = 'SNMP audit thinks '.$ip.' has a serial: ' . $details->serial; + $log->command_output = $details->serial; discovery_log($log); // subnet @@ -840,20 +843,22 @@ function snmp_audit($ip, $credentials, $log) discovery_log($log); unset($log->id, $log->command, $log->command_time_to_execute); - $log->message = 'MAC Address for interface ' . $interface_number . ' using IP ' . $ip . ' retrieval for '.$ip; - $log->command = 'snmpget 1.3.6.1.2.1.2.2.1.6.'.$interface_number; - $log->command_status = 'fail'; - $log->id = discovery_log($log); - $item_start = microtime(true); - snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); - $details->mac_address = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.2.2.1.6.".$interface_number); - snmp_set_valueretrieval(SNMP_VALUE_PLAIN); - $log->command_time_to_execute = (microtime(true) - $item_start); - $details->mac_address = format_mac($details->mac_address); - $log->command_output = (string)$details->mac_address; - $log->command_status = 'notice'; - discovery_log($log); - unset($log->id, $log->command, $log->command_time_to_execute); + if (!empty($interface_number)) { + $log->message = 'MAC Address for interface ' . $interface_number . ' using IP ' . $ip . ' retrieval for '.$ip; + $log->command = 'snmpget 1.3.6.1.2.1.2.2.1.6.'.$interface_number; + $log->command_status = 'fail'; + $log->id = discovery_log($log); + $item_start = microtime(true); + snmp_set_valueretrieval(SNMP_VALUE_LIBRARY); + $details->mac_address = my_snmp_get($ip, $credentials, "1.3.6.1.2.1.2.2.1.6.".$interface_number); + snmp_set_valueretrieval(SNMP_VALUE_PLAIN); + $log->command_time_to_execute = (microtime(true) - $item_start); + $details->mac_address = format_mac($details->mac_address); + $log->command_output = (string)$details->mac_address; + $log->command_status = 'notice'; + discovery_log($log); + unset($log->id, $log->command, $log->command_time_to_execute); + } } // last attempt at a MAC - just use whatever's in the first interface MAC if (empty($details->mac_address)) { @@ -1241,10 +1246,10 @@ function snmp_audit($ip, $credentials, $log) discovery_log($log); unset($log->id, $log->command, $log->command_time_to_execute, $log->command_output); - $log->message = 'Processing modules for '.$ip; - $log->command_status = 'fail'; - $log->id = discovery_log($log); - $item_start = microtime(true); + // $log->message = 'Processing modules for '.$ip; + // $log->command_status = 'fail'; + // $log->id = discovery_log($log); + // $item_start = microtime(true); foreach ($modules_list as $key => $value) { $module = new stdClass(); @@ -1306,10 +1311,10 @@ function snmp_audit($ip, $credentials, $log) $modules[] = $module; } - $log->command_time_to_execute = (microtime(true) - $item_start); - $log->command_status = 'notice'; - discovery_log($log); - unset($log->id, $log->command, $log->command_time_to_execute); + // $log->command_time_to_execute = (microtime(true) - $item_start); + // $log->command_status = 'notice'; + // discovery_log($log); + // unset($log->id, $log->command, $log->command_time_to_execute); } unset($log->id, $log->command, $log->command_time_to_execute, $log->command_output); @@ -1505,10 +1510,10 @@ function snmp_audit($ip, $credentials, $log) discovery_log($log); unset($log->id, $log->command, $log->command_time_to_execute, $log->command_output); - $log->message = 'Processing interfaces for '.$ip; - $log->command_status = 'fail'; - $log->id = discovery_log($log); - $item_start = microtime(true); + // $log->message = 'Processing interfaces for '.$ip; + // $log->command_status = 'fail'; + // $log->id = discovery_log($log); + // $item_start = microtime(true); foreach ($interfaces as $key => $value) { // $log->message = 'Processing interface '. $value .' for '.$ip; @@ -1597,10 +1602,10 @@ function snmp_audit($ip, $credentials, $log) // unset($log->id, $log->command, $log->command_time_to_execute); } - $log->command_time_to_execute = (microtime(true) - $item_start); - $log->command_status = 'notice'; - discovery_log($log); - unset($log->id, $log->command, $log->command_time_to_execute); + // $log->command_time_to_execute = (microtime(true) - $item_start); + // $log->command_status = 'notice'; + // discovery_log($log); + // unset($log->id, $log->command, $log->command_time_to_execute); } // end of network interfaces // Special for ExaBlaze diff --git a/code_igniter/application/helpers/ssh_helper.php b/code_igniter/application/helpers/ssh_helper.php index 5a5437b9b..68c89254c 100644 --- a/code_igniter/application/helpers/ssh_helper.php +++ b/code_igniter/application/helpers/ssh_helper.php @@ -505,7 +505,11 @@ function ssh_command($parameters) if (stripos($command, 'audit_') !== false and stripos($command, 'submit_online') !== false) { $log->command_output = 'Audit console output removed.'; } else { - $log->command_output = json_encode($result); + if (!empty($result)) { + $log->command_output = json_encode($result); + } else { + $log->command_output = ''; + } } $log->command_status = 'success'; discovery_log($log); @@ -763,17 +767,13 @@ function ssh_audit($parameters) } $log->severity = 7; - if (strpos($device->shell, 'bash') === false) { + if (strpos($device->shell, 'bash') === false and $device->bash === '') { $log->command = ''; $log->command_output = $device->shell; $log->command_time_to_execute = ''; $log->severity = 6; - $log->message = 'Will use ' . $device->bash . ' to run commands. Running commands in a shell other than bash may fail.'; + $log->message = 'Will use ' . $device->shell . ' to run commands. Running commands in a shell other than bash may fail.'; $log->command_status = 'notice'; - if ($device->bash === '') { - $log->message = 'Unable to detect shell. Running commands in a shell other than bash may fail.'; - $log->command_status = 'notice'; - } discovery_log($log); } $log->severity = 7; @@ -850,18 +850,18 @@ function ssh_audit($parameters) } else { $device->$item = $temp1; } - $log->command = $command . '; # ' . $item; + $log->command = $command; $log->command_time_to_execute = (microtime(true) - $item_start); $log->command_output = $temp1; $log->command_status = 'success'; - $log->message = 'SSH command'; + $log->message = 'SSH command - ' . $item; discovery_log($log); } else { - $log->command = $command . '; # ' . $item; + $log->command = $command; $log->command_time_to_execute = (microtime(true) - $item_start); $log->command_output = $temp1; $log->command_status = 'notice'; - $log->message = 'SSH command'; + $log->message = 'SSH command - ' . $item; discovery_log($log); } }