* You may not use, modify or distribute this program under any other version * of the GNU General Public License. * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this package; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA * * * On Debian GNU/Linux systems, the complete text of the GNU General * Public License can be found in `/usr/share/common-licenses/GPL-2'. * * Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt * */ require_once 'av_init.php'; require_once 'scan_util.php'; Session::logcheck('environment-menu', 'ToolsScan'); $db = new ossim_db(); $conn = $db->connect(); $scan = new Scan(); $lastscan = $scan->get_results(); if (!empty($lastscan['scanned_ips'])) { scan2html($conn, $lastscan); } $db->close();
} 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"; } }
**************** Configuration Data **************** ****************************************************/ $conf = $GLOBALS['CONF']; if (!$conf) { $conf = new Ossim_conf(); $GLOBALS['CONF'] = $conf; } /**************************************************** ******************** Scan Data ********************* ****************************************************/ //Database connection $db = new ossim_db(); $conn = $db->connect(); //Scan results $scan = new Scan(); $scan_results = $scan->get_results(); $sensor = $scan_results['sensor']; if (!empty($sensor['ctx'])) { $ctx = $sensor['ctx']; } else { echo ossim_error(_('Error! Scan results not found')); exit; } /* echo '<pre style="white-space: pre;">'; print_r($_SESSION['_scan']); echo '</pre>'; */ //All sensors $filters = array('where' => "sensor.id = acl_sensors.sensor_id AND acl_sensors.entity_id = UNHEX('{$ctx}')"); $all_sensors = Av_sensor::get_basic_list($conn, $filters);
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; }