|
5 | 5 | # Public researches: https://i.blackhat.com/USA21/Wednesday-Handouts/us-21-Fixing-A-Memory-Forensics-Blind-Spot-Linux-Kernel-Tracing-wp.pdf
|
6 | 6 |
|
7 | 7 | import logging
|
8 |
| -from typing import Dict, List, Iterable, Optional |
| 8 | +from typing import Dict, List, Generator |
9 | 9 | from enum import Enum
|
10 | 10 | from dataclasses import dataclass
|
11 | 11 |
|
@@ -67,7 +67,7 @@ class CheckFtrace(interfaces.plugins.PluginInterface):
|
67 | 67 | Investigate the ftrace infrastructure to uncover kernel attached callbacks, which can be leveraged
|
68 | 68 | to hook kernel functions and modify their behaviour."""
|
69 | 69 |
|
70 |
| - _version = (1, 0, 0) |
| 70 | + _version = (2, 0, 0) |
71 | 71 | _required_framework_version = (2, 19, 0)
|
72 | 72 |
|
73 | 73 | @classmethod
|
@@ -103,14 +103,14 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
|
103 | 103 | def extract_hash_table_filters(
|
104 | 104 | cls,
|
105 | 105 | ftrace_ops: interfaces.objects.ObjectInterface,
|
106 |
| - ) -> Optional[Iterable[interfaces.objects.ObjectInterface]]: |
| 106 | + ) -> Generator[interfaces.objects.ObjectInterface, None, None]: |
107 | 107 | """Wrap the process of walking to every ftrace_func_entry of an ftrace_ops.
|
108 | 108 | Those are stored in a hash table of filters that indicates the addresses hooked.
|
109 | 109 |
|
110 | 110 | Args:
|
111 | 111 | ftrace_ops: The ftrace_ops struct to walk through
|
112 | 112 |
|
113 |
| - Returns: |
| 113 | + Return, None, None: |
114 | 114 | An iterable of ftrace_func_entry structs
|
115 | 115 | """
|
116 | 116 |
|
@@ -140,7 +140,7 @@ def parse_ftrace_ops(
|
140 | 140 | known_modules: Dict[str, List[extensions.module]],
|
141 | 141 | ftrace_ops: interfaces.objects.ObjectInterface,
|
142 | 142 | run_hidden_modules: bool = True,
|
143 |
| - ) -> Optional[Iterable[ParsedFtraceOps]]: |
| 143 | + ) -> Generator[ParsedFtraceOps, None, None]: |
144 | 144 | """Parse an ftrace_ops struct to highlight ftrace kernel hooking.
|
145 | 145 | Iterates over embedded ftrace_func_entry entries, which point to hooked memory areas.
|
146 | 146 |
|
@@ -237,12 +237,10 @@ def parse_ftrace_ops(
|
237 | 237 | formatted_ftrace_flags,
|
238 | 238 | )
|
239 | 239 |
|
240 |
| - return None |
241 |
| - |
242 | 240 | @classmethod
|
243 | 241 | def iterate_ftrace_ops_list(
|
244 | 242 | cls, context: interfaces.context.ContextInterface, kernel_name: str
|
245 |
| - ) -> Optional[Iterable[interfaces.objects.ObjectInterface]]: |
| 243 | + ) -> Generator[interfaces.objects.ObjectInterface, None, None]: |
246 | 244 | """Iterate over (ftrace_ops *)ftrace_ops_list.
|
247 | 245 |
|
248 | 246 | Returns:
|
|
0 commit comments