void rpc_ntlm_http_init_channel(rdpRpc* rpc, rdpNtlmHttp* ntlm_http, TSG_CHANNEL channel) { if (channel == TSG_CHANNEL_IN) http_context_set_method(ntlm_http->context, "RPC_IN_DATA"); else if (channel == TSG_CHANNEL_OUT) http_context_set_method(ntlm_http->context, "RPC_OUT_DATA"); http_context_set_uri(ntlm_http->context, "/rpc/rpcproxy.dll?localhost:3388"); http_context_set_accept(ntlm_http->context, "application/rpc"); http_context_set_cache_control(ntlm_http->context, "no-cache"); http_context_set_connection(ntlm_http->context, "Keep-Alive"); http_context_set_user_agent(ntlm_http->context, "MSRPC"); http_context_set_host(ntlm_http->context, rpc->settings->GatewayHostname); if (channel == TSG_CHANNEL_IN) { http_context_set_pragma(ntlm_http->context, "ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729"); } else if (channel == TSG_CHANNEL_OUT) { http_context_set_pragma(ntlm_http->context, "ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729" ", " "SessionId=fbd9c34f-397d-471d-a109-1b08cc554624"); } }
static int rpc_out_channel_rpch_init(rdpRpc* rpc, RpcOutChannel* outChannel) { HttpContext* http; outChannel->ntlm = ntlm_new(); if (!outChannel->ntlm) return -1; outChannel->http = http_context_new(); if (!outChannel->http) return -1; http = outChannel->http; http_context_set_method(http, "RPC_OUT_DATA"); http_context_set_uri(http, "/rpc/rpcproxy.dll?localhost:3388"); http_context_set_accept(http, "application/rpc"); http_context_set_cache_control(http, "no-cache"); http_context_set_connection(http, "Keep-Alive"); http_context_set_user_agent(http, "MSRPC"); http_context_set_host(http, rpc->settings->GatewayHostname); http_context_set_pragma(http, "ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729, " "SessionId=fbd9c34f-397d-471d-a109-1b08cc554624"); return 1; }
static int rpc_in_channel_rpch_init(rdpRpc* rpc, RpcInChannel* inChannel) { HttpContext* http; inChannel->ntlm = ntlm_new(); if (!inChannel->ntlm) return -1; inChannel->http = http_context_new(); if (!inChannel->http) return -1; http = inChannel->http; http_context_set_method(http, "RPC_IN_DATA"); http_context_set_uri(http, "/rpc/rpcproxy.dll?localhost:3388"); http_context_set_accept(http, "application/rpc"); http_context_set_cache_control(http, "no-cache"); http_context_set_connection(http, "Keep-Alive"); http_context_set_user_agent(http, "MSRPC"); http_context_set_host(http, rpc->settings->GatewayHostname); http_context_set_pragma(http, "ResourceTypeUuid=44e265dd-7daf-42cd-8560-3cdb6e7a2729"); return 1; }
rdpRdg* rdg_new(rdpTransport* transport) { rdpRdg* rdg; RPC_CSTR stringUuid; char bracedUuid[40]; RPC_STATUS rpcStatus; assert(transport != NULL); rdg = (rdpRdg*) calloc(1, sizeof(rdpRdg)); if (rdg) { rdg->state = RDG_CLIENT_STATE_INITIAL; rdg->context = transport->context; rdg->settings = rdg->context->settings; rdg->extAuth = HTTP_EXTENDED_AUTH_NONE; if (rdg->settings->GatewayAccessToken) rdg->extAuth = HTTP_EXTENDED_AUTH_PAA; UuidCreate(&rdg->guid); rpcStatus = UuidToStringA(&rdg->guid, &stringUuid); if (rpcStatus == RPC_S_OUT_OF_MEMORY) goto rdg_alloc_error; sprintf_s(bracedUuid, sizeof(bracedUuid), "{%s}", stringUuid); RpcStringFreeA(&stringUuid); rdg->tlsOut = tls_new(rdg->settings); if (!rdg->tlsOut) goto rdg_alloc_error; rdg->tlsIn = tls_new(rdg->settings); if (!rdg->tlsIn) goto rdg_alloc_error; rdg->http = http_context_new(); if (!rdg->http) goto rdg_alloc_error; http_context_set_uri(rdg->http, "/remoteDesktopGateway/"); http_context_set_accept(rdg->http, "*/*"); http_context_set_cache_control(rdg->http, "no-cache"); http_context_set_pragma(rdg->http, "no-cache"); http_context_set_connection(rdg->http, "Keep-Alive"); http_context_set_user_agent(rdg->http, "MS-RDGateway/1.0"); http_context_set_host(rdg->http, rdg->settings->GatewayHostname); http_context_set_rdg_connection_id(rdg->http, bracedUuid); if (!rdg->http->URI || !rdg->http->Accept || !rdg->http->CacheControl || !rdg->http->Pragma || !rdg->http->Connection || !rdg->http->UserAgent || !rdg->http->Host || !rdg->http->RdgConnectionId) { goto rdg_alloc_error; } if (rdg->extAuth != HTTP_EXTENDED_AUTH_NONE) { switch (rdg->extAuth) { case HTTP_EXTENDED_AUTH_PAA: http_context_set_rdg_auth_scheme(rdg->http, "PAA"); if (!rdg->http->RdgAuthScheme) goto rdg_alloc_error; break; default: WLog_DBG(TAG, "RDG extended authentication method %d not supported", rdg->extAuth); } } rdg->frontBio = BIO_new(BIO_s_rdg()); if (!rdg->frontBio) goto rdg_alloc_error; BIO_set_data(rdg->frontBio, rdg); InitializeCriticalSection(&rdg->writeSection); } return rdg; rdg_alloc_error: rdg_free(rdg); return NULL; }
rdpRdg* rdg_new(rdpTransport* transport) { rdpRdg* rdg; RPC_CSTR stringUuid; char bracedUuid[40]; RPC_STATUS rpcStatus; assert(transport != NULL); rdg = (rdpRdg*) calloc(1, sizeof(rdpRdg)); if (rdg) { rdg->state = RDG_CLIENT_STATE_INITIAL; rdg->context = transport->context; rdg->settings = rdg->context->settings; UuidCreate(&rdg->guid); rpcStatus = UuidToStringA(&rdg->guid, &stringUuid); if (rpcStatus == RPC_S_OUT_OF_MEMORY) goto rdg_alloc_error; sprintf_s(bracedUuid, sizeof(bracedUuid), "{%s}", stringUuid); RpcStringFreeA(&stringUuid); rdg->tlsOut = tls_new(rdg->settings); if (!rdg->tlsOut) goto rdg_alloc_error; rdg->tlsIn = tls_new(rdg->settings); if (!rdg->tlsIn) goto rdg_alloc_error; rdg->http = http_context_new(); if (!rdg->http) goto rdg_alloc_error; http_context_set_uri(rdg->http, "/remoteDesktopGateway/"); http_context_set_accept(rdg->http, "*/*"); http_context_set_cache_control(rdg->http, "no-cache"); http_context_set_pragma(rdg->http, "no-cache"); http_context_set_connection(rdg->http, "Keep-Alive"); http_context_set_user_agent(rdg->http, "MS-RDGateway/1.0"); http_context_set_host(rdg->http, rdg->settings->GatewayHostname); http_context_set_rdg_connection_id(rdg->http, bracedUuid); if (!rdg->http->URI || !rdg->http->Accept || !rdg->http->CacheControl || !rdg->http->Pragma || !rdg->http->Connection || !rdg->http->UserAgent || !rdg->http->Host || !rdg->http->RdgConnectionId) { goto rdg_alloc_error; } rdg->frontBio = BIO_new(BIO_s_rdg()); if (!rdg->frontBio) goto rdg_alloc_error; rdg->frontBio->ptr = rdg; rdg->readEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!rdg->readEvent) goto rdg_alloc_error; InitializeCriticalSection(&rdg->writeSection); } return rdg; rdg_alloc_error: rdg_free(rdg); return NULL; }