Example #1
0
 $autodetect = $autodetect == 1 ? 'true' : 'false';
 $rdns = $rdns == 1 ? 'true' : 'false';
 $timing_template = empty($timing_template) ? 'T3' : $timing_template;
 $scan_options = array('scan_type' => $scan_type, 'scan_timing' => $timing_template, 'autodetect_os' => $autodetect, 'reverse_dns' => $rdns, 'scan_ports' => $custom_ports, 'idm' => 'false');
 $av_scan = new Av_scan($targets_p, $sensor, $scan_options);
 $av_scan->run();
 echo "Asset scan:\n";
 echo "\tTargets: " . $av_scan->get_targets('scan_format') . "\n";
 echo "\tSensor: " . $av_scan->get_sensor() . "\n";
 echo "\tScan Options: \n";
 $sc_options = $av_scan->get_scan_options();
 foreach ($sc_options as $sc_type => $sc_value) {
     echo "\t\t{$sc_type}: {$sc_value}\n";
 }
 if ($display_results == 1) {
     $status = $av_scan->get_status();
     while ($status['status']['code'] != Av_scan::ST_SCAN_FINISHED) {
         sleep(2);
         $status = $av_scan->get_status();
     }
     // Getting discovered hosts
     $scan_report = $av_scan->download_scan_report();
     // Deleting Scan Report
     $av_scan->delete_scan();
     //Parsing scan report
     $nmap_parser = new Nmap_parser();
     $scan_report = $nmap_parser->parse_json($scan_report, $av_scan->get_sensor());
     if (!empty($scan_report['scanned_ips'])) {
         foreach ($scan_report['scanned_ips'] as $ip => $hdata) {
             if ($hdata['status'] == 'up') {
                 echo "Host {$ip} appears to be up\n";