Esempio n. 1
0
void license_send_new_license_request_packet(rdpLicense* license)
{
	STREAM* s;
	char* username;

	s = license_send_stream_init(license);

	if (license->rdp->settings->username != NULL)
		username = license->rdp->settings->username;
	else
		username = "******";

	license->client_user_name->data = (uint8*) username;
	license->client_user_name->length = strlen(username) + 1;

	license->client_machine_name->data = (uint8*) license->rdp->settings->client_hostname;
	license->client_machine_name->length = strlen(license->rdp->settings->client_hostname) + 1;

	license_write_new_license_request_packet(license, s);

	license_send(license, s, NEW_LICENSE_REQUEST);

	license->client_user_name->data = NULL;
	license->client_user_name->length = 0;

	license->client_machine_name->data = NULL;
	license->client_machine_name->length = 0;
}
Esempio n. 2
0
BOOL license_send_new_license_request_packet(rdpLicense* license)
{
	wStream* s;
	char* username;
	DEBUG_LICENSE("Sending New License Packet");
	s = license_send_stream_init(license);
	if (!s)
		return FALSE;

	if (license->rdp->settings->Username != NULL)
		username = license->rdp->settings->Username;
	else
		username = "******";

	license->ClientUserName->data = (BYTE*) username;
	license->ClientUserName->length = strlen(username) + 1;
	license->ClientMachineName->data = (BYTE*) license->rdp->settings->ClientHostname;
	license->ClientMachineName->length = strlen(license->rdp->settings->ClientHostname) + 1;
	if (!license_write_new_license_request_packet(license, s) ||
		!license_send(license, s, NEW_LICENSE_REQUEST))
	{
		return FALSE;
	}

	license->ClientUserName->data = NULL;
	license->ClientUserName->length = 0;
	license->ClientMachineName->data = NULL;
	license->ClientMachineName->length = 0;
	return TRUE;
}
Esempio n. 3
0
BOOL license_send_platform_challenge_response_packet(rdpLicense* license)
{
    wStream* s;
    int length;
    BYTE* buffer;
    WINPR_RC4_CTX* rc4;
    BYTE mac_data[16];
    BOOL status;

    DEBUG_LICENSE("Sending Platform Challenge Response Packet");
    s = license_send_stream_init(license);
    license->EncryptedPlatformChallenge->type = BB_DATA_BLOB;
    length = license->PlatformChallenge->length + HWID_LENGTH;

    buffer = (BYTE*) malloc(length);
    if (!buffer)
        return FALSE;

    CopyMemory(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
    CopyMemory(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
    status = security_mac_data(license->MacSaltKey, buffer, length, mac_data);
    free(buffer);

    if (!status)
        return FALSE;

    rc4 = winpr_RC4_New(license->LicensingEncryptionKey,
                        LICENSING_ENCRYPTION_KEY_LENGTH);
    if (!rc4)
        return FALSE;

    buffer = (BYTE*) malloc(HWID_LENGTH);
    if (!buffer)
        return FALSE;

    status = winpr_RC4_Update(rc4, HWID_LENGTH, license->HardwareId, buffer);
    winpr_RC4_Free(rc4);
    if (!status)
    {
        free(buffer);
        return FALSE;
    }

    license->EncryptedHardwareId->type = BB_DATA_BLOB;
    license->EncryptedHardwareId->data = buffer;
    license->EncryptedHardwareId->length = HWID_LENGTH;
#ifdef WITH_DEBUG_LICENSE
    WLog_DBG(TAG, "LicensingEncryptionKey:");
    winpr_HexDump(TAG, WLOG_DEBUG, license->LicensingEncryptionKey, 16);
    WLog_DBG(TAG, "HardwareId:");
    winpr_HexDump(TAG, WLOG_DEBUG, license->HardwareId, HWID_LENGTH);
    WLog_DBG(TAG, "EncryptedHardwareId:");
    winpr_HexDump(TAG, WLOG_DEBUG, license->EncryptedHardwareId->data, HWID_LENGTH);
#endif
    return license_write_platform_challenge_response_packet(license, s, mac_data) &&
           license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}
Esempio n. 4
0
BOOL license_send_valid_client_error_packet(rdpLicense* license)
{
	wStream* s;
	s = license_send_stream_init(license);
	DEBUG_LICENSE("Sending Error Alert Packet");
	Stream_Write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */
	Stream_Write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */
	license_write_binary_blob(s, license->ErrorInfo);
	return license_send(license, s, ERROR_ALERT);
}
Esempio n. 5
0
void license_send_platform_challenge_response_packet(rdpLicense* license)
{
	wStream* s;
	int length;
	BYTE* buffer;
	CryptoRc4 rc4;
	BYTE mac_data[16];

	DEBUG_LICENSE("Sending Platform Challenge Response Packet");

	s = license_send_stream_init(license);

	license->EncryptedPlatformChallenge->type = BB_DATA_BLOB;
	length = license->PlatformChallenge->length + HWID_LENGTH;

	buffer = (BYTE*) malloc(length);
	CopyMemory(buffer, license->PlatformChallenge->data, license->PlatformChallenge->length);
	CopyMemory(&buffer[license->PlatformChallenge->length], license->HardwareId, HWID_LENGTH);
	security_mac_data(license->MacSaltKey, buffer, length, mac_data);
	free(buffer);

	buffer = (BYTE*) malloc(HWID_LENGTH);
	rc4 = crypto_rc4_init(license->LicensingEncryptionKey, LICENSING_ENCRYPTION_KEY_LENGTH);
	if (!rc4)
	{
		fprintf(stderr, "%s: unable to allocate a rc4\n", __FUNCTION__);
		return;
	}
	crypto_rc4(rc4, HWID_LENGTH, license->HardwareId, buffer);
	crypto_rc4_free(rc4);

	license->EncryptedHardwareId->type = BB_DATA_BLOB;
	license->EncryptedHardwareId->data = buffer;
	license->EncryptedHardwareId->length = HWID_LENGTH;

#ifdef WITH_DEBUG_LICENSE
	fprintf(stderr, "LicensingEncryptionKey:\n");
	winpr_HexDump(license->LicensingEncryptionKey, 16);
	fprintf(stderr, "\n");

	fprintf(stderr, "HardwareId:\n");
	winpr_HexDump(license->HardwareId, HWID_LENGTH);
	fprintf(stderr, "\n");

	fprintf(stderr, "EncryptedHardwareId:\n");
	winpr_HexDump(license->EncryptedHardwareId->data, HWID_LENGTH);
	fprintf(stderr, "\n");
#endif

	license_write_platform_challenge_response_packet(license, s, mac_data);

	license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}
Esempio n. 6
0
BOOL license_send_valid_client_error_packet(rdpLicense* license)
{
	STREAM* s;

	s = license_send_stream_init(license);

	stream_write_UINT32(s, STATUS_VALID_CLIENT); /* dwErrorCode */
	stream_write_UINT32(s, ST_NO_TRANSITION); /* dwStateTransition */

	license_write_binary_blob(s, license->error_info);

	return license_send(license, s, ERROR_ALERT);
}
Esempio n. 7
0
void license_send_platform_challenge_response_packet(rdpLicense* license)
{
	STREAM* s;
	int length;
	uint8* buffer;
	CryptoRc4 rc4;
	uint8 mac_data[16];

	s = license_send_stream_init(license);
	DEBUG_LICENSE("Sending Platform Challenge Response Packet");

	license->encrypted_platform_challenge->type = BB_DATA_BLOB;
	length = license->platform_challenge->length + HWID_LENGTH;
	buffer = (uint8*) xmalloc(length);
	memcpy(buffer, license->platform_challenge->data, license->platform_challenge->length);
	memcpy(&buffer[license->platform_challenge->length], license->hwid, HWID_LENGTH);
	security_mac_data(license->mac_salt_key, buffer, length, mac_data);
	xfree(buffer);

	buffer = (uint8*) xmalloc(HWID_LENGTH);
	rc4 = crypto_rc4_init(license->licensing_encryption_key, LICENSING_ENCRYPTION_KEY_LENGTH);
	crypto_rc4(rc4, HWID_LENGTH, license->hwid, buffer);
	crypto_rc4_free(rc4);

#ifdef WITH_DEBUG_LICENSE
	printf("Licensing Encryption Key:\n");
	freerdp_hexdump(license->licensing_encryption_key, 16);

	printf("HardwareID:\n");
	freerdp_hexdump(license->hwid, 20);

	printf("Encrypted HardwareID:\n");
	freerdp_hexdump(buffer, 20);
#endif

	license->encrypted_hwid->type = BB_DATA_BLOB;
	license->encrypted_hwid->data = buffer;
	license->encrypted_hwid->length = HWID_LENGTH;

	license_write_platform_challenge_response_packet(license, s, mac_data);

	license_send(license, s, PLATFORM_CHALLENGE_RESPONSE);
}