1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-03-18 15:14:10 +01:00

Fix error response in packet_transmit_http

The response code from packet_transmit_http was hardcoded to always return ERROR_SUCCESS.

This fix emulates how errors are debug-printed and returned from server_transport_tcp and server_transport_pipe.
This commit is contained in:
guffre 2023-02-26 17:54:39 -06:00
parent 6d92de2b7e
commit 1c6241604d

@ -290,7 +290,7 @@ static DWORD validate_response_winhttp(HANDLE hReq, HttpTransportContext* ctx)
*/ */
static DWORD packet_transmit_http(Remote *remote, LPBYTE rawPacket, DWORD rawPacketLength) static DWORD packet_transmit_http(Remote *remote, LPBYTE rawPacket, DWORD rawPacketLength)
{ {
DWORD res = 0; DWORD result = ERROR_SUCCESS;
HINTERNET hReq; HINTERNET hReq;
BOOL result; BOOL result;
DWORD retries = 5; DWORD retries = 5;
@ -303,26 +303,32 @@ static DWORD packet_transmit_http(Remote *remote, LPBYTE rawPacket, DWORD rawPac
hReq = ctx->create_req(ctx, FALSE, "PACKET TRANSMIT"); hReq = ctx->create_req(ctx, FALSE, "PACKET TRANSMIT");
if (hReq == NULL) if (hReq == NULL)
{ {
result = GetLastError();
break; break;
} }
result = ctx->send_req(ctx, hReq, rawPacket, rawPacketLength); result = ctx->send_req(ctx, hReq, rawPacket, rawPacketLength);
if (!result) if (!result)
{ {
dprintf("[PACKET TRANSMIT] Failed HttpSendRequest: %d", GetLastError()); result = GetLastError();
SetLastError(ERROR_NOT_FOUND);
break; break;
} }
dprintf("[PACKET TRANSMIT] request sent.. apparently");
} while(0); } while(0);
if (result != ERROR_SUCCESS)
{
dprintf("[PACKET TRANSMIT] transmit request failed with return: %d", result);
}
else
{
dprintf("[PACKET TRANSMIT] request sent.. apparently");
}
ctx->close_req(hReq); ctx->close_req(hReq);
lock_release(remote->lock); lock_release(remote->lock);
return res; return result;
} }
/*! /*!