* @return Packet populated with MCS data
*/
public RdpPackage sendMcsData() {
// logger.debug("Secure.sendMcsData");
RdpPackage buffer = new RdpPackage(512);
int hostlen = 2 * (RDPConnection.conf.hostname == null ? 0 : RDPConnection.conf.hostname.length());
if (hostlen > 30) {
hostlen = 30;
}
int length = 158;
if (RDPConnection.conf.use_rdp5) {
length += 76 + 12 + 4;
}
if (RDPConnection.conf.use_rdp5 && (channels.num_channels() > 0)) {
length += channels.num_channels() * 12 + 8;
}
buffer.setBigEndian16(5); /* unknown */
buffer.setBigEndian16(0x14);
buffer.set8(0x7c);
buffer.setBigEndian16(1);
buffer.setBigEndian16(length | 0x8000); // remaining length
buffer.setBigEndian16(8); // length?
buffer.setBigEndian16(16);
buffer.set8(0);
buffer.setLittleEndian16(0xc001);
buffer.set8(0);
buffer.setLittleEndian32(0x61637544); // "Duca" ?!
buffer.setBigEndian16(length - 14 | 0x8000); // remaining length
// Client information
buffer.setLittleEndian16(SEC_TAG_CLI_INFO);
buffer.setLittleEndian16(RDPConnection.conf.use_rdp5 ? 212 : 136); // length
buffer.setLittleEndian16(RDPConnection.conf.use_rdp5 ? 4 : 1);
buffer.setLittleEndian16(8);
buffer.setLittleEndian16(RDPConnection.conf.width);
buffer.setLittleEndian16(RDPConnection.conf.height);
buffer.setLittleEndian16(0xca01);
buffer.setLittleEndian16(0xaa03);
buffer.setLittleEndian32(RDPConnection.conf.keylayout);
buffer.setLittleEndian32(RDPConnection.conf.use_rdp5 ? 2600 : 419); // or 0ece // client build? we are 2600 compatible :-)
/* Unicode name of client, padded to 32 bytes */
buffer.outUnicodeString(RDPConnection.conf.hostname.toUpperCase(), hostlen);
buffer.incrementPosition(30 - hostlen);
buffer.setLittleEndian32(4);
buffer.setLittleEndian32(0);
buffer.setLittleEndian32(12);
buffer.incrementPosition(64); /* reserved? 4 + 12 doublewords */
buffer.setLittleEndian16(0xca01); // out_uint16_le(s, 0xca01);
buffer.setLittleEndian16(RDPConnection.conf.use_rdp5 ? 1 : 0);
if (RDPConnection.conf.use_rdp5) {
buffer.setLittleEndian32(0); // out_uint32(s, 0);
buffer.set8(RDPConnection.conf.server_bpp); // out_uint8(s, g_server_bpp);
buffer.setLittleEndian16(0x0700); // out_uint16_le(s, 0x0700);
buffer.set8(0); // out_uint8(s, 0);
buffer.setLittleEndian32(1); // out_uint32_le(s, 1);
buffer.incrementPosition(64);
buffer.setLittleEndian16(SEC_TAG_CLI_4); // out_uint16_le(s, SEC_TAG_CLI_4);
buffer.setLittleEndian16(12); // out_uint16_le(s, 12);
buffer.setLittleEndian32(RDPConnection.conf.console_session ? 0xb : 0xd); // out_uint32_le(s, g_console_session ? 0xb : 9);
buffer.setLittleEndian32(0); // out_uint32(s, 0);
}
// Client encryption settings //
buffer.setLittleEndian16(SEC_TAG_CLI_CRYPT);
buffer.setLittleEndian16(RDPConnection.conf.use_rdp5 ? 12 : 8); // length
//if(RDPConnection.conf.use_rdp5) buffer.setLittleEndian32(RDPConnection.conf.encryption ? 0x1b : 0); // 128-bit encryption supported
//else
buffer.setLittleEndian32(RDPConnection.conf.encryption ? (RDPConnection.conf.console_session ? 0xb : 0x3) : 0);
if (RDPConnection.conf.use_rdp5) {
buffer.setLittleEndian32(0); // unknown
}
if (RDPConnection.conf.use_rdp5 && (channels.num_channels() > 0)) {
// logger.debug(("num_channels is " + channels.num_channels()));
buffer.setLittleEndian16(SEC_TAG_CLI_CHANNELS); // out_uint16_le(s, SEC_TAG_CLI_CHANNELS);
buffer.setLittleEndian16(channels.num_channels() * 12 + 8); // out_uint16_le(s, g_num_channels * 12 + 8); // length
buffer.setLittleEndian32(channels.num_channels()); // out_uint32_le(s, g_num_channels); // number of virtual channels
for (int i = 0; i < channels.num_channels(); i++) {
// logger.debug(("Requesting channel " + channels.channel(i).name()));
buffer.out_uint8p(channels.channel(i).name(), 8); // out_uint8a(s, g_channels[i].name, 8);
buffer.setBigEndian32(channels.channel(i).flags()); // out_uint32_be(s, g_channels[i].flags);
}
}
buffer.markEnd();
return buffer;
}