示例#1
0
        ossim_valid($custom_ports, OSS_DIGIT, OSS_SPACE, OSS_SCORE, OSS_NULLABLE, ',', 'illegal:' . _('Custom Ports'));
        if (ossim_error()) {
            $e_msg = ossim_get_error_clean();
        } else {
            // Run remote nmap scans
            $targets = array();
            foreach ($explain_scan as $sensor_id => $s_data) {
                //Sensor status: Idle(0), Running (1) or Down(2)
                $code = $s_data['status']['code'];
                if ($code == 0) {
                    foreach ($s_data['assets'] as $assets) {
                        $targets[] = $assets['ip'];
                    }
                    $targets = implode(' ', $targets);
                    $scan_options = array('scan_type' => $scan_type, 'timing_template' => $timing_template, 'autodetect_os' => $autodetect, 'reverse_dns' => $rdns, 'ports' => $custom_ports, 'idm' => 'true');
                    $av_scan = new Av_scan($targets, $sensor_id, $scan_options);
                    $res = $av_scan->run();
                    $close = TRUE;
                    unset($av_scan);
                    $explain_scan[$sensor_id]['status'] = array('code' => 1, 'desc' => _('Running'));
                }
            }
        }
    }
} catch (Exception $e) {
    $e_msg = $e->getMessage();
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
示例#2
0
 $session = new Session($user, $pass, '');
 $session->login(TRUE);
 $db->close();
 $is_disabled = $session->is_user_disabled();
 if ($is_disabled == TRUE) {
     $e_msg = _('Error! Scan cannot be completed: Scan owner is disabled');
     Av_exception::throw_error(Av_exception::USER_ERROR, $e_msg);
 }
 $client = new Alienvault_client($user);
 $client->auth()->login($user, $pass);
 //Launching scan
 $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();
     }
示例#3
0
function cancel_scan($wizard)
{
    //File to cache scan object
    $user = Session::get_session_user();
    $scan_file = 'w_last_asset_object-' . md5($user);
    $step = intval($wizard->get_step_data('scan_step'));
    if ($step == 1 || $step == 2) {
        $obj = Av_scan::get_object_from_file($scan_file);
        $obj->stop();
        $obj->delete_scan();
        Cache_file::remove_file($scan_file);
    }
    $wizard->clean_step_data();
    $wizard->save_status();
    $response['error'] = FALSE;
    return $response;
}
示例#4
0
$filters = array('where' => 'sensor_properties.version <> ""', 'order_by' => 'sensor.name, priority DESC');
$sensor_list = Av_sensor::get_list($conn, $filters);
$sensor_list = $sensor_list[0];
/****************************************************
******************** Search Box ********************
****************************************************/
$autocomplete_keys = array('hosts', 'nets');
$assets = Autocomplete::get_autocomplete($conn, $autocomplete_keys);
/****************************************************
******************** Clear Scan ********************
****************************************************/
//Results will be deleted when a custom scan is executed or when an user forces it
if (intval($_REQUEST['clearscan']) == 1 || $_REQUEST['action'] == 'custom_scan') {
    try {
        //Delete scan task from Redis
        $av_scan = Av_scan::get_object_from_file($scan_file);
        if (is_object($av_scan) && !empty($av_scan)) {
            $av_scan->delete_scan();
            //Delete local scan files
            Cache_file::remove_file($scan_file);
        }
        //Delete report scan information
        @unlink($scan_report_file);
    } catch (Exception $e) {
    }
}
/*******************************************************************
***  Custom scan (From Asset Detail or from a Suggestion Link)   ***
********************************************************************/
if ($_REQUEST['action'] == 'custom_scan') {
    if ($_GET['action'] == 'custom_scan') {
示例#5
0
 $session = new Session($user, $pass, '');
 $session->login(TRUE);
 $db->close();
 $is_disabled = $session->is_user_disabled();
 if ($is_disabled == TRUE) {
     $e_msg = _('Error! Scan cannot be completed: Scan owner is disabled');
     Av_exception::throw_error(Av_exception::USER_ERROR, $e_msg);
 }
 $client = new Alienvault_client($user);
 $client->auth()->login($user, $pass);
 //Launching scan
 $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();
 //File to cache scan object
 $scan_file = 'last_asset_object-' . md5($user);
 Av_scan::set_object_in_file($av_scan, $scan_file);
 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) {
示例#6
0
if (!(valid_hex32($scan_server) && (Session::allowedSensors() == "" || in_array($scan_server, array_values($sensor_ids))))) {
    $scan_server = "";
}
$message_pre_scan = _('Pre-scan localy');
$message_force_pre_scan = _('Error: Need to force pre-scan locally');
$ctest = array();
// to save connection test to servers
$ttargets = array();
// to save check for targets
$sensor_error = false;
// Getting available sensors (connected sensors)
$_list_data = Av_sensor::get_list($conn);
$all_sensors = $_list_data[0];
// Remote nmap
$ids = array();
$agents = Av_scan::get_scanning_sensors();
if (is_array($agents) && !empty($agents)) {
    $ids = array_keys($agents);
}
$withnmapforced = 0;
if (valid_hex32($scan_server) && !$hosts_alive && $sensor_id != '') {
    $ids = array_merge(array($sensor_id), $ids);
    $withnmapforced = 1;
}
// targets
$total_host = 0;
// count total targets to scan
foreach ($targets as $target => $target_data) {
    $sensors = array();
    if ($scan_server != '') {
        $sensors = array($scan_server);
示例#7
0
<?php 
//There are some validation errors
if ($data['status'] == 'error') {
    $txt_error = '<div>' . _('The following errors occurred') . ":</div>\n                  <div style='padding: 10px;'>" . implode('<br/>', $data['data']) . '</div>';
    $config_nt = array('content' => $txt_error, 'options' => array('type' => 'nf_error', 'cancel_button' => FALSE), 'style' => 'width: 80%; margin: 20px auto; text-align: left;');
    $nt = new Notification('nt_1', $config_nt);
    $nt->show();
} else {
    $scan_report = file_get_contents($scan_report_file);
    $scan_report = unserialize($scan_report);
    //Sensor context
    $ctx = $scan_report['sensor']['ctx'];
    session_write_close();
    $db = new ossim_db();
    $conn = $db->connect();
    $data = Av_scan::save_scan_report_in_db($conn, $scan_report, $_POST);
    //Check general status
    if (count($data['general']['hosts_in_group']) == 0) {
        $data['general']['status'] = 'error';
        $data['general']['data'] = _('Error! Assets could not be updated');
    } else {
        if (count($data['general']['hosts_in_group']) == $data['general']['total_hosts']) {
            $data['general']['status'] = 'success';
            $data['general']['data'] = _('Asset information succesfully updated');
            foreach ($data['by_host'] as $h_key => $h_data) {
                if ($h_data['status'] == 'warning') {
                    $data['general']['status'] = 'warning';
                    $data['general']['data'] = _('Asset information succesfully updated');
                    break;
                }
            }