20 |
|
|
21 |
#include "rdesktop.h" |
#include "rdesktop.h" |
22 |
|
|
23 |
extern uint16 mcs_userid; |
extern uint16 g_mcs_userid; |
24 |
extern char username[16]; |
extern char username[16]; |
25 |
extern BOOL bitmap_compression; |
extern BOOL bitmap_compression; |
26 |
extern BOOL orders; |
extern BOOL orders; |
100 |
|
|
101 |
out_uint16_le(s, length); |
out_uint16_le(s, length); |
102 |
out_uint16_le(s, (RDP_PDU_DATA | 0x10)); |
out_uint16_le(s, (RDP_PDU_DATA | 0x10)); |
103 |
out_uint16_le(s, (mcs_userid + 1001)); |
out_uint16_le(s, (g_mcs_userid + 1001)); |
104 |
|
|
105 |
out_uint32_le(s, rdp_shareid); |
out_uint32_le(s, rdp_shareid); |
106 |
out_uint8(s, 0); /* pad */ |
out_uint8(s, 0); /* pad */ |
140 |
int len_password = 2 * strlen(password); |
int len_password = 2 * strlen(password); |
141 |
int len_program = 2 * strlen(program); |
int len_program = 2 * strlen(program); |
142 |
int len_directory = 2 * strlen(directory); |
int len_directory = 2 * strlen(directory); |
143 |
|
int len_ip = 2 * strlen("127.0.0.1"); |
144 |
|
int len_dll = 2 * strlen("C:\\WINNT\\System32\\mstscax.dll"); |
145 |
|
int packetlen = 0; |
146 |
uint32 sec_flags = encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO; |
uint32 sec_flags = encryption ? (SEC_LOGON_INFO | SEC_ENCRYPT) : SEC_LOGON_INFO; |
147 |
STREAM s; |
STREAM s; |
148 |
|
|
168 |
} |
} |
169 |
else |
else |
170 |
{ |
{ |
171 |
|
flags |= RDP_LOGON_BLOB; |
172 |
DEBUG_RDP5(("Sending RDP5-style Logon packet\n")); |
DEBUG_RDP5(("Sending RDP5-style Logon packet\n")); |
173 |
s = sec_init(sec_flags, 12 + (flags & RDP_LOGON_AUTO ? 2 : 0) + 6 + (flags & RDP_LOGON_AUTO ? len_password : 0) + len_domain + len_user + 4 + len_program + len_directory + 30 + 2 + 60 + 32 + 20 + 32 + 20); /* Phew! */ |
packetlen = 4 + // Unknown uint32 |
174 |
|
4 + // flags |
175 |
|
2 + // len_domain |
176 |
|
2 + // len_user |
177 |
|
(flags & RDP_LOGON_AUTO ? 2 : 0) + // len_password |
178 |
|
(flags & RDP_LOGON_BLOB ? 2 : 0) + // Length of BLOB |
179 |
|
2 + // len_program |
180 |
|
2 + // len_directory |
181 |
|
(0 < len_domain ? len_domain : 2) + // domain |
182 |
|
len_user + (flags & RDP_LOGON_AUTO ? len_password : 0) + 0 + // We have no 512 byte BLOB. Perhaps we must? |
183 |
|
(flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO) ? 2 : 0) + // After the BLOB is a unknown int16. If there is a BLOB, that is. |
184 |
|
(0 < len_program ? len_program : 2) + (0 < len_directory ? len_directory : 2) + 2 + // Unknown (2) |
185 |
|
2 + // Client ip length |
186 |
|
len_ip + // Client ip |
187 |
|
2 + // DLL string length |
188 |
|
len_dll + // DLL string |
189 |
|
2 + // Unknown |
190 |
|
2 + // Unknown |
191 |
|
64 + // Time zone #0 |
192 |
|
2 + // Unknown |
193 |
|
64 + // Time zone #1 |
194 |
|
32; // Unknown |
195 |
|
|
196 |
out_uint32(s, 0); |
s = sec_init(sec_flags, packetlen); |
197 |
|
DEBUG_RDP5(("Called sec_init with packetlen %d\n", packetlen)); |
198 |
|
|
199 |
|
out_uint32(s, 0); // Unknown |
200 |
out_uint32_le(s, flags); |
out_uint32_le(s, flags); |
201 |
out_uint16_le(s, len_domain); |
out_uint16_le(s, len_domain); |
202 |
out_uint16_le(s, len_user); |
out_uint16_le(s, len_user); |
203 |
if (flags & RDP_LOGON_AUTO) |
if (flags & RDP_LOGON_AUTO) |
204 |
{ |
{ |
205 |
out_uint16_le(s, len_password); |
out_uint16_le(s, len_password); |
206 |
|
|
207 |
|
} |
208 |
|
if (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO)) |
209 |
|
{ |
210 |
|
out_uint16_le(s, 0); |
211 |
} |
} |
|
out_uint16(s, 0); /* Seems to be length of a 512 byte blob with |
|
|
completely unknown data, but hopefully we'll do |
|
|
with a 0 length block as well */ |
|
212 |
out_uint16_le(s, len_program); |
out_uint16_le(s, len_program); |
213 |
out_uint16_le(s, len_directory); |
out_uint16_le(s, len_directory); |
214 |
rdp_out_unistr(s, domain, len_domain); |
if (0 < len_domain) |
215 |
|
rdp_out_unistr(s, domain, len_domain); |
216 |
|
else |
217 |
|
out_uint16_le(s, 0); |
218 |
|
rdp_out_unistr(s, user, len_user); |
219 |
if (flags & RDP_LOGON_AUTO) |
if (flags & RDP_LOGON_AUTO) |
220 |
{ |
{ |
221 |
rdp_out_unistr(s, password, len_password); |
rdp_out_unistr(s, password, len_password); |
222 |
} |
} |
223 |
rdp_out_unistr(s, user, len_user); |
if (flags & RDP_LOGON_BLOB && !(flags & RDP_LOGON_AUTO)) |
224 |
out_uint16(s, 0); |
{ |
225 |
out_uint16(s, 0); |
out_uint16_le(s, 0); |
226 |
|
} |
227 |
if (0 < len_program) |
if (0 < len_program) |
228 |
|
{ |
229 |
rdp_out_unistr(s, program, len_program); |
rdp_out_unistr(s, program, len_program); |
230 |
|
|
231 |
|
} |
232 |
|
else |
233 |
|
{ |
234 |
|
out_uint16_le(s, 0); |
235 |
|
} |
236 |
if (0 < len_directory) |
if (0 < len_directory) |
237 |
|
{ |
238 |
rdp_out_unistr(s, directory, len_directory); |
rdp_out_unistr(s, directory, len_directory); |
239 |
out_uint8s(s, 30); /* Some kind of client data - let's see if the server |
} |
240 |
handles zeros well.. */ |
else |
241 |
out_uint16_le(s, 60); |
{ |
242 |
rdp_out_unistr(s, "C:\\WINNT\\System32\\mstscax.dll", 58); |
out_uint16_le(s, 0); |
243 |
out_uint32_be(s, 0x88ffffff); |
} |
244 |
rdp_out_unistr(s, "GTB, normaltid", 2 * strlen("GTB, normaltid") - 2); |
out_uint16_le(s, 2); |
245 |
out_uint8s(s, 30 - 2 * strlen("GTP, normaltid")); |
out_uint16_le(s, len_ip + 2); // Length of client ip |
246 |
|
rdp_out_unistr(s, "127.0.0.1", len_ip); |
247 |
|
out_uint16_le(s, len_dll + 2); |
248 |
|
rdp_out_unistr(s, "C:\\WINNT\\System32\\mstscax.dll", len_dll); |
249 |
|
out_uint16_le(s, 0xffc4); |
250 |
|
out_uint16_le(s, 0xffff); |
251 |
|
rdp_out_unistr(s, "GTB, normaltid", 2 * strlen("GTB, normaltid")); |
252 |
|
out_uint8s(s, 62 - 2 * strlen("GTB, normaltid")); |
253 |
|
|
254 |
|
|
255 |
out_uint32_le(s, 0x0a0000); |
out_uint32_le(s, 0x0a0000); |
256 |
out_uint32_le(s, 0x050000); |
out_uint32_le(s, 0x050000); |
257 |
out_uint32_le(s, 2); |
out_uint32_le(s, 3); |
258 |
out_uint32(s, 0); |
out_uint32_le(s, 0); |
259 |
out_uint32_le(s, 0xffffffc4); |
out_uint32_le(s, 0); |
|
out_uint32_le(s, 0xfffffffe); |
|
|
out_uint32_le(s, 0x0f); |
|
|
out_uint32(s, 0); |
|
260 |
|
|
261 |
rdp_out_unistr(s, "GTB, sommartid", 2 * strlen("GTB, sommartid") - 1); |
rdp_out_unistr(s, "GTB, sommartid", 2 * strlen("GTB, sommartid")); |
262 |
out_uint8s(s, 30 - 2 * strlen("GTP, sommartid")); |
out_uint8s(s, 62 - 2 * strlen("GTB, sommartid")); |
263 |
|
|
264 |
out_uint32_le(s, 0x030000); |
out_uint32_le(s, 0x30000); |
265 |
out_uint32_le(s, 0x050000); |
out_uint32_le(s, 0x050000); |
266 |
out_uint32_le(s, 2); |
out_uint32_le(s, 2); |
267 |
out_uint32(s, 0); |
out_uint32(s, 0); |
270 |
out_uint32_le(s, 0x0f); |
out_uint32_le(s, 0x0f); |
271 |
out_uint32(s, 0); |
out_uint32(s, 0); |
272 |
|
|
273 |
|
|
274 |
} |
} |
275 |
s_mark_end(s); |
s_mark_end(s); |
276 |
sec_send(s, sec_flags); |
sec_send(s, sec_flags); |
554 |
|
|
555 |
out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE)); |
out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE)); |
556 |
out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10)); /* Version 1 */ |
out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10)); /* Version 1 */ |
557 |
out_uint16_le(s, (mcs_userid + 1001)); |
out_uint16_le(s, (g_mcs_userid + 1001)); |
558 |
|
|
559 |
out_uint32_le(s, rdp_shareid); |
out_uint32_le(s, rdp_shareid); |
560 |
out_uint16_le(s, 0x3ea); /* userid */ |
out_uint16_le(s, 0x3ea); /* userid */ |
712 |
if (!compress) |
if (!compress) |
713 |
{ |
{ |
714 |
int y; |
int y; |
715 |
bmpdata = xmalloc(width * height * Bpp); |
bmpdata = (uint8 *) xmalloc(width * height * Bpp); |
716 |
for (y = 0; y < height; y++) |
for (y = 0; y < height; y++) |
717 |
{ |
{ |
718 |
in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)], |
in_uint8a(s, &bmpdata[(height - y - 1) * (width * Bpp)], |
735 |
in_uint8s(s, 4); /* line_size, final_size */ |
in_uint8s(s, 4); /* line_size, final_size */ |
736 |
} |
} |
737 |
in_uint8p(s, data, size); |
in_uint8p(s, data, size); |
738 |
bmpdata = xmalloc(width * height * Bpp); |
bmpdata = (uint8 *) xmalloc(width * height * Bpp); |
739 |
if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) |
if (bitmap_decompress(bmpdata, width, height, data, size, Bpp)) |
740 |
{ |
{ |
741 |
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); |
ui_paint_bitmap(left, top, cx, cy, width, height, bmpdata); |
762 |
in_uint16_le(s, map.ncolours); |
in_uint16_le(s, map.ncolours); |
763 |
in_uint8s(s, 2); /* pad */ |
in_uint8s(s, 2); /* pad */ |
764 |
|
|
765 |
map.colours = xmalloc(3 * map.ncolours); |
map.colours = (COLOURENTRY *) xmalloc(3 * map.ncolours); |
766 |
|
|
767 |
DEBUG(("PALETTE(c=%d)\n", map.ncolours)); |
DEBUG(("PALETTE(c=%d)\n", map.ncolours)); |
768 |
|
|
884 |
rdp_connect(char *server, uint32 flags, char *domain, char *password, |
rdp_connect(char *server, uint32 flags, char *domain, char *password, |
885 |
char *command, char *directory) |
char *command, char *directory) |
886 |
{ |
{ |
887 |
|
if (use_rdp5) |
888 |
|
channels_init(); |
889 |
|
|
890 |
if (!sec_connect(server, username)) |
if (!sec_connect(server, username)) |
891 |
return False; |
return False; |
892 |
|
|