From 7772d71ffd742cfc9b7ff214659d16c5bb56a391 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 5 Feb 2005 00:38:27 +0000 Subject: [PATCH 1/1] Support RDP5 logon packets. --- mcs.c | 4 +- rdp.c | 121 +++++++++++++++++++++++++++++++++++++++++++------------ rdpsrv.c | 2 + 3 files changed, 100 insertions(+), 27 deletions(-) diff --git a/mcs.c b/mcs.c index 7d70e75..5f4fe20 100644 --- a/mcs.c +++ b/mcs.c @@ -205,10 +205,10 @@ mcs_send_connect_response() out_uint8s(s, 21); // ick out_uint8(s, 0); - // server info -- we claim to support RDP1 + // server info -- we claim to support RDP5 out_uint16_le(s, SEC_TAG_SRV_INFO); out_uint16_le(s, 6); // length - out_uint16_le(s, 1); + out_uint16_le(s, 5); // crypto info out_uint16_le(s, SEC_TAG_SRV_CRYPT); diff --git a/rdp.c b/rdp.c index 56a0f7c..39d2ce8 100644 --- a/rdp.c +++ b/rdp.c @@ -171,41 +171,112 @@ void rdp_send_bitmap_update(unsigned x, unsigned y, unsigned width, unsigned hei rdp_send_data(s, RDP_DATA_PDU_UPDATE); } +#define EXPECT16(value) { in_uint16_le(s, unknown); if (unknown != (value)) printf("Unknown value on code line %u; expected 0x%x, got 0x%x\n", __LINE__, (value), unknown); } +#define EXPECT32(value) { in_uint32_le(s, unknown); if (unknown != (value)) printf("Unknown value on code line %u; expected 0x%x, got 0x%x\n", __LINE__, (value), unknown); } void rdp_get_logon_info(STREAM s) { - uint32 flags; - int len_domain, len_user, len_password, len_program, len_directory; - char domain[256], user[256], password[256], program[256], directory[256]; // FIXME + uint32 flags, unknown; + uint16 tzone_major, tzone_minor; + int len_domain, len_user, len_password, len_program, len_directory, len_ip, len_dll; + char domain[256], user[256], password[256], program[256], directory[256], ip[256], dll[256], tz1[256], tz2[256]; // FIXME - in_uint32_le(s, flags); // unknown + in_uint32_le(s, unknown); in_uint32_le(s, flags); - - if (flags & RDP_LOGON_BLOB) - error("got RDP5-style logon packet, can't handle this yet"); - + printf("logon flags: %x\n", flags); - in_uint16_le(s, len_domain); - in_uint16_le(s, len_user); - in_uint16_le(s, len_password); - in_uint16_le(s, len_program); - in_uint16_le(s, len_directory); - rdp_in_unistr(s, domain, len_domain); - rdp_in_unistr(s, user, len_user); - rdp_in_unistr(s, password, len_password); - rdp_in_unistr(s, program, len_program); - rdp_in_unistr(s, directory, len_directory); - - printf("domain='%s'\n", domain); - printf("user='%s'\n", user); - printf("password='%s'\n", password); - printf("program='%s'\n", program); - printf("directory='%s'\n", directory); + if (flags & RDP_LOGON_BLOB) { + printf("RDP5-style logon packet\n"); + + in_uint16_le(s, len_domain); + in_uint16_le(s, len_user); + + if (flags & RDP_LOGON_AUTO) { + in_uint16_le(s, len_password); + } else { + strcpy(password, ""); + } + if (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO)) { + // is this too some kind of length? + EXPECT16(0); + } + in_uint16_le(s, len_program); + in_uint16_le(s, len_directory); + + rdp_in_unistr(s, domain, len_domain); + rdp_in_unistr(s, user, len_user); + + if (flags & RDP_LOGON_AUTO) + rdp_in_unistr(s, password, len_password); + + if (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO)) + EXPECT16(0); + + rdp_in_unistr(s, program, len_program); + rdp_in_unistr(s, directory, len_directory); + + EXPECT16(2); + + in_uint16_le(s, len_ip); + rdp_in_unistr(s, ip, len_ip - 2); + + in_uint16_le(s, len_dll); + rdp_in_unistr(s, dll, len_dll - 2); + + in_uint16_le(s, tzone_major); + in_uint16_le(s, tzone_minor); + + // time zone names? + rdp_in_unistr(s, tz1, 62); + EXPECT32(0x0a0000); + EXPECT32(0x050000); + EXPECT32(3); + EXPECT32(0); + EXPECT32(0); + + rdp_in_unistr(s, tz2, 62); + EXPECT32(0x030000); + EXPECT32(0x050000); + EXPECT32(2); + EXPECT32(0); + EXPECT32(0xffffffc4); + EXPECT32(0xfffffffe); + EXPECT32(0x0f); + EXPECT32(0); + + printf("domain='%s'\n", domain); + printf("user='%s'\n", user); + printf("password='%s'\n", password); + printf("program='%s'\n", program); + printf("directory='%s'\n", directory); + printf("ip='%s'\n", ip); + printf("dll='%s'\n", dll); + printf("timezone=%d:%02d\n", tzone_major, tzone_minor); + printf("tz1='%64s'\n", tz1); + printf("tz2='%64s'\n", tz2); + } else { + in_uint16_le(s, len_domain); + in_uint16_le(s, len_user); + in_uint16_le(s, len_password); + in_uint16_le(s, len_program); + in_uint16_le(s, len_directory); + rdp_in_unistr(s, domain, len_domain); + rdp_in_unistr(s, user, len_user); + rdp_in_unistr(s, password, len_password); + rdp_in_unistr(s, program, len_program); + rdp_in_unistr(s, directory, len_directory); + + printf("domain='%s'\n", domain); + printf("user='%s'\n", user); + printf("password='%s'\n", password); + printf("program='%s'\n", program); + printf("directory='%s'\n", directory); + } if (!s_check_end(s)) - error("Unknown data at end of logon packet!"); + error("Unknown data at end of logon packet!\n"); } /* Send a control PDU */ diff --git a/rdpsrv.c b/rdpsrv.c index 94f2099..0251a2a 100644 --- a/rdpsrv.c +++ b/rdpsrv.c @@ -140,6 +140,8 @@ void handle_input_pdu(STREAM s, int vnc_sock) mouse1_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x01 : 0; if (device_flags & MOUSE_FLAG_BUTTON2) mouse2_down = (device_flags & MOUSE_FLAG_DOWN) ? 0x02 : 0; + + printf("button mask = %x\n", mouse1_down | mouse2_down); buf[0] = 5; // message type buf[1] = mouse1_down | mouse2_down; // button mask -- 2.39.5