1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-02 11:36:22 +01:00

Use temp storage for URL parsing

This removes the issue where URLs were truncated during parsing,
resulting in them not working later on when transports are changed.
This commit is contained in:
OJ 2015-07-10 14:53:36 +10:00
parent 15ca2a90fb
commit d16e5276c5

View File

@ -937,6 +937,7 @@ static void transport_reset_tcp(Transport* transport, BOOL shuttingDown) {
static BOOL configure_tcp_connection(Transport* transport) {
DWORD result = ERROR_SUCCESS;
size_t charsConverted;
char tempUrl[512] = {0};
TcpTransportContext* ctx = (TcpTransportContext*)transport->ctx;
// check if comms is already open via a staged payload
@ -946,15 +947,20 @@ static BOOL configure_tcp_connection(Transport* transport) {
else {
dprintf("[TCP CONFIGURE] Url: %s", transport->url);
// copy the URL to the temp location and work from there
// so that we don't damage the original URL while breaking
// it up into its individual parts.
strncpy(tempUrl, transport->url, sizeof(tempUrl) - 1);
//transport->start_time = current_unix_timestamp();
transport->comms_last_packet = current_unix_timestamp();
if (strncmp(transport->url, "tcp", 3) == 0) {
char* pHost = strstr(transport->url, "//") + 2;
if (strncmp(tempUrl, "tcp", 3) == 0) {
char* pHost = strstr(tempUrl, "//") + 2;
char* pPort = strrchr(pHost, ':') + 1;
// check if we're using IPv6
if (transport->url[3] == '6') {
if (tempUrl[3] == '6') {
char* pScopeId = strrchr(pHost, '?') + 1;
*(pScopeId - 1) = '\0';
*(pPort - 1) = '\0';