2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Client
|
|
|
|
* RDP Client Info
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-02-16 10:53:58 +04:00
|
|
|
#include "timezone.h"
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
#include "info.h"
|
|
|
|
|
2011-07-25 21:42:14 +04:00
|
|
|
#define INFO_TYPE_LOGON 0x00000000
|
|
|
|
#define INFO_TYPE_LOGON_LONG 0x00000001
|
|
|
|
#define INFO_TYPE_LOGON_PLAIN_NOTIFY 0x00000002
|
|
|
|
#define INFO_TYPE_LOGON_EXTENDED_INF 0x00000003
|
|
|
|
|
2011-11-30 05:15:50 +04:00
|
|
|
/*
|
|
|
|
static const char* const INFO_TYPE_LOGON_STRINGS[] =
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
|
|
|
"Logon Info V1",
|
|
|
|
"Logon Info V2",
|
|
|
|
"Logon Plain Notify",
|
|
|
|
"Logon Extended Info"
|
|
|
|
};
|
2011-11-30 05:15:50 +04:00
|
|
|
*/
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
2011-07-25 21:42:14 +04:00
|
|
|
* Read Server Auto Reconnect Cookie (ARC_SC_PRIVATE_PACKET).\n
|
|
|
|
* @msdn{cc240540}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
void rdp_read_server_auto_reconnect_cookie(STREAM* s, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
ARC_SC_PRIVATE_PACKET* autoReconnectCookie;
|
2012-01-14 23:42:36 +04:00
|
|
|
autoReconnectCookie = settings->server_auto_reconnect_cookie;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
stream_read_uint32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
|
|
|
stream_read_uint32(s, autoReconnectCookie->version); /* version (4 bytes) */
|
|
|
|
stream_read_uint32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */
|
|
|
|
stream_read(s, autoReconnectCookie->arcRandomBits, 16); /* arcRandomBits (16 bytes) */
|
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Client Auto Reconnect Cookie (ARC_CS_PRIVATE_PACKET).\n
|
|
|
|
* @msdn{cc240541}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
boolean rdp_read_client_auto_reconnect_cookie(STREAM* s, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
ARC_CS_PRIVATE_PACKET* autoReconnectCookie;
|
2012-01-14 23:42:36 +04:00
|
|
|
autoReconnectCookie = settings->client_auto_reconnect_cookie;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
|
|
|
if (stream_get_left(s) < 28)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-03-16 23:47:34 +04:00
|
|
|
stream_read_uint32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
|
|
|
stream_read_uint32(s, autoReconnectCookie->version); /* version (4 bytes) */
|
|
|
|
stream_read_uint32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */
|
|
|
|
stream_read(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-25 21:42:14 +04:00
|
|
|
/**
|
|
|
|
* Write Client Auto Reconnect Cookie (ARC_CS_PRIVATE_PACKET).\n
|
2011-07-12 02:46:36 +04:00
|
|
|
* @msdn{cc240541}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
2011-07-25 21:42:14 +04:00
|
|
|
void rdp_write_client_auto_reconnect_cookie(STREAM* s, rdpSettings* settings)
|
2011-07-12 02:46:36 +04:00
|
|
|
{
|
|
|
|
ARC_CS_PRIVATE_PACKET* autoReconnectCookie;
|
2012-01-14 23:42:36 +04:00
|
|
|
autoReconnectCookie = settings->client_auto_reconnect_cookie;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
stream_write_uint32(s, autoReconnectCookie->cbLen); /* cbLen (4 bytes) */
|
|
|
|
stream_write_uint32(s, autoReconnectCookie->version); /* version (4 bytes) */
|
|
|
|
stream_write_uint32(s, autoReconnectCookie->logonId); /* LogonId (4 bytes) */
|
|
|
|
stream_write(s, autoReconnectCookie->securityVerifier, 16); /* SecurityVerifier */
|
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Extended Info Packet (TS_EXTENDED_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240476}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
boolean rdp_read_extended_info_packet(STREAM* s, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
uint16 clientAddressFamily;
|
|
|
|
uint16 cbClientAddress;
|
|
|
|
uint16 cbClientDir;
|
|
|
|
uint16 cbAutoReconnectLen;
|
|
|
|
|
|
|
|
stream_read_uint16(s, clientAddressFamily); /* clientAddressFamily */
|
|
|
|
stream_read_uint16(s, cbClientAddress); /* cbClientAddress */
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
settings->ipv6 = (clientAddressFamily == ADDRESS_FAMILY_INET6 ? true : false);
|
2011-08-20 14:22:14 +04:00
|
|
|
if (stream_get_left(s) < cbClientAddress)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
settings->ip_address = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbClientAddress);
|
|
|
|
stream_seek(s, cbClientAddress);
|
|
|
|
|
|
|
|
stream_read_uint16(s, cbClientDir); /* cbClientDir */
|
|
|
|
if (stream_get_left(s) < cbClientDir)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-25 09:45:43 +04:00
|
|
|
if (settings->client_dir)
|
|
|
|
xfree(settings->client_dir);
|
2011-08-20 14:22:14 +04:00
|
|
|
settings->client_dir = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbClientDir);
|
|
|
|
stream_seek(s, cbClientDir);
|
|
|
|
|
|
|
|
if (!rdp_read_client_time_zone(s, settings))
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
|
|
|
stream_seek_uint32(s); /* clientSessionId, should be set to 0 */
|
|
|
|
stream_read_uint32(s, settings->performance_flags); /* performanceFlags */
|
|
|
|
|
|
|
|
stream_read_uint16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */
|
|
|
|
|
|
|
|
if (cbAutoReconnectLen > 0)
|
|
|
|
return rdp_read_client_auto_reconnect_cookie(s, settings); /* autoReconnectCookie */
|
|
|
|
|
|
|
|
/* reserved1 (2 bytes) */
|
|
|
|
/* reserved2 (2 bytes) */
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* Write Extended Info Packet (TS_EXTENDED_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240476}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
size_t length;
|
|
|
|
uint16 clientAddressFamily;
|
|
|
|
uint8* clientAddress;
|
|
|
|
uint16 cbClientAddress;
|
|
|
|
uint8* clientDir;
|
|
|
|
uint16 cbClientDir;
|
|
|
|
uint16 cbAutoReconnectLen;
|
|
|
|
|
|
|
|
clientAddressFamily = settings->ipv6 ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET;
|
|
|
|
|
2012-01-14 23:42:36 +04:00
|
|
|
clientAddress = (uint8*) freerdp_uniconv_out(settings->uniconv, settings->ip_address, &length);
|
2011-07-12 02:46:36 +04:00
|
|
|
cbClientAddress = length;
|
|
|
|
|
2012-01-14 23:42:36 +04:00
|
|
|
clientDir = (uint8*) freerdp_uniconv_out(settings->uniconv, settings->client_dir, &length);
|
2011-07-12 02:46:36 +04:00
|
|
|
cbClientDir = length;
|
|
|
|
|
2012-01-14 23:42:36 +04:00
|
|
|
cbAutoReconnectLen = settings->client_auto_reconnect_cookie->cbLen;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
stream_write_uint16(s, clientAddressFamily); /* clientAddressFamily */
|
|
|
|
|
|
|
|
stream_write_uint16(s, cbClientAddress + 2); /* cbClientAddress */
|
|
|
|
|
|
|
|
if (cbClientAddress > 0)
|
|
|
|
stream_write(s, clientAddress, cbClientAddress); /* clientAddress */
|
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
stream_write_uint16(s, cbClientDir + 2); /* cbClientDir */
|
|
|
|
|
|
|
|
if (cbClientDir > 0)
|
|
|
|
stream_write(s, clientDir, cbClientDir); /* clientDir */
|
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
rdp_write_client_time_zone(s, settings); /* clientTimeZone */
|
|
|
|
|
|
|
|
stream_write_uint32(s, 0); /* clientSessionId, should be set to 0 */
|
|
|
|
stream_write_uint32(s, settings->performance_flags); /* performanceFlags */
|
|
|
|
|
|
|
|
stream_write_uint16(s, cbAutoReconnectLen); /* cbAutoReconnectLen */
|
|
|
|
|
|
|
|
if (cbAutoReconnectLen > 0)
|
2011-07-25 21:42:14 +04:00
|
|
|
rdp_write_client_auto_reconnect_cookie(s, settings); /* autoReconnectCookie */
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
/* reserved1 (2 bytes) */
|
|
|
|
/* reserved2 (2 bytes) */
|
|
|
|
|
|
|
|
xfree(clientAddress);
|
|
|
|
xfree(clientDir);
|
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Info Packet (TS_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240475}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
boolean rdp_read_info_packet(STREAM* s, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
uint32 flags;
|
|
|
|
uint16 cbDomain;
|
|
|
|
uint16 cbUserName;
|
|
|
|
uint16 cbPassword;
|
|
|
|
uint16 cbAlternateShell;
|
|
|
|
uint16 cbWorkingDir;
|
|
|
|
|
|
|
|
stream_seek_uint32(s); /* CodePage */
|
|
|
|
stream_read_uint32(s, flags); /* flags */
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
settings->autologon = ((flags & INFO_AUTOLOGON) ? true : false);
|
|
|
|
settings->remote_app = ((flags & INFO_RAIL) ? true : false);
|
|
|
|
settings->console_audio = ((flags & INFO_REMOTECONSOLEAUDIO) ? true : false);
|
|
|
|
settings->compression = ((flags & INFO_COMPRESSION) ? true : false);
|
2011-08-20 14:22:14 +04:00
|
|
|
|
|
|
|
stream_read_uint16(s, cbDomain); /* cbDomain */
|
|
|
|
stream_read_uint16(s, cbUserName); /* cbUserName */
|
|
|
|
stream_read_uint16(s, cbPassword); /* cbPassword */
|
|
|
|
stream_read_uint16(s, cbAlternateShell); /* cbAlternateShell */
|
|
|
|
stream_read_uint16(s, cbWorkingDir); /* cbWorkingDir */
|
|
|
|
|
|
|
|
if (stream_get_left(s) < cbDomain + 2)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbDomain > 0)
|
|
|
|
{
|
|
|
|
settings->domain = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbDomain);
|
|
|
|
stream_seek(s, cbDomain);
|
|
|
|
}
|
|
|
|
stream_seek(s, 2);
|
|
|
|
|
|
|
|
if (stream_get_left(s) < cbUserName + 2)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbUserName > 0)
|
|
|
|
{
|
|
|
|
settings->username = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbUserName);
|
|
|
|
stream_seek(s, cbUserName);
|
|
|
|
}
|
|
|
|
stream_seek(s, 2);
|
|
|
|
|
|
|
|
if (stream_get_left(s) < cbPassword + 2)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbPassword > 0)
|
|
|
|
{
|
|
|
|
settings->password = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbPassword);
|
|
|
|
stream_seek(s, cbPassword);
|
|
|
|
}
|
|
|
|
stream_seek(s, 2);
|
|
|
|
|
|
|
|
if (stream_get_left(s) < cbAlternateShell + 2)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbAlternateShell > 0)
|
|
|
|
{
|
|
|
|
settings->shell = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbAlternateShell);
|
|
|
|
stream_seek(s, cbAlternateShell);
|
|
|
|
}
|
|
|
|
stream_seek(s, 2);
|
|
|
|
|
|
|
|
if (stream_get_left(s) < cbWorkingDir + 2)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
if (cbWorkingDir > 0)
|
|
|
|
{
|
|
|
|
settings->directory = freerdp_uniconv_in(settings->uniconv, stream_get_tail(s), cbWorkingDir);
|
|
|
|
stream_seek(s, cbWorkingDir);
|
|
|
|
}
|
|
|
|
stream_seek(s, 2);
|
|
|
|
|
|
|
|
if (settings->rdp_version >= 5)
|
|
|
|
return rdp_read_extended_info_packet(s, settings); /* extraInfo */
|
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-08-20 14:22:14 +04:00
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* Write Info Packet (TS_INFO_PACKET).\n
|
|
|
|
* @msdn{cc240475}
|
|
|
|
* @param s stream
|
|
|
|
* @param settings settings
|
|
|
|
*/
|
|
|
|
|
|
|
|
void rdp_write_info_packet(STREAM* s, rdpSettings* settings)
|
|
|
|
{
|
|
|
|
size_t length;
|
|
|
|
uint32 flags;
|
|
|
|
uint8* domain;
|
|
|
|
uint16 cbDomain;
|
|
|
|
uint8* userName;
|
|
|
|
uint16 cbUserName;
|
|
|
|
uint8* password;
|
|
|
|
uint16 cbPassword;
|
|
|
|
uint8* alternateShell;
|
|
|
|
uint16 cbAlternateShell;
|
|
|
|
uint8* workingDir;
|
|
|
|
uint16 cbWorkingDir;
|
2012-02-01 20:58:06 +04:00
|
|
|
boolean usedPasswordCookie = false;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
flags = INFO_MOUSE |
|
|
|
|
INFO_UNICODE |
|
|
|
|
INFO_LOGONERRORS |
|
|
|
|
INFO_LOGONNOTIFY |
|
|
|
|
INFO_MAXIMIZESHELL |
|
|
|
|
INFO_ENABLEWINDOWSKEY |
|
2012-03-13 13:05:14 +04:00
|
|
|
INFO_DISABLECTRLALTDEL;
|
|
|
|
|
|
|
|
if (settings->audio_capture)
|
|
|
|
flags |= RNS_INFO_AUDIOCAPTURE;
|
|
|
|
|
|
|
|
if (!settings->audio_playback)
|
|
|
|
flags |= INFO_NOAUDIOPLAYBACK;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
|
|
|
if (settings->autologon)
|
|
|
|
flags |= INFO_AUTOLOGON;
|
|
|
|
|
2011-08-08 23:06:07 +04:00
|
|
|
if (settings->remote_app)
|
|
|
|
flags |= INFO_RAIL;
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
if (settings->console_audio)
|
|
|
|
flags |= INFO_REMOTECONSOLEAUDIO;
|
|
|
|
|
|
|
|
if (settings->compression)
|
2012-03-21 21:18:40 +04:00
|
|
|
flags |= INFO_COMPRESSION | INFO_PACKET_COMPR_TYPE_RDP6;
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2011-07-27 03:14:11 +04:00
|
|
|
domain = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->domain, &length);
|
2011-07-12 02:46:36 +04:00
|
|
|
cbDomain = length;
|
|
|
|
|
2011-07-27 03:14:11 +04:00
|
|
|
userName = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->username, &length);
|
2011-07-12 02:46:36 +04:00
|
|
|
cbUserName = length;
|
|
|
|
|
2012-02-01 20:58:06 +04:00
|
|
|
if (settings->password_cookie && settings->password_cookie->length > 0)
|
2012-01-31 05:54:46 +04:00
|
|
|
{
|
2012-02-01 20:58:06 +04:00
|
|
|
usedPasswordCookie = true;
|
2012-01-31 05:54:46 +04:00
|
|
|
password = (uint8*)settings->password_cookie->data;
|
2012-03-16 23:47:34 +04:00
|
|
|
cbPassword = settings->password_cookie->length - 2; /* Strip double zero termination */
|
2012-01-31 05:54:46 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-16 23:47:34 +04:00
|
|
|
password = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->password, &length);
|
|
|
|
cbPassword = length;
|
2012-01-31 05:54:46 +04:00
|
|
|
}
|
2011-07-12 02:46:36 +04:00
|
|
|
|
2011-07-27 03:14:11 +04:00
|
|
|
alternateShell = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->shell, &length);
|
2011-07-12 02:46:36 +04:00
|
|
|
cbAlternateShell = length;
|
|
|
|
|
2011-07-27 03:14:11 +04:00
|
|
|
workingDir = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->directory, &length);
|
2011-07-12 02:46:36 +04:00
|
|
|
cbWorkingDir = length;
|
|
|
|
|
|
|
|
stream_write_uint32(s, 0); /* CodePage */
|
|
|
|
stream_write_uint32(s, flags); /* flags */
|
|
|
|
|
|
|
|
stream_write_uint16(s, cbDomain); /* cbDomain */
|
|
|
|
stream_write_uint16(s, cbUserName); /* cbUserName */
|
|
|
|
stream_write_uint16(s, cbPassword); /* cbPassword */
|
|
|
|
stream_write_uint16(s, cbAlternateShell); /* cbAlternateShell */
|
|
|
|
stream_write_uint16(s, cbWorkingDir); /* cbWorkingDir */
|
|
|
|
|
|
|
|
if (cbDomain > 0)
|
|
|
|
stream_write(s, domain, cbDomain);
|
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
if (cbUserName > 0)
|
|
|
|
stream_write(s, userName, cbUserName);
|
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
if (cbPassword > 0)
|
2012-03-16 23:47:34 +04:00
|
|
|
stream_write(s, password, cbPassword);
|
2011-07-12 02:46:36 +04:00
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
if (cbAlternateShell > 0)
|
|
|
|
stream_write(s, alternateShell, cbAlternateShell);
|
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
if (cbWorkingDir > 0)
|
|
|
|
stream_write(s, workingDir, cbWorkingDir);
|
|
|
|
stream_write_uint16(s, 0);
|
|
|
|
|
|
|
|
xfree(domain);
|
|
|
|
xfree(userName);
|
|
|
|
xfree(alternateShell);
|
|
|
|
xfree(workingDir);
|
|
|
|
|
2012-02-01 20:58:06 +04:00
|
|
|
if (!usedPasswordCookie)
|
|
|
|
xfree(password);
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
if (settings->rdp_version >= 5)
|
|
|
|
rdp_write_extended_info_packet(s, settings); /* extraInfo */
|
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
/**
|
|
|
|
* Read Client Info PDU (CLIENT_INFO_PDU).\n
|
|
|
|
* @msdn{cc240474}
|
|
|
|
* @param rdp RDP module
|
|
|
|
* @param s stream
|
|
|
|
*/
|
|
|
|
|
2011-08-23 08:58:10 +04:00
|
|
|
boolean rdp_recv_client_info(rdpRdp* rdp, STREAM* s)
|
2011-08-20 14:22:14 +04:00
|
|
|
{
|
|
|
|
uint16 length;
|
|
|
|
uint16 channelId;
|
2012-01-25 19:30:54 +04:00
|
|
|
uint16 securityFlags;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
|
|
|
if (!rdp_read_header(rdp, s, &length, &channelId))
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-01-25 19:30:54 +04:00
|
|
|
rdp_read_security_header(s, &securityFlags);
|
|
|
|
if ((securityFlags & SEC_INFO_PKT) == 0)
|
2011-11-19 21:19:16 +04:00
|
|
|
return false;
|
2011-08-20 14:22:14 +04:00
|
|
|
|
2012-01-25 19:30:54 +04:00
|
|
|
if (rdp->settings->encryption)
|
|
|
|
{
|
|
|
|
if (securityFlags & SEC_REDIRECTION_PKT)
|
|
|
|
{
|
|
|
|
printf("Error: SEC_REDIRECTION_PKT unsupported\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (securityFlags & SEC_ENCRYPT)
|
|
|
|
{
|
|
|
|
if (!rdp_decrypt(rdp, s, length - 4, securityFlags))
|
|
|
|
{
|
|
|
|
printf("rdp_decrypt failed\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-20 14:22:14 +04:00
|
|
|
return rdp_read_info_packet(s, rdp->settings);
|
|
|
|
}
|
|
|
|
|
2011-07-12 02:46:36 +04:00
|
|
|
/**
|
|
|
|
* Send Client Info PDU (CLIENT_INFO_PDU).\n
|
|
|
|
* @msdn{cc240474}
|
|
|
|
* @param rdp RDP module
|
|
|
|
*/
|
|
|
|
|
2011-08-22 11:03:58 +04:00
|
|
|
boolean rdp_send_client_info(rdpRdp* rdp)
|
2011-07-12 02:46:36 +04:00
|
|
|
{
|
|
|
|
STREAM* s;
|
|
|
|
|
2011-09-13 10:40:27 +04:00
|
|
|
//rdp->settings->crypt_flags |= SEC_INFO_PKT;
|
|
|
|
rdp->sec_flags |= SEC_INFO_PKT;
|
2011-07-12 02:46:36 +04:00
|
|
|
s = rdp_send_stream_init(rdp);
|
|
|
|
rdp_write_info_packet(s, rdp->settings);
|
2011-08-22 11:03:58 +04:00
|
|
|
return rdp_send(rdp, s, MCS_GLOBAL_CHANNEL_ID);
|
2011-07-12 02:46:36 +04:00
|
|
|
}
|
|
|
|
|
2011-07-25 21:42:14 +04:00
|
|
|
void rdp_recv_logon_info_v1(rdpRdp* rdp, STREAM* s)
|
|
|
|
{
|
|
|
|
uint32 cbDomain;
|
|
|
|
uint32 cbUserName;
|
|
|
|
|
|
|
|
stream_read_uint32(s, cbDomain); /* cbDomain (4 bytes) */
|
|
|
|
stream_seek(s, 52); /* domain (52 bytes) */
|
|
|
|
stream_read_uint32(s, cbUserName); /* cbUserName (4 bytes) */
|
|
|
|
stream_seek(s, 512); /* userName (512 bytes) */
|
|
|
|
stream_seek_uint32(s); /* sessionId (4 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
void rdp_recv_logon_info_v2(rdpRdp* rdp, STREAM* s)
|
|
|
|
{
|
|
|
|
uint32 cbDomain;
|
|
|
|
uint32 cbUserName;
|
|
|
|
|
|
|
|
stream_seek_uint16(s); /* version (2 bytes) */
|
|
|
|
stream_seek_uint32(s); /* size (4 bytes) */
|
2012-01-09 01:02:59 +04:00
|
|
|
stream_seek_uint32(s); /* sessionId (4 bytes) */
|
2011-07-25 21:42:14 +04:00
|
|
|
stream_read_uint32(s, cbDomain); /* cbDomain (4 bytes) */
|
|
|
|
stream_read_uint32(s, cbUserName); /* cbUserName (4 bytes) */
|
|
|
|
stream_seek(s, 558); /* pad */
|
|
|
|
stream_seek(s, cbDomain); /* domain */
|
|
|
|
stream_seek(s, cbUserName); /* userName */
|
|
|
|
}
|
|
|
|
|
|
|
|
void rdp_recv_logon_plain_notify(rdpRdp* rdp, STREAM* s)
|
|
|
|
{
|
|
|
|
stream_seek(s, 576); /* pad */
|
|
|
|
}
|
|
|
|
|
|
|
|
void rdp_recv_logon_error_info(rdpRdp* rdp, STREAM* s)
|
|
|
|
{
|
|
|
|
uint32 errorNotificationType;
|
|
|
|
uint32 errorNotificationData;
|
|
|
|
|
|
|
|
stream_read_uint32(s, errorNotificationType); /* errorNotificationType (4 bytes) */
|
|
|
|
stream_read_uint32(s, errorNotificationData); /* errorNotificationData (4 bytes) */
|
|
|
|
}
|
|
|
|
|
|
|
|
void rdp_recv_logon_info_extended(rdpRdp* rdp, STREAM* s)
|
|
|
|
{
|
|
|
|
uint32 cbFieldData;
|
|
|
|
uint32 fieldsPresent;
|
2011-10-28 21:48:40 +04:00
|
|
|
uint16 Length;
|
2011-07-25 21:42:14 +04:00
|
|
|
|
2011-10-28 21:48:40 +04:00
|
|
|
stream_read_uint16(s, Length); /* The total size in bytes of this structure */
|
2011-07-25 21:42:14 +04:00
|
|
|
stream_read_uint32(s, fieldsPresent); /* fieldsPresent (4 bytes) */
|
|
|
|
|
|
|
|
/* logonFields */
|
|
|
|
|
|
|
|
if (fieldsPresent & LOGON_EX_AUTORECONNECTCOOKIE)
|
|
|
|
{
|
|
|
|
stream_read_uint32(s, cbFieldData); /* cbFieldData (4 bytes) */
|
|
|
|
rdp_read_server_auto_reconnect_cookie(s, rdp->settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fieldsPresent & LOGON_EX_LOGONERRORS)
|
|
|
|
{
|
|
|
|
stream_read_uint32(s, cbFieldData); /* cbFieldData (4 bytes) */
|
|
|
|
rdp_recv_logon_error_info(rdp, s);
|
|
|
|
}
|
|
|
|
|
|
|
|
stream_seek(s, 570); /* pad */
|
|
|
|
}
|
|
|
|
|
2011-08-23 08:58:10 +04:00
|
|
|
boolean rdp_recv_save_session_info(rdpRdp* rdp, STREAM* s)
|
2011-07-25 21:42:14 +04:00
|
|
|
{
|
|
|
|
uint32 infoType;
|
|
|
|
|
|
|
|
stream_read_uint32(s, infoType); /* infoType (4 bytes) */
|
|
|
|
|
2011-09-02 21:29:17 +04:00
|
|
|
//printf("%s\n", INFO_TYPE_LOGON_STRINGS[infoType]);
|
2011-07-25 21:42:14 +04:00
|
|
|
|
|
|
|
switch (infoType)
|
|
|
|
{
|
|
|
|
case INFO_TYPE_LOGON:
|
|
|
|
rdp_recv_logon_info_v1(rdp, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INFO_TYPE_LOGON_LONG:
|
|
|
|
rdp_recv_logon_info_v2(rdp, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INFO_TYPE_LOGON_PLAIN_NOTIFY:
|
|
|
|
rdp_recv_logon_plain_notify(rdp, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INFO_TYPE_LOGON_EXTENDED_INF:
|
|
|
|
rdp_recv_logon_info_extended(rdp, s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-08-22 13:49:39 +04:00
|
|
|
|
2011-11-19 21:19:16 +04:00
|
|
|
return true;
|
2011-07-25 21:42:14 +04:00
|
|
|
}
|
|
|
|
|