|
11 | 11 | # |
12 | 12 | # https://volatility-labs.blogspot.com/2021/10/memory-forensics-r-illustrated.html |
13 | 13 |
|
14 | | -import io |
15 | 14 | import logging |
16 | 15 | from typing import Iterable, Tuple, List, Optional |
17 | 16 |
|
18 | 17 | import pefile |
19 | 18 |
|
20 | 19 | from volatility3.framework import interfaces, symbols, exceptions |
21 | | -from volatility3.framework import renderers, constants |
| 20 | +from volatility3.framework import renderers |
22 | 21 | from volatility3.framework.configuration import requirements |
23 | 22 | from volatility3.framework.layers import scanners |
24 | 23 | from volatility3.framework.objects import utility |
25 | 24 | from volatility3.framework.renderers import format_hints |
26 | 25 | from volatility3.framework.symbols import intermed |
27 | 26 | from volatility3.framework.symbols.windows import pdbutil |
28 | 27 | from volatility3.framework.symbols.windows.extensions import pe |
29 | | -from volatility3.plugins.windows import pslist, vadinfo |
| 28 | +from volatility3.plugins.windows import pslist, vadinfo, pe_symbols |
30 | 29 |
|
31 | 30 | try: |
32 | 31 | import capstone |
@@ -61,43 +60,11 @@ def get_requirements(cls): |
61 | 60 | requirements.VersionRequirement( |
62 | 61 | name="pdbutil", component=pdbutil.PDBUtility, version=(1, 0, 0) |
63 | 62 | ), |
| 63 | + requirements.VersionRequirement( |
| 64 | + name="pe_symbols", component=pe_symbols.PESymbols, version=(1, 1, 0) |
| 65 | + ), |
64 | 66 | ] |
65 | 67 |
|
66 | | - def _get_pefile_obj( |
67 | | - self, pe_table_name: str, layer_name: str, base_address: int |
68 | | - ) -> pefile.PE: |
69 | | - """ |
70 | | - Attempts to pefile object from the bytes of the PE file |
71 | | -
|
72 | | - Args: |
73 | | - pe_table_name: name of the pe types table |
74 | | - layer_name: name of the lsass.exe process layer |
75 | | - base_address: base address of cryptdll.dll in lsass.exe |
76 | | -
|
77 | | - Returns: |
78 | | - the constructed pefile object |
79 | | - """ |
80 | | - pe_data = io.BytesIO() |
81 | | - |
82 | | - try: |
83 | | - dos_header = self.context.object( |
84 | | - pe_table_name + constants.BANG + "_IMAGE_DOS_HEADER", |
85 | | - offset=base_address, |
86 | | - layer_name=layer_name, |
87 | | - ) |
88 | | - |
89 | | - for offset, data in dos_header.reconstruct(): |
90 | | - pe_data.seek(offset) |
91 | | - pe_data.write(data) |
92 | | - |
93 | | - pe_ret = pefile.PE(data=pe_data.getvalue(), fast_load=True) |
94 | | - |
95 | | - except exceptions.InvalidAddressException: |
96 | | - vollog.debug("Unable to reconstruct cryptdll.dll in memory") |
97 | | - pe_ret = None |
98 | | - |
99 | | - return pe_ret |
100 | | - |
101 | 68 | def _check_for_skeleton_key_vad( |
102 | 69 | self, |
103 | 70 | csystem: interfaces.objects.ObjectInterface, |
@@ -497,7 +464,9 @@ def _find_csystems_with_export( |
497 | 464 | self.context, self.config_path, "windows", "pe", class_types=pe.class_types |
498 | 465 | ) |
499 | 466 |
|
500 | | - cryptdll = self._get_pefile_obj(pe_table_name, proc_layer_name, cryptdll_base) |
| 467 | + cryptdll = pe_symbols.PESymbols.get_pefile_obj( |
| 468 | + self.context, pe_table_name, proc_layer_name, cryptdll_base |
| 469 | + ) |
501 | 470 | if not cryptdll: |
502 | 471 | return None |
503 | 472 |
|
|
0 commit comments