Suggested changes from ikelos

This commit is contained in:
Andrew Case
2019-09-27 20:50:21 +01:00
committed by ikelos
parent bf29e23e1c
commit a4a918ea58
4 changed files with 36 additions and 48 deletions
@@ -1,32 +0,0 @@
# This file is Copyright 2019 Volatility Foundation and licensed under the Volatility Software License 1.0
# which is available at https://www.volatilityfoundation.org/license/vsl_v1.0
#
from volatility.framework import interfaces
from volatility.framework import exceptions
def walk_tailq(queue: interfaces.objects.ObjectInterface, next_member: str, max_elements: int = 4096):
seen = set()
try:
current = queue.tqh_first
except exceptions.PagedInvalidAddressException:
return
while current:
if current.vol.offset in seen:
break
seen.add(current.vol.offset)
if len(seen) == max_elements:
break
yield current
try:
current = current.member(attr = next_member).tqe_next
except exceptions.PagedInvalidAddressException:
return
+5 -12
View File
@@ -1,5 +1,5 @@
# This file is Copyright 2019 Volatility Foundation and licensed under the Volatility Software License 1.0
# which is available at https://www.volatilityfoundation.org/license/vsl_v1.0
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0
#
from volatility.framework import exceptions, renderers, interfaces, contexts
@@ -9,13 +9,9 @@ from volatility.framework.interfaces import plugins
from volatility.framework.objects import utility
from volatility.framework.renderers import format_hints
import volatility.plugins.mac.common as mac_common
class Ifconfig(plugins.PluginInterface):
"""Lists loaded kernel modules"""
_version = (1, 0, 0)
@classmethod
def get_requirements(cls):
return [
@@ -34,13 +30,10 @@ class Ifconfig(plugins.PluginInterface):
except exceptions.SymbolError:
list_head = kernel.object_from_symbol(symbol_name = "dlil_ifnet_head")
for ifnet in mac_common.walk_tailq(list_head, "if_link"):
for ifnet in mac.MacUtilities.walk_tailq(list_head, "if_link"):
name = utility.pointer_to_string(ifnet.if_name, 32)
unit = ifnet.if_unit
if ifnet.if_flags & 0x100 == 0x100: # IFF_PROMISC
prom = "True"
else:
prom = "False"
prom = ifnet.if_flags & 0x100 == 0x100 # IFF_PROMISC
sock_addr_dl = ifnet.sockaddr_dl()
if sock_addr_dl is None:
@@ -48,13 +41,13 @@ class Ifconfig(plugins.PluginInterface):
else:
mac_addr = str(sock_addr_dl)
for ifaddr in mac_common.walk_tailq(ifnet.if_addrhead, "ifa_link"):
for ifaddr in mac.MacUtilities.walk_tailq(ifnet.if_addrhead, "ifa_link"):
ip = ifaddr.ifa_addr.get_address()
yield (0, ("{0}{1}".format(name, unit), ip, mac_addr, prom))
def run(self):
return renderers.TreeGrid([("Interface", str), ("IP Address", str), ("Mac Address", str), ("Promiscuous", str)], self._generator())
return renderers.TreeGrid([("Interface", str), ("IP Address", str), ("Mac Address", str), ("Promiscuous", bool)], self._generator())