} else { $ips = array(); echo '<br>\\n<b>Unable to run remote scan:</b> ' . $rscan->err() . "\n"; } // delete results (only for vulnerabilities scans) if ($argv[3] == 'vulnscan') { $rscan->del_scan(); } } else { echo 'Scanning local networks: ' . $targets . "\n"; $only_ping = $scan_type == 'ping' || $argv[3] == 'vulnscan' ? TRUE : FALSE; $config = array('only_ping' => $only_ping, 'user' => $user); $scan = new Scan($targets, $config); if ($argv[3] != 'vulnscan') { // Append Timing $scan->append_option($timing_template); // Append Autodetect if ($autodetect) { if ($scan_type != 'fast') { $scan->append_option('-A'); } else { $scan->append_option('-sV -O --osscan-guess --max-os-tries=1'); } } // Append RDNS if (!$rdns) { $scan->append_option('-n'); } if ($scan_type == 'fast') { $scan->append_option('-p21,22,23,25,53,80,113,115,135,139,161,389,443,445,554,1194,1241,1433,3000,3306,3389,8080,9390,27017'); } elseif ($scan_type == 'custom') {
die("Incorrect net/host format {$net}\n"); } if ($remote_sensor != "" && $remote_sensor != "null") { $rscan = new RemoteScan($net, "ping", $remote_sensor, $nmap_completed_scan); $quiet = $timing_template != "" ? FALSE : TRUE; echo "Scanning remote network: {$net}\n"; $rscan->do_scan($quiet); if ($rscan->err() == "") { $ips = $rscan->get_scan(); } else { $ips = array(); echo "Unable to run remote scan: " . $rscan->err() . "\n"; } } else { echo "Scanning local network: {$net}\n"; $scan = new Scan($net, null, $nmap_completed_scan); $scan->append_option($timing_template); if ($full == "fast") { $scan->append_option("-F"); $scan->do_scan(TRUE); } elseif ($full == "full") { $scan->do_scan(TRUE); } else { $scan->do_scan(FALSE); } echo "\n"; $ips = $scan->get_scan(); } foreach ($ips as $ip => $val) { echo "Host {$ip} appears to be up\n"; }