示例#1
0
/* Process a Server Platform Challenge packet */
static void
licence_process_platform_challenge(rdpLicence * licence, STREAM s)
{
    uint8 *in_token = NULL, *in_sig;
    uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE];
    uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];
    uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
    uint8 out_sig[LICENCE_SIGNATURE_SIZE];
    CryptoRc4 crypt_key;

    /* Parse incoming packet and save the encrypted token */
    licence_parse_authreq(licence, s, &in_token, &in_sig);
    memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);

    /* Decrypt the token. It should read TEST in Unicode. */
    crypt_key = crypto_rc4_init(licence->licence_key, 16);
    crypto_rc4(crypt_key, LICENCE_TOKEN_SIZE, in_token, decrypt_token);
    crypto_rc4_free(crypt_key);

    /* Generate a signature for a buffer of token and HWID */
    licence_generate_hwid(licence, hwid);
    memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);
    memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);
    sec_sign(out_sig, 16, licence->licence_sign_key, 16, sealed_buffer, sizeof(sealed_buffer));

    /* Now encrypt the HWID */
    crypt_key = crypto_rc4_init(licence->licence_key, 16);
    crypto_rc4(crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);
    crypto_rc4_free(crypt_key);

    licence_send_authresp(licence, out_token, crypt_hwid, out_sig);
}
示例#2
0
/* Process an authentication request packet */
static void
licence_process_authreq(RDPCLIENT * This, STREAM s)
{
	uint8 *in_token, *in_sig;
	uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE];
	uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];
	uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
	uint8 out_sig[LICENCE_SIGNATURE_SIZE];
	RC4_KEY crypt_key;

	/* Parse incoming packet and save the encrypted token */
	licence_parse_authreq(s, &in_token, &in_sig);
	memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);

	/* Decrypt the token. It should read TEST in Unicode. */
	RC4_set_key(&crypt_key, 16, This->licence.key);
	RC4(&crypt_key, LICENCE_TOKEN_SIZE, in_token, decrypt_token);

	/* Generate a signature for a buffer of token and HWID */
	licence_generate_hwid(This, hwid);
	memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);
	memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);
	sec_sign(out_sig, 16, This->licence.sign_key, 16, sealed_buffer, sizeof(sealed_buffer));

	/* Now encrypt the HWID */
	RC4_set_key(&crypt_key, 16, This->licence.key);
	RC4(&crypt_key, LICENCE_HWID_SIZE, hwid, crypt_hwid);

	licence_send_authresp(This, out_token, crypt_hwid, out_sig);
}
示例#3
0
/* Process an authentication request packet */
static void
licence_process_authreq(STREAM s)
{
	uint8 *in_token = NULL, *in_sig;
	uint8 out_token[LICENCE_TOKEN_SIZE], decrypt_token[LICENCE_TOKEN_SIZE];
	uint8 hwid[LICENCE_HWID_SIZE], crypt_hwid[LICENCE_HWID_SIZE];
	uint8 sealed_buffer[LICENCE_TOKEN_SIZE + LICENCE_HWID_SIZE];
	uint8 out_sig[LICENCE_SIGNATURE_SIZE];
	void * crypt_key;

	/* Parse incoming packet and save the encrypted token */
	licence_parse_authreq(s, &in_token, &in_sig);
	memcpy(out_token, in_token, LICENCE_TOKEN_SIZE);

	/* Decrypt the token. It should read TEST in Unicode. */
	crypt_key = ssl_rc4_info_create();
	ssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
	ssl_rc4_crypt(crypt_key, (char *)in_token, (char *)decrypt_token, LICENCE_TOKEN_SIZE);
	ssl_rc4_info_delete(crypt_key);
	
	/* Generate a signature for a buffer of token and HWID */
	licence_generate_hwid(hwid);
	memcpy(sealed_buffer, decrypt_token, LICENCE_TOKEN_SIZE);
	memcpy(sealed_buffer + LICENCE_TOKEN_SIZE, hwid, LICENCE_HWID_SIZE);
	sec_sign(out_sig, 16, g_licence_sign_key, 16, sealed_buffer, sizeof(sealed_buffer));

	/* Now encrypt the HWID */
	crypt_key = ssl_rc4_info_create();
	ssl_rc4_set_key(crypt_key, (char *)g_licence_key, 16);
	ssl_rc4_crypt(crypt_key, (char *)hwid, (char *)crypt_hwid, LICENCE_HWID_SIZE);
	ssl_rc4_info_delete(crypt_key);

	licence_send_authresp(out_token, crypt_hwid, out_sig);
}