mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-02 11:36:22 +01:00
add arp command to linux python meterpreter
This commit is contained in:
parent
2fb2604b05
commit
15223316a8
@ -1851,8 +1851,9 @@ def stdapi_fs_mount_show(request, response):
|
||||
response += tlv_pack(TLV_TYPE_MOUNT_GROUP, mount)
|
||||
return ERROR_SUCCESS, response
|
||||
|
||||
@register_function_if(has_windll)
|
||||
@register_function
|
||||
def stdapi_net_config_get_arp_table(request, response):
|
||||
if has_windll:
|
||||
MIB_IPNET_TYPE_DYNAMIC = 3
|
||||
MIB_IPNET_TYPE_STATIC = 4
|
||||
|
||||
@ -1892,6 +1893,28 @@ def stdapi_net_config_get_arp_table(request, response):
|
||||
arp_tlv += tlv_pack(TLV_TYPE_MAC_ADDRESS, bytes(ipnet_row.bPhysAddr)[:ipnet_row.dwPhysAddrLen])
|
||||
arp_tlv += tlv_pack(TLV_TYPE_MAC_NAME, str(ipnet_row.dwIndex))
|
||||
response += tlv_pack(TLV_TYPE_ARP_ENTRY, arp_tlv)
|
||||
|
||||
elif sys.platform.startswith('linux'):
|
||||
arp_cache_file = '/proc/net/arp'
|
||||
if not os.path.exists(arp_cache_file):
|
||||
return ERROR_NOT_SUPPORTED, response
|
||||
|
||||
with open('/proc/net/arp', 'r') as arp_cache:
|
||||
lines = arp_cache.readlines()
|
||||
import binascii
|
||||
for line in lines[1:]:
|
||||
fields = line.split()
|
||||
ip_address = fields[0]
|
||||
mac_address = fields[3]
|
||||
mac_address = bytes().join(binascii.unhexlify(h) for h in mac_address.split(':'))
|
||||
interface_name = fields[5]
|
||||
arp_tlv = bytes()
|
||||
arp_tlv += tlv_pack(TLV_TYPE_IP, socket.inet_aton(ip_address))
|
||||
arp_tlv += tlv_pack(TLV_TYPE_MAC_ADDRESS, mac_address)
|
||||
arp_tlv += tlv_pack(TLV_TYPE_MAC_NAME, interface_name)
|
||||
response += tlv_pack(TLV_TYPE_ARP_ENTRY, arp_tlv)
|
||||
else:
|
||||
return ERROR_NOT_SUPPORTED, response
|
||||
return ERROR_SUCCESS, response
|
||||
|
||||
@register_function
|
||||
|
Loading…
Reference in New Issue
Block a user