Skip to content

Commit a4ad727

Browse files
committed
temp
1 parent cd8690a commit a4ad727

File tree

7 files changed

+78
-16
lines changed

7 files changed

+78
-16
lines changed

kovid.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"check_modules": false,
3+
"hidden_modules": false,
4+
"kernel.class": "volatility3.framework.contexts.Module",
5+
"kernel.layer_name.class": "volatility3.framework.layers.intel.LinuxIntel32e",
6+
"kernel.layer_name.kernel_banner": "Linux version 5.15.0-87-generic (buildd@lcy02-amd64-011) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #97-Ubuntu SMP Mon Oct 2 21:09:21 UTC 2023 (Ubuntu 5.15.0-87.97-generic 5.15.122)\n\u0000",
7+
"kernel.layer_name.kernel_virtual_offset": 310378496,
8+
"kernel.layer_name.memory_layer.base_layer.class": "volatility3.framework.layers.physical.FileLayer",
9+
"kernel.layer_name.memory_layer.base_layer.location": "file:///mnt/hgfs/memory_samples/x64/linux/Ubuntu-jammy_5.15.0-87-generic_kovid.lime",
10+
"kernel.layer_name.memory_layer.class": "volatility3.framework.layers.lime.LimeLayer",
11+
"kernel.layer_name.page_map_offset": 385941504,
12+
"kernel.offset": 310378496,
13+
"kernel.symbol_table_name.class": "volatility3.framework.symbols.linux.LinuxKernelIntermedSymbols",
14+
"kernel.symbol_table_name.isf_url": "file:///home/xyz/Desktop/volatility3_2/volatility3/symbols/linux/Ubuntu_5.15.0-87-generic_5.15.0-87.97_amd64.json",
15+
"kernel.symbol_table_name.symbol_mask": 281474976710655,
16+
"linux-tainting": false,
17+
"lsmod": false,
18+
"plain_taints": true
19+
}

result.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

volatility3/cli/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,16 @@ def run(self):
499499
renderer.filter = text_filter.CLIFilter(grid, args.filters)
500500
renderer.column_hide_list = args.hide_columns
501501
renderer.render(grid)
502+
except exceptions.UnsatisfiedException as excp:
503+
output = sys.stderr
504+
output.write(
505+
"An unsatisfied internal framework requirement was encountered during a plugin run:\n"
506+
)
507+
self.process_unsatisfied_exceptions(excp)
508+
output.write(
509+
f"Unable to validate the requirements: {[x for x in excp.unsatisfied]}\n",
510+
)
511+
sys.exit(1)
502512
except exceptions.VolatilityException as excp:
503513
self.process_exceptions(excp)
504514

volatility3/framework/configuration/requirements.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
import os
1414
from typing import Any, ClassVar, Dict, List, Optional, Set, Tuple, Type
1515
from urllib import parse, request
16+
from functools import wraps
1617

17-
from volatility3.framework import constants, interfaces
18+
from volatility3.framework import constants, interfaces, exceptions
1819

1920
vollog = logging.getLogger(__name__)
2021

@@ -599,6 +600,30 @@ def matches_required(
599600
return False
600601
return True
601602

603+
@staticmethod
604+
def version_requirement_wrapper(**kwargs):
605+
"""Wrapper to be used as a decorator,
606+
to check version requirements dynamically.
607+
Useful for classes that cannot produce requirements.
608+
"""
609+
610+
def decorator(func):
611+
@wraps(func)
612+
def wrapper(*func_args, **func_kwargs):
613+
req = VersionRequirement(**kwargs)
614+
if not req.matches_required(req._version, req._component.version):
615+
full_unsat_req_path = (
616+
func.__module__ + "." + func.__name__ + "." + req.name
617+
)
618+
# Catched by the cli and redirected to process_unsatisfied_exceptions
619+
raise exceptions.UnsatisfiedException({full_unsat_req_path: req})
620+
# Call the original function with all its arguments
621+
return func(*func_args, **func_kwargs)
622+
623+
return wrapper
624+
625+
return decorator
626+
602627

603628
class PluginRequirement(VersionRequirement):
604629
def __init__(

volatility3/framework/interfaces/symbols.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import bisect
66
import collections.abc
77
from abc import ABC, abstractmethod
8-
from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type
8+
from typing import Any, Dict, Iterable, List, Mapping, Optional, Set, Tuple, Type
99

1010
from volatility3.framework import constants, exceptions, interfaces
1111
from volatility3.framework.configuration import requirements
@@ -130,8 +130,8 @@ def symbols(self) -> Iterable[str]:
130130
# ## Required Type functions
131131

132132
@property
133-
def types(self) -> Iterable[str]:
134-
"""Returns an iterator of the Symbol type names."""
133+
def types(self) -> Set[str]:
134+
"""Returns a set containing the symbol type names."""
135135
raise NotImplementedError(
136136
"Abstract property types not implemented by subclass."
137137
)

volatility3/framework/symbols/intermed.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import os
1111
import pathlib
1212
import zipfile
13+
import collections
14+
1315
from abc import ABCMeta
1416
from typing import Any, Dict, Generator, Iterable, List, Mapping, Optional, Tuple, Type
1517

@@ -410,19 +412,24 @@ def get_symbol(self, name: str) -> interfaces.symbols.SymbolInterface:
410412
return self._symbol_cache[name]
411413

412414
@property
413-
def symbols(self) -> Iterable[str]:
414-
"""Returns an iterator of the symbol names."""
415-
return list(self._json_object.get("symbols", {}))
415+
def symbols(self) -> collections.abc.KeysView[str]:
416+
"""Returns a dictview of the symbol names."""
417+
return self._json_object.get("symbols", {}).keys()
416418

417419
@property
418-
def enumerations(self) -> Iterable[str]:
419-
"""Returns an iterator of the available enumerations."""
420-
return list(self._json_object.get("enums", {}))
420+
def enumerations(self) -> collections.abc.KeysView[str]:
421+
"""Returns a dictview of the available enumerations."""
422+
return self._json_object.get("enums", {}).keys()
421423

422424
@property
423-
def types(self) -> Iterable[str]:
424-
"""Returns an iterator of the symbol type names."""
425-
return list(self._json_object.get("user_types", {})) + list(self.natives.types)
425+
def types(self) -> collections.abc.KeysView[str]:
426+
"""Returns a dictview of the symbol type names."""
427+
# self.natives.types is very small compared to user_types, so the dict overhead
428+
# can be neglected
429+
return {
430+
**self._json_object.get("user_types", {}),
431+
**dict.fromkeys(self.natives.types),
432+
}.keys()
426433

427434
def get_type_class(self, name: str) -> Type[interfaces.objects.ObjectInterface]:
428435
return self._overrides.get(name, objects.AggregateType)

volatility3/framework/symbols/native.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
import copy
6-
from typing import Any, Dict, Iterable, Optional, Type
6+
from typing import Any, Dict, Optional, Set, Type
77

88
from volatility3.framework import constants, interfaces, objects
99

@@ -29,8 +29,8 @@ def get_type_class(self, name: str) -> Type[interfaces.objects.ObjectInterface]:
2929
return ntype
3030

3131
@property
32-
def types(self) -> Iterable[str]:
33-
"""Returns an iterator of the symbol type names."""
32+
def types(self) -> Set[str]:
33+
"""Returns a set containing the symbol type names."""
3434
return self._types
3535

3636
def get_type(self, type_name: str) -> interfaces.objects.Template:

0 commit comments

Comments
 (0)