Пример #1
0
static void
rdpsnd_process(STREAM s)
{
	uint16 len;

	while (!s_check_end(s))
	{
		/* New packet */
		if (packet.size == 0)
		{
			if ((s->end - s->p) < 4)
			{
				logger(Sound, Error,
				       "rdpsnd_process(), split at packet header, things will go south from here...");
				return;
			}
			in_uint8(s, packet_opcode);
			in_uint8s(s, 1);	/* Padding */
			in_uint16_le(s, len);

			logger(Sound, Debug, "rdpsnd_process(), Opcode = 0x%x Length= %d",
			       (int) packet_opcode, (int) len);

			packet.p = packet.data;
			packet.end = packet.data + len;
			packet.size = len;
		}
		else
		{
			len = MIN(s->end - s->p, packet.end - packet.p);

			/* Microsoft's server is so broken it's not even funny... */
			if (packet_opcode == SNDC_WAVE)
			{
				if ((packet.p - packet.data) < 12)
					len = MIN(len, 12 - (packet.p - packet.data));
				else if ((packet.p - packet.data) == 12)
				{
					logger(Sound, Debug,
					       "rdpsnd_process(), eating 4 bytes of %d bytes...",
					       len);
					in_uint8s(s, 4);
					len -= 4;
				}
			}

			in_uint8a(s, packet.p, len);
			packet.p += len;
		}

		/* Packet fully assembled */
		if (packet.p == packet.end)
		{
			packet.p = packet.data;
			rdpsnd_process_packet(packet_opcode, &packet);
			packet.size = 0;
		}
	}
}
Пример #2
0
static void
rdpsnd_process(STREAM s)
{
	uint16 len;

	while (!s_check_end(s))
	{
		/* New packet */
		if (packet.size == 0)
		{
			if ((s->end - s->p) < 4)
			{
				error("RDPSND: Split at packet header. Things will go south from here...\n");
				return;
			}
			in_uint8(s, packet_opcode);
			in_uint8s(s, 1);	/* Padding */
			in_uint16_le(s, len);

			DEBUG_SOUND(("RDPSND: == Opcode %x Length: %d ==\n",
				     (int) packet_opcode, (int) len));

			packet.p = packet.data;
			packet.end = packet.data + len;
			packet.size = len;
		}
		else
		{
			len = MIN(s->end - s->p, packet.end - packet.p);

			/* Microsoft's server is so broken it's not even funny... */
			if (packet_opcode == RDPSND_WRITE)
			{
				if ((packet.p - packet.data) < 12)
					len = MIN(len, 12 - (packet.p - packet.data));
				else if ((packet.p - packet.data) == 12)
				{
					DEBUG_SOUND(("RDPSND: Eating 4 bytes of %d bytes...\n",
						     len));
					in_uint8s(s, 4);
					len -= 4;
				}
			}

			in_uint8a(s, packet.p, len);
			packet.p += len;
		}

		/* Packet fully assembled */
		if (packet.p == packet.end)
		{
			packet.p = packet.data;
			rdpsnd_process_packet(packet_opcode, &packet);
			packet.size = 0;
		}
	}
}
Пример #3
0
/* Backpatch capability set header at the reference */
static void
rdp_out_capset_header(STREAM s, capsetHeaderRef header, uint16 capabilitySetType)
{
	struct stream tmp_s;

	ASSERT(header >= s->data);
	ASSERT(header < s->p);

	tmp_s.p = tmp_s.data = header;
	tmp_s.size = 4;
	tmp_s.end = tmp_s.data + tmp_s.size;
	out_uint16_le(&tmp_s, capabilitySetType); /* capabilitySetType */
	out_uint16_le(&tmp_s, s->p - header); /* lengthCapability */
	ASSERT(s_check_end(&tmp_s));
}
Пример #4
0
/* Parse an authentication request packet */
static BOOL
licence_parse_authreq(STREAM s, uint8 **token, uint8 **signature)
{
	uint16 tokenlen;

	in_uint8s(s, 6);	/* unknown: f8 3d 15 00 04 f6 */

	in_uint16_le(s, tokenlen);
	if (tokenlen != LICENCE_TOKEN_SIZE)
	{
		error("token len %d\n", tokenlen);
		return False;
	}

	in_uint8p(s, *token, tokenlen);
	in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);

	return s_check_end(s);
}
Пример #5
0
/* Parse an platform challenge request packet */
static RD_BOOL
licence_parse_platform_challenge(STREAM s, uint8 ** token, uint8 ** signature)
{
	uint16 tokenlen;

	in_uint8s(s, 6);	/* unknown: f8 3d 15 00 04 f6 */

	in_uint16_le(s, tokenlen);
	if (tokenlen != LICENCE_TOKEN_SIZE)
	{
		logger(Protocol, Error,
		       "license_parse_platform_challenge(), tokenlen != LICENSE_TOKEN_SIZE");
		return False;
	}

	in_uint8p(s, *token, tokenlen);
	in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);

	return s_check_end(s);
}
Пример #6
0
/* Parse a Server Platform Challenge packet */
static RD_BOOL
licence_parse_authreq(rdpLicence * licence, STREAM s, uint8 ** token, uint8 ** signature)
{
    uint16 tokenlen;

    in_uint8s(s, 4);	/* ConnectFlags (unused) */

    /* Licensing Binary BLOB with EncryptedPlatformChallenge: */
    in_uint8s(s, 2);	/* wBlobType (unused) */
    in_uint16_le(s, tokenlen);	/* wBlobLen */
    if (tokenlen != LICENCE_TOKEN_SIZE)
    {
        ui_error(licence->sec->rdp->inst, "token len %d\n", tokenlen);
        return False;
    }
    in_uint8p(s, *token, tokenlen);	/* RC4-encrypted challenge data */

    in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);	/* MACData for decrypted challenge data */

    return s_check_end(s);
}