Handle RDP4-style logon packets.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 4 Feb 2005 01:28:06 +0000 (01:28 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 4 Feb 2005 01:28:06 +0000 (01:28 +0000)
rdp.c
secure.c

diff --git a/rdp.c b/rdp.c
index 11ed6f9..eafd3d0 100644 (file)
--- a/rdp.c
+++ b/rdp.c
@@ -132,6 +132,57 @@ rdp_out_unistr(STREAM s, char *string, int len)
        s->p += len;
 }
 
+/* Input a string in Unicode (uuuuuuugly, use iconv later) */
+void
+rdp_in_unistr(STREAM s, char *string, int len)
+{
+       int i = 0, j = 0;
+       len += 2;
+
+       while (i < len)
+       {
+               string[j++] = s->p[i];
+               i += 2;
+       }
+       
+       s->p += len;
+}
+
+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
+       
+       in_uint32_le(s, flags);  // 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 (!s_check_end(s))
+               error("Unknown data at end of logon packet!");
+}
 
 /* Send a control PDU */
 static void
index 9147cbc..3e0b17f 100644 (file)
--- a/secure.c
+++ b/secure.c
@@ -743,7 +743,7 @@ sec_recv(void)
                        if (sec_flags & SEC_LOGON_INFO) 
                        {
                                printf("Received logon packet!\n");
-
+                               rdp_get_logon_info(s);
                        }
                }