1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-14 17:37:27 +01:00

return interface name instead of index for arp command

This commit is contained in:
Alex Romero 2023-03-06 16:25:20 -05:00
parent 0f18eef4f8
commit 5df4982d73
No known key found for this signature in database

View File

@ -9,7 +9,6 @@ DWORD get_arp_table(Remote *remote, Packet *response)
DWORD dwSize = 0;
DWORD dwRetVal;
DWORD i;
char interface_index[10];
do {
dwRetVal = GetIpNetTable(NULL, &dwSize, 0);
@ -36,8 +35,6 @@ DWORD get_arp_table(Remote *remote, Packet *response)
if ((pIpNetTable->table[i].dwType == MIB_IPNET_TYPE_DYNAMIC) ||
(pIpNetTable->table[i].dwType == MIB_IPNET_TYPE_STATIC)) {
Tlv arp[3];
// can't send interface name as it can be _big_, so send index instead
sprintf_s(interface_index, sizeof(interface_index), "%d", pIpNetTable->table[i].dwIndex);
arp[0].header.type = TLV_TYPE_IP;
arp[0].header.length = sizeof(DWORD);
@ -48,8 +45,27 @@ DWORD get_arp_table(Remote *remote, Packet *response)
arp[1].buffer = (PUCHAR)pIpNetTable->table[i].bPhysAddr;
arp[2].header.type = TLV_TYPE_MAC_NAME;
arp[2].header.length = (DWORD)strlen(interface_index) + 1;
arp[2].buffer = (PUCHAR)interface_index;
BOOL has_description = FALSE;
MIB_IFROW iface;
iface.dwIndex = pIpNetTable->table[i].dwIndex;
result = GetIfEntry(&iface);
if (result == NO_ERROR)
{
if (iface.bDescr)
{
arp[2].header.length = (DWORD)strlen(iface.bDescr) + 1;
arp[2].buffer = (PUCHAR)iface.bDescr;
has_description = TRUE;
}
}
if (!has_description) {
char interface_index[10];
sprintf_s(interface_index, sizeof(interface_index), "%d", pIpNetTable->table[i].dwIndex);
arp[2].header.length = (DWORD)strlen(interface_index) + 1;
arp[2].buffer = (PUCHAR)interface_index;
}
met_api->packet.add_tlv_group(response, TLV_TYPE_ARP_ENTRY, arp, 3);
}