Example #1
0
     if (!isset($_POST['ajax_validation_all']) || POST('ajax_validation_all') == FALSE) {
         if (!Token::verify('tk_form_task', REQUEST('token'))) {
             Token::show_error();
             exit;
         }
     }
 }
 $validation_errors = validate_form_fields('POST', $validate);
 if (empty($validation_errors['task_params'])) {
     if ($_SESSION['av_inventory_type'] == 'nmap') {
         $task_params = POST('task_params');
         $task_sensor = POST('task_sensor');
         if (!Asset_net::is_cidr_in_my_nets($conn, $task_params)) {
             $validation_errors['task_params'] = _('Network not allowed') . '. Check your asset filter. <br/>' . _('Entered value') . ": <strong>'" . Util::htmlentities($task_params) . "</strong>'";
         } else {
             if (!Asset_net::check_cidr_by_sensor($conn, $task_params, $task_sensor)) {
                 $validation_errors['task_params'] = _("You can't scan the specified network using this sensor");
             }
         }
     } elseif ($_SESSION['av_inventory_type'] == 'wmi') {
         //Format example: wmihost:ip_address;wmiuser:user;wmipass:pass
         $task_params = POST('task_params');
         $pattern = '/\\s*wmihost:(.*);wmiuser:(.*);wmipass:(.*)\\s*/';
         preg_match($pattern, $task_params, $matches);
         $wmi_host = trim($matches[1]);
         $wmi_user = trim($matches[2]);
         $wmi_pass = trim($matches[3]);
         ossim_clean_error();
         if (!ossim_valid($wmi_host, OSS_IP_ADDR, 'illegal:' . _('WMI Credentials'))) {
             ossim_clean_error();
             ossim_valid($wmi_host, OSS_HOST_NAME, 'illegal:' . _('WMI Credentials'));
Example #2
0
$sensor_id = POST('task_sensor');
$params = POST('task_params');
$frequency = POST('task_period');
$validation_errors = validate_form_fields('POST', $validate);
//Extra validations
if (empty($validation_errors)) {
    switch ($s_type) {
        case 'nmap':
            $db = new ossim_db();
            $conn = $db->connect();
            $params = POST('task_params');
            $sensor_id = POST('task_sensor');
            if (!Asset_net::is_cidr_in_my_nets($conn, $params)) {
                $validation_errors['task_params'] = sprintf(_("Error! The network %s is not allowed.  Please check your network settings"), Util::htmlentities($params));
            } else {
                if (!Asset_net::check_cidr_by_sensor($conn, $params, $sensor_id)) {
                    $validation_errors['task_params'] = _("You can't scan the specified network using this sensor");
                }
            }
            $db->close();
            break;
        case 'wmi':
            $pattern = '/\\s*wmihost:(.*);wmiuser:(.*);wmipass:(.*)\\s*/';
            preg_match($pattern, $params, $matches);
            $wmi_host = trim($matches[1]);
            $wmi_user = trim($matches[2]);
            $wmi_pass = trim($matches[3]);
            ossim_clean_error();
            if (!ossim_valid($wmi_host, OSS_IP_ADDR, 'illegal:' . _('WMI Host'))) {
                ossim_clean_error();
                ossim_valid($wmi_host, OSS_HOST_NAME, 'illegal:' . _('WMI Host'));