Skip to content

Commit 1b554b4

Browse files
authored
Merge pull request #1578 from volatilityfoundation/issues/issue1575
Shift exposed staticmethods to classmethods
2 parents 8125b0d + e4e54a5 commit 1b554b4

File tree

15 files changed

+90
-69
lines changed

15 files changed

+90
-69
lines changed

volatility3/framework/plugins/linux/envars.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Envars(plugins.PluginInterface):
1818
"""Lists processes with their environment variables"""
1919

2020
_required_framework_version = (2, 13, 0)
21-
_version = (2, 0, 0)
21+
_version = (2, 0, 1)
2222

2323
@classmethod
2424
def get_requirements(cls):
@@ -40,8 +40,9 @@ def get_requirements(cls):
4040
),
4141
]
4242

43-
@staticmethod
43+
@classmethod
4444
def get_task_env_variables(
45+
cls,
4546
context: interfaces.context.ContextInterface,
4647
task: interfaces.objects.ObjectInterface,
4748
env_area_max_size: int = 8192,

volatility3/framework/plugins/linux/hidden_modules.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class Hidden_modules(interfaces.plugins.PluginInterface):
1616
"""Carves memory to find hidden kernel modules"""
1717

1818
_required_framework_version = (2, 10, 0)
19-
20-
_version = (1, 0, 0)
19+
_version = (1, 0, 1)
2120

2221
@classmethod
2322
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
@@ -32,8 +31,9 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
3231
),
3332
]
3433

35-
@staticmethod
34+
@classmethod
3635
def get_modules_memory_boundaries(
36+
cls,
3737
context: interfaces.context.ContextInterface,
3838
vmlinux_module_name: str,
3939
) -> Tuple[int]:

volatility3/framework/plugins/linux/pagecache.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class Files(plugins.PluginInterface, timeliner.TimeLinerInterface):
104104

105105
_required_framework_version = (2, 0, 0)
106106

107-
_version = (1, 0, 2)
107+
_version = (1, 0, 3)
108108

109109
@classmethod
110110
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
@@ -360,8 +360,8 @@ def generate_timeline(self):
360360
yield description, timeliner.TimeLinerType.MODIFIED, inode_out.modification_time
361361
yield description, timeliner.TimeLinerType.CHANGED, inode_out.change_time
362362

363-
@staticmethod
364-
def format_fields_with_headers(headers, generator):
363+
@classmethod
364+
def format_fields_with_headers(cls, headers, generator):
365365
"""Uses the headers type to cast the fields obtained from the generator"""
366366
for level, fields in generator:
367367
formatted_fields = []
@@ -405,7 +405,7 @@ class InodePages(plugins.PluginInterface):
405405

406406
_required_framework_version = (2, 0, 0)
407407

408-
_version = (2, 0, 1)
408+
_version = (2, 0, 2)
409409

410410
@classmethod
411411
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
@@ -436,8 +436,9 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
436436
),
437437
]
438438

439-
@staticmethod
439+
@classmethod
440440
def write_inode_content_to_file(
441+
cls,
441442
inode: interfaces.objects.ObjectInterface,
442443
filename: str,
443444
open_method: Type[interfaces.plugins.FileHandlerInterface],

volatility3/framework/plugins/linux/vmayarascan.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class VmaYaraScan(interfaces.plugins.PluginInterface):
1818
"""Scans all virtual memory areas for tasks using yara."""
1919

2020
_required_framework_version = (2, 4, 0)
21-
_version = (1, 0, 2)
21+
_version = (1, 0, 3)
2222

2323
@classmethod
2424
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
@@ -105,8 +105,9 @@ def _generator(self):
105105
value,
106106
)
107107

108-
@staticmethod
108+
@classmethod
109109
def get_vma_maps(
110+
cls,
110111
task: interfaces.objects.ObjectInterface,
111112
) -> Iterable[Tuple[int, int]]:
112113
"""Creates a map of start/end addresses for each virtual memory area in a task.

volatility3/framework/plugins/windows/cachedump.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Cachedump(interfaces.plugins.PluginInterface):
2222
"""Dumps lsa secrets from memory"""
2323

2424
_required_framework_version = (2, 0, 0)
25-
_version = (1, 0, 0)
25+
_version = (1, 0, 1)
2626

2727
@classmethod
2828
def get_requirements(cls):
@@ -43,16 +43,16 @@ def get_requirements(cls):
4343
),
4444
]
4545

46-
@staticmethod
46+
@classmethod
4747
def get_nlkm(
48-
sechive: registry.RegistryHive, lsakey: bytes, is_vista_or_later: bool
48+
cls, sechive: registry.RegistryHive, lsakey: bytes, is_vista_or_later: bool
4949
):
5050
return lsadump.Lsadump.get_secret_by_name(
5151
sechive, "NL$KM", lsakey, is_vista_or_later
5252
)
5353

54-
@staticmethod
55-
def decrypt_hash(edata: bytes, nlkm: bytes, ch, xp: bool):
54+
@classmethod
55+
def decrypt_hash(cls, edata: bytes, nlkm: bytes, ch, xp: bool):
5656
if xp:
5757
hmac_md5 = HMAC.new(nlkm, ch)
5858
rc4key = hmac_md5.digest()
@@ -69,8 +69,8 @@ def decrypt_hash(edata: bytes, nlkm: bytes, ch, xp: bool):
6969
data += aes.decrypt(buf)
7070
return data
7171

72-
@staticmethod
73-
def parse_cache_entry(cache_data: bytes) -> Tuple[int, int, int, bytes, bytes]:
72+
@classmethod
73+
def parse_cache_entry(cls, cache_data: bytes) -> Tuple[int, int, int, bytes, bytes]:
7474
(uname_len, domain_len) = unpack("<HH", cache_data[:4])
7575
if len(cache_data[60:62]) == 0:
7676
return (uname_len, domain_len, 0, b"", b"")
@@ -79,9 +79,9 @@ def parse_cache_entry(cache_data: bytes) -> Tuple[int, int, int, bytes, bytes]:
7979
enc_data = cache_data[96:]
8080
return (uname_len, domain_len, domain_name_len, enc_data, ch)
8181

82-
@staticmethod
82+
@classmethod
8383
def parse_decrypted_cache(
84-
dec_data: bytes, uname_len: int, domain_len: int, domain_name_len: int
84+
cls, dec_data: bytes, uname_len: int, domain_len: int, domain_name_len: int
8585
) -> Tuple[str, str, str, bytes]:
8686
"""Get the data from the cache and separate it into the username, domain name, and hash data"""
8787
uname_offset = 72

volatility3/framework/plugins/windows/direct_system_calls.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class DirectSystemCalls(interfaces.plugins.PluginInterface):
5353
"""Detects the Direct System Call technique used to bypass EDRs"""
5454

5555
_required_framework_version = (2, 4, 0)
56-
_version = (1, 0, 0)
56+
_version = (1, 0, 1)
5757

5858
# DLLs that are expected to host system call invocations
5959
valid_syscall_handlers = ("ntdll.dll", "win32u.dll")
@@ -200,8 +200,8 @@ def _is_syscall_block(
200200

201201
return disasm_bytes, end_inst
202202

203-
@staticmethod
204-
def get_disasm_function(architecture: str) -> Callable:
203+
@classmethod
204+
def get_disasm_function(cls, architecture: str) -> Callable:
205205
"""
206206
Returns the disassembly handler for the given architecture
207207
.detail is used to get full instruction information
@@ -284,8 +284,9 @@ def _is_valid_syscall(
284284

285285
return None
286286

287-
@staticmethod
287+
@classmethod
288288
def get_vad_maps(
289+
cls,
289290
task: interfaces.objects.ObjectInterface,
290291
) -> List[Tuple[int, int, str]]:
291292
"""Creates a map of start/end addresses within a virtual address
@@ -310,9 +311,9 @@ def get_vad_maps(
310311

311312
return vads
312313

313-
@staticmethod
314+
@classmethod
314315
def get_range_path(
315-
ranges: List[Tuple[int, int, str]], address: int
316+
cls, ranges: List[Tuple[int, int, str]], address: int
316317
) -> Optional[str]:
317318
"""
318319
Returns the path for the range holding `address`, if found

volatility3/framework/plugins/windows/mftscan.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MFTScan(interfaces.plugins.PluginInterface, timeliner.TimeLinerInterface):
2222

2323
_required_framework_version = (2, 0, 0)
2424

25-
_version = (2, 0, 0)
25+
_version = (2, 0, 1)
2626

2727
@classmethod
2828
def get_requirements(cls):
@@ -37,8 +37,9 @@ def get_requirements(cls):
3737
),
3838
]
3939

40-
@staticmethod
40+
@classmethod
4141
def enumerate_mft_records(
42+
cls,
4243
context: interfaces.context.ContextInterface,
4344
config_path: str,
4445
primary_layer_name: str,
@@ -128,8 +129,9 @@ def enumerate_mft_records(
128129
layer_name=layer.name,
129130
)
130131

131-
@staticmethod
132+
@classmethod
132133
def parse_mft_records(
134+
cls,
133135
record_map: Dict[int, Tuple[str, int, int]],
134136
mft_record: interfaces.objects.ObjectInterface,
135137
attr: interfaces.objects.ObjectInterface,
@@ -191,8 +193,9 @@ def parse_mft_records(
191193
file_name,
192194
)
193195

194-
@staticmethod
196+
@classmethod
195197
def parse_data_record(
198+
cls,
196199
mft_record: interfaces.objects.ObjectInterface,
197200
attr: interfaces.objects.ObjectInterface,
198201
record_map: Dict[int, Tuple[str, int, int]],
@@ -325,7 +328,7 @@ class ADS(interfaces.plugins.PluginInterface):
325328

326329
_required_framework_version = (2, 7, 0)
327330

328-
_version = (1, 0, 0)
331+
_version = (1, 0, 1)
329332

330333
@classmethod
331334
def get_requirements(cls):
@@ -343,8 +346,9 @@ def get_requirements(cls):
343346
),
344347
]
345348

346-
@staticmethod
349+
@classmethod
347350
def parse_ads_data_records(
351+
cls,
348352
record_map: Dict[int, Tuple[str, int, int]],
349353
mft_record: interfaces.objects.ObjectInterface,
350354
attr: interfaces.objects.ObjectInterface,
@@ -394,7 +398,7 @@ class ResidentData(interfaces.plugins.PluginInterface):
394398

395399
_required_framework_version = (2, 7, 0)
396400

397-
_version = (1, 0, 0)
401+
_version = (1, 0, 1)
398402

399403
@classmethod
400404
def get_requirements(cls):
@@ -412,8 +416,9 @@ def get_requirements(cls):
412416
),
413417
]
414418

415-
@staticmethod
419+
@classmethod
416420
def parse_first_data_records(
421+
cls,
417422
record_map: Dict[int, Tuple[str, int, int]],
418423
mft_record: interfaces.objects.ObjectInterface,
419424
attr: interfaces.objects.ObjectInterface,

volatility3/framework/plugins/windows/netscan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NetScan(interfaces.plugins.PluginInterface, timeliner.TimeLinerInterface):
2323
"""Scans for network objects present in a particular windows memory image."""
2424

2525
_required_framework_version = (2, 0, 0)
26-
_version = (1, 0, 0)
26+
_version = (1, 0, 1)
2727

2828
@classmethod
2929
def get_requirements(cls):
@@ -50,9 +50,9 @@ def get_requirements(cls):
5050
),
5151
]
5252

53-
@staticmethod
53+
@classmethod
5454
def create_netscan_constraints(
55-
context: interfaces.context.ContextInterface, symbol_table: str
55+
cls, context: interfaces.context.ContextInterface, symbol_table: str
5656
) -> List[poolscanner.PoolConstraint]:
5757
"""Creates a list of Pool Tag Constraints for network objects.
5858

0 commit comments

Comments
 (0)