mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-03-24 18:16:24 +01:00
Fix Windows XP compatibility
GetIpForwardTable2 is not available on Windows versions prior to Vista. Use GetProcAddress to call it when it's available while avoiding crashing on XP.
This commit is contained in:
parent
bf7e5cb7c6
commit
f402d7cb9e
@ -3,6 +3,8 @@
|
||||
#include "common_metapi.h"
|
||||
#include <netioapi.h>
|
||||
|
||||
typedef NETIO_STATUS(NETIOAPI_API_* GETIPFORWARDTABLE2)(ADDRESS_FAMILY Family, PMIB_IPFORWARD_TABLE2* Table);
|
||||
|
||||
typedef struct v6netmask
|
||||
{
|
||||
unsigned int mask[4];
|
||||
@ -111,12 +113,18 @@ DWORD request_net_config_get_routes(Remote *remote, Packet *packet)
|
||||
route, 5);
|
||||
}
|
||||
|
||||
if (GetIpForwardTable2(AF_INET6, &table_ipv6) != NO_ERROR) {
|
||||
v6netmask v6_mask;
|
||||
MIB_IPINTERFACE_ROW iface = { .Family = AF_INET6 };
|
||||
GETIPFORWARDTABLE2 pGetIpForwardTable2 = (GETIPFORWARDTABLE2)GetProcAddress(GetModuleHandle(TEXT("Iphlpapi.dll")), "GetIpForwardTable2");
|
||||
|
||||
// GetIpForwardTable2 is only available on Windows Vista and later.
|
||||
if (!pGetIpForwardTable2) {
|
||||
break;
|
||||
}
|
||||
if (pGetIpForwardTable2(AF_INET6, &table_ipv6) != NO_ERROR) {
|
||||
BREAK_ON_ERROR("[NET] request_net_config_get_routes: GetIpForwardTable2 failed");
|
||||
}
|
||||
|
||||
v6netmask v6_mask;
|
||||
MIB_IPINTERFACE_ROW iface = { .Family = AF_INET6 };
|
||||
// Enumerate it
|
||||
for (index = 0;
|
||||
index < table_ipv6->NumEntries;
|
||||
|
Loading…
x
Reference in New Issue
Block a user