} else { if ($obj->get_status() == 'Search Finished') { if ($obj->get_only_ping() == FALSE) { $data['state'] = 'local_search_in_progress'; $task = _('Searching hosts'); } else { $data['state'] = 'finished'; $task = _('Scan Finished'); } } } } } if ($data['state'] != 'launching_local_scan') { $data['message'] = sprintf(_('%s: <strong>%s</strong> with local sensor, please wait...'), $task, $sc_asset); $progress = $obj->get_progress(); $data['progress']['percent'] = round($progress['hosts_scanned'] / $progress['total_hosts'] * 100); $data['progress']['current'] = $progress['hosts_scanned']; $data['progress']['total'] = $progress['total_hosts']; if ($progress['remaining'] == -1) { $data['progress']['time'] = _('Calculating Remaining Time'); } else { $data['progress']['time'] = Welcome_wizard::format_time($progress['remaining']) . ' ' . _('remaining'); } } else { $data['message'] = NULL; $data['progress'] = NULL; $data['debug_info'] = NULL; } $data['debug_info'] = NULL; }
} elseif ($scan_type == 'full') { $scan->append_option('-sS -p 1-65535'); } } // ping scan $scan->search_hosts(); $status = $scan->get_status(); while ($status == 'Searching Hosts') { $status = $scan->get_status(); sleep(2); } // normal scan if ($scan_type != 'ping' && $argv[3] != 'vulnscan') { $scan->launch_scan(); while ($scan->get_status() == 'Scanning Hosts') { $progress = $scan->get_progress(); echo $scan->get_status() . ': ' . $progress['hosts_scanned'] . '/' . $progress['total_hosts'] . ' ' . $progress['remaining'] . "\n"; sleep(2); } } $ips = $scan->get_results(); // delete results (only for vulnerabilities scans) if ($argv[3] == 'vulnscan') { $scan->delete_data(); } } if (is_array($ips['scanned_ips']) && !empty($ips['scanned_ips'])) { foreach ($ips['scanned_ips'] as $ip => $val) { echo "Host {$ip} appears to be up\n"; } }
function check_scan_progress($conn, $wizard) { $data = array(); $obj = new Scan(); $status = $obj->get_status(); //Get status if ($status == 'Scan Finished') { $info = array(); $result = $obj->get_results(); $obj->delete_data(); $info = Welcome_wizard::format_result_scan($conn, $result); $wizard->set_step_data('scan_step', 3); $wizard->set_step_data('scan_info', $info); $data['finish'] = TRUE; } elseif ($status == 'Scanning Hosts') { $progress = $obj->get_progress(); $percent = $progress['hosts_scanned'] / $progress['total_hosts'] * 100; $data['finish'] = FALSE; $data['percent'] = round($percent); $data['current'] = $progress['hosts_scanned']; $data['total'] = $progress['total_hosts']; if ($progress['remaining'] == -1) { $data['time'] = _('Calculating Remaining Time'); } else { $data['time'] = Welcome_wizard::format_time($progress['remaining']) . ' ' . _('remaining'); } } else { $msg = _("Invalid NMAP status ({$status}). Expecting 'Scanning Hosts' or 'Scan Finished'"); set_scan_error_message($wizard, $msg); $response['error'] = TRUE; return $response; } $response['error'] = FALSE; $response['data'] = $data; $wizard->save_status(); return $response; }