Example #1
0
 static function validaToken()
 {
     $ip = Util::get_client_ip();
     $id = Util::getHeaderVarClient('idDevice');
     $tks = Util::getHeaderVarClient('tks-sec');
     $json = Util::decrypt($tks);
     $tk = json_decode($json, true);
     //print_r( $tk); exit;
     if ($ip == $tk['ip']) {
         return $tk['obj'];
     }
     if ($id == $tk['id'] && strlen($id) > 5) {
         return $tk['obj'];
     }
     return false;
 }
Example #2
0
 public function server($query)
 {
     $this->setQuery($query);
     $this->appId = $this->query['secret'];
     $this->secretKey = $this->fetchSecretKey($this->appId);
     $this->setPolicy(Util::decrypt($this->query['policy'], $this->secretKey));
     $this->setFile($this->query['key']);
     $error = 0;
     $funcs = array('checkSignature', 'checkPolicy', 'checkUpload', 'checkFile', 'checkImage', 'saveFile');
     foreach ($funcs as $func) {
         if (!$error) {
             $error = call_user_func(array($this, $func));
         }
     }
     $this->error = $error;
     return $this;
 }
Example #3
0
 public static function dencryptParser($w, $l)
 {
     if ($l == "load") {
         return Util::decrypt(base64_decode($w, true));
     }
     return base64_encode(Util::encrypt($w));
 }
 /**
  * Decriptografa um valor vindo do banco de dados
  * @param array $prop Array contendo as propriedades do campo
  * @param string $value O valor a ser decriptografado
  * @return string Valor decriptografado
  * @author Hugo Ferreira da Silva
  */
 function _getDecryptValue($prop, $value)
 {
     if (isset($prop['crypt']) && $prop['crypt'] == 'true') {
         LumineLog::Logger(1, 'Decriptografando o campo ' . $prop['name'], __FILE__, __LINE__);
         $value = Util::decrypt($value, $this);
         // o valor foi "escapado" antes de inserir/atualizar... tempos que retirar as contra-barras
         if (isset($this->oTable->config->config['escape']) && $this->oTable->config->config['escape'] == 1) {
             $value = stripslashes($value);
         }
     }
     return $value;
 }
Example #5
0
function deploy_agents($conn, $wizard)
{
    //Aux variable that is returned
    $data = array();
    //If we have already initialized the deploy, we return true to check the status
    $started = $wizard->get_step_data('deploy_initialized');
    if ($started === TRUE) {
        $response['error'] = FALSE;
        $response['data'] = $data;
        return $response;
    }
    //Retrieving the params
    $os = $wizard->get_step_data('deploy_os');
    $username = $wizard->get_step_data('deploy_username');
    $domain = $wizard->get_step_data('deploy_domain');
    //Getting the array of hosts
    $hosts = $wizard->get_step_data('deploy_hosts');
    $hosts = is_array($hosts) ? $hosts : array();
    //Getting the password and decrypting
    $password = $wizard->get_step_data('deploy_password');
    $password = Util::decrypt($password, Util::get_system_uuid());
    $total_ip = 0;
    //Performing linux deployment --> Agentless
    if ($os == 'linux') {
        $sensor_id = get_sensor_id();
        $deploy = 0;
        //Num of successful deployments --> Initially 0
        //Arguments for the agentless entries
        $arguments = '/etc /usr/bin /usr/sbin /bin /sbin';
        foreach ($hosts as $h) {
            $ips = Asset_host_ips::get_ips_to_string($conn, $h);
            $ips = explode(',', $ips);
            $hostname = Asset_host::get_name_by_id($conn, $h);
            foreach ($ips as $ip) {
                try {
                    //Adding Aggentless
                    Ossec_agentless::save_in_db($conn, $ip, $sensor_id, $hostname, $username, $password, '', FALSE, '');
                    //Adding Aggentless Entries
                    Ossec_agentless::add_monitoring_entry($conn, $ip, $sensor_id, 'ssh_integrity_check_bsd', 3600, 'periodic', $arguments);
                    Ossec_agentless::add_monitoring_entry($conn, $ip, $sensor_id, 'ssh_integrity_check_linux', 3600, 'periodic', $arguments);
                    $deploy++;
                } catch (Exception $e) {
                    Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
                }
                $total_ip++;
            }
        }
        //Saving the number of the successful deployments
        $wizard->set_step_data('deploy_success', $deploy);
    } elseif ($os == 'windows') {
        $jobs = array();
        foreach ($hosts as $h) {
            $ips = Asset_host_ips::get_ips_to_string($conn, $h);
            $ips = explode(',', $ips);
            foreach ($ips as $ip) {
                try {
                    //Adding job to deploy ossec.
                    $name = 'Windows-' . str_replace('.', '-', $ip);
                    $job = Welcome_wizard::launch_ossec_deploy($name, $ip, $username, $domain, $password);
                    $jid = md5($h . $ip);
                    $jobs[$jid] = array('job_id' => $job['job_id'], 'agent' => $name . '(' . $ip . ')');
                } catch (Exception $e) {
                    Av_exception::write_log(Av_exception::USER_ERROR, $e->getMessage());
                }
                $total_ip++;
            }
        }
        //Saving the jobs IDs in the wizard object
        $wizard->set_step_data('deploy_jobs', $jobs);
    }
    $total_ip = $total_ip > count($hosts) ? $total_ip : count($hosts);
    $data['total_ips'] = $total_ip;
    //Setting the total of ips.
    $wizard->set_step_data('deploy_total_ips', $total_ip);
    //Setting to true the flag that warns that the deploy has been already initialized.
    $wizard->set_step_data('deploy_initialized', TRUE);
    //Saving the wizard status
    $wizard->save_status();
    $response['error'] = FALSE;
    $response['data'] = $data;
    return $response;
}