Skip to content

Commit 944c841

Browse files
committed
Linux: Rename net extensions to allow for net variable name
1 parent ce49029 commit 944c841

File tree

7 files changed

+54
-56
lines changed

7 files changed

+54
-56
lines changed

volatility3/framework/plugins/linux/ip.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
from volatility3.framework import interfaces, renderers, constants
77
from volatility3.framework.configuration import requirements
88
from volatility3.framework.interfaces import plugins
9-
from volatility3.framework.symbols.linux import net
10-
from volatility3.framework.symbols.linux.extensions import net as net_extensions
9+
from volatility3.framework.symbols.linux import network
10+
from volatility3.framework.symbols.linux.extensions import network as net_extensions
1111

1212

1313
class Addr(plugins.PluginInterface):
@@ -26,7 +26,7 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
2626
architectures=["Intel32", "Intel64"],
2727
),
2828
requirements.VersionRequirement(
29-
name="Net", component=net.NetSymbols, version=(1, 0, 0)
29+
name="Net", component=network.NetSymbols, version=(1, 0, 0)
3030
),
3131
]
3232

@@ -62,7 +62,7 @@ def _generator(self):
6262

6363
net_type_symname = vmlinux.symbol_table_name + constants.BANG + "net"
6464
net_device_symname = vmlinux.symbol_table_name + constants.BANG + "net_device"
65-
net.NetSymbols.apply(self.context.symbol_space[vmlinux.symbol_table_name])
65+
network.NetSymbols.apply(self.context.symbol_space[vmlinux.symbol_table_name])
6666

6767
# 'net_namespace_list' exists from kernels >= 2.6.24
6868
net_namespace_list = vmlinux.object_from_symbol("net_namespace_list")
@@ -102,7 +102,7 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
102102
architectures=["Intel32", "Intel64"],
103103
),
104104
requirements.VersionRequirement(
105-
name="Net", component=net.NetSymbols, version=(1, 0, 0)
105+
name="Net", component=network.NetSymbols, version=(1, 0, 0)
106106
),
107107
]
108108

volatility3/framework/plugins/linux/netfilter.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from volatility3.framework.renderers import format_hints
1818
from volatility3.framework.configuration import requirements
1919
from volatility3.framework.symbols import linux
20-
from volatility3.framework.symbols.linux import net
20+
from volatility3.framework.symbols.linux import network
2121
from volatility3.plugins.linux import lsmod
2222

2323
vollog = logging.getLogger(__name__)
@@ -101,7 +101,7 @@ def __init__(
101101
)
102102

103103
linux_net_required_version = Netfilter._required_linuxnet_version
104-
linux_net_current_version = net.NetSymbols.version
104+
linux_net_current_version = network.NetSymbols.version
105105
if not requirements.VersionRequirement.matches_required(
106106
linux_net_required_version, linux_net_current_version
107107
):
@@ -124,7 +124,7 @@ def __init__(
124124
)
125125

126126
symbol_table = self._context.symbol_space[self.vmlinux.symbol_table_name]
127-
net.NetSymbols.apply(symbol_table)
127+
network.NetSymbols.apply(symbol_table)
128128

129129
modules = lsmod.Lsmod.list_modules(context, kernel_module_name)
130130
self.handlers = linux.LinuxUtilities.generate_kernel_handler_info(
@@ -204,11 +204,9 @@ def _run(self) -> Iterator[Tuple[int, str, str, int, int, str, bool]]:
204204
module_name [str]: Linux kernel module name
205205
hooked [bool]: "True" if the network stack has been hijacked
206206
"""
207-
for netns, network in self.get_net_namespaces():
207+
for netns, net in self.get_net_namespaces():
208208
for proto_idx, proto_name, hook_idx, hook_name in self._proto_hook_loop():
209-
hooks_container = self.get_hooks_container(
210-
network, proto_name, hook_name
211-
)
209+
hooks_container = self.get_hooks_container(net, proto_name, hook_name)
212210

213211
for hook_container in hooks_container:
214212
for hook_ops in self.get_hook_ops(
@@ -313,9 +311,9 @@ def get_net_namespaces(self):
313311
"""
314312
nethead = self.vmlinux.object_from_symbol("net_namespace_list")
315313
symbol_net_name = self.get_symbol_fullname("net")
316-
for network in nethead.to_list(symbol_net_name, "list"):
317-
net_ns_id = network.ns.inum
318-
yield net_ns_id, network
314+
for net in nethead.to_list(symbol_net_name, "list"):
315+
net_ns_id = net.ns.inum
316+
yield net_ns_id, net
319317

320318
def get_hooks_container(self, net, proto_name, hook_name):
321319
"""Returns the data structure used in a specific kernel implementation to store
@@ -737,7 +735,7 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
737735
),
738736
requirements.VersionRequirement(
739737
name="linuxnet",
740-
component=net.NetSymbols,
738+
component=network.NetSymbols,
741739
version=cls._required_linuxnet_version,
742740
),
743741
]

volatility3/framework/plugins/linux/sockstat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from volatility3.framework.symbols import linux
1414
from volatility3.plugins.linux import lsof
1515
from volatility3.plugins.linux import pslist
16-
from volatility3.framework.symbols.linux import net
16+
from volatility3.framework.symbols.linux import network
1717

1818

1919
vollog = logging.getLogger(__name__)
@@ -475,7 +475,7 @@ def get_requirements(cls):
475475
name="linuxutils", component=linux.LinuxUtilities, version=(2, 0, 0)
476476
),
477477
requirements.VersionRequirement(
478-
name="linux_net", component=net.NetSymbols, version=(1, 0, 0)
478+
name="linux_net", component=network.NetSymbols, version=(1, 0, 0)
479479
),
480480
requirements.BooleanRequirement(
481481
name="unix",
@@ -618,7 +618,7 @@ def _generator(self, pids: List[int], netns_id_arg: int, kernel_module_name: str
618618
"""
619619
vmlinux = self.context.modules[kernel_module_name]
620620
symbol_table = self.context.symbol_space[vmlinux.symbol_table_name]
621-
net.NetSymbols.apply(symbol_table)
621+
network.NetSymbols.apply(symbol_table)
622622

623623
filter_func = pslist.PsList.create_pid_filter(pids)
624624
socket_generator = self.list_sockets(

volatility3/framework/symbols/linux/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ def __init__(self, *args, **kwargs) -> None:
7373

7474
# Network
7575
# FIXME: Deprecate all of this once the framework hits version 3
76-
self.set_type_class("net", extensions.net.net)
77-
self.set_type_class("socket", extensions.net.socket)
78-
self.set_type_class("sock", extensions.net.sock)
79-
self.set_type_class("inet_sock", extensions.net.inet_sock)
80-
self.set_type_class("unix_sock", extensions.net.unix_sock)
76+
self.set_type_class("net", extensions.network.net)
77+
self.set_type_class("socket", extensions.network.socket)
78+
self.set_type_class("sock", extensions.network.sock)
79+
self.set_type_class("inet_sock", extensions.network.inet_sock)
80+
self.set_type_class("unix_sock", extensions.network.unix_sock)
8181
# Might not exist in older kernels or the current symbols
82-
self.optional_set_type_class("netlink_sock", extensions.net.netlink_sock)
83-
self.optional_set_type_class("vsock_sock", extensions.net.vsock_sock)
84-
self.optional_set_type_class("packet_sock", extensions.net.packet_sock)
85-
self.optional_set_type_class("bt_sock", extensions.net.bt_sock)
86-
self.optional_set_type_class("xdp_sock", extensions.net.xdp_sock)
82+
self.optional_set_type_class("netlink_sock", extensions.network.netlink_sock)
83+
self.optional_set_type_class("vsock_sock", extensions.network.vsock_sock)
84+
self.optional_set_type_class("packet_sock", extensions.network.packet_sock)
85+
self.optional_set_type_class("bt_sock", extensions.network.bt_sock)
86+
self.optional_set_type_class("xdp_sock", extensions.network.xdp_sock)
8787

8888
# Only found in 6.1+ kernels
8989
self.optional_set_type_class("maple_tree", extensions.maple_tree)

volatility3/framework/symbols/linux/extensions/net.py renamed to volatility3/framework/symbols/linux/extensions/network.py

File renamed without changes.

volatility3/framework/symbols/linux/net.py

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from volatility3.framework.symbols import intermed
2+
from volatility3.framework.symbols.linux.extensions import network
3+
from volatility3.framework.interfaces.configuration import VersionableInterface
4+
5+
6+
class NetSymbols(VersionableInterface):
7+
_version = (1, 0, 0)
8+
9+
@classmethod
10+
def apply(cls, symbol_table: intermed.IntermediateSymbolTable):
11+
# Network
12+
symbol_table.set_type_class("net", network.net)
13+
symbol_table.set_type_class("net_device", network.net_device)
14+
symbol_table.set_type_class("in_device", network.in_device)
15+
symbol_table.set_type_class("in_ifaddr", network.in_ifaddr)
16+
symbol_table.set_type_class("inet6_dev", network.inet6_dev)
17+
symbol_table.set_type_class("inet6_ifaddr", network.inet6_ifaddr)
18+
symbol_table.set_type_class("socket", network.socket)
19+
symbol_table.set_type_class("sock", network.sock)
20+
symbol_table.set_type_class("inet_sock", network.inet_sock)
21+
symbol_table.set_type_class("unix_sock", network.unix_sock)
22+
# Might not exist in older kernels or the current symbols
23+
symbol_table.optional_set_type_class("netlink_sock", network.netlink_sock)
24+
symbol_table.optional_set_type_class("vsock_sock", network.vsock_sock)
25+
symbol_table.optional_set_type_class("packet_sock", network.packet_sock)
26+
symbol_table.optional_set_type_class("bt_sock", network.bt_sock)
27+
symbol_table.optional_set_type_class("xdp_sock", network.xdp_sock)

0 commit comments

Comments
 (0)