Commit Graph
100 Commits
Author SHA1 Message Date
David McDonald e40adbb7f9 Linux Utilities: Yield directly from iterator
Instead of constructing a dict and yielding from `.values()` directly,
yields values as they are yielded from the underlying call to
`get_kset_modules`.
2025-04-21 10:27:50 -05:00
David McDonald 8e35fb40ca Linux Utilities: Sort imports 2025-04-21 10:27:50 -05:00
David McDonald 7e0a05c4fa Linux Plugins: Bump 'Modules' dependency versions 2025-04-21 10:27:50 -05:00
David McDonald 778f244005 Linux: Update get_kset_modules callers
Updates all calls to `get_kset_modules` to correctly use the new
iterator return type
2025-04-21 10:20:59 -05:00
David McDonald 8ac7505750 Linux Utilities: Improve get_kset_modules signature
Returning a `dict` leads to an all-or-nothing result, where you either
get the complete set of modules, or an exception is encountered and
raised and you get nothing. Using an iterator allows for as many
readable modules to be yielded as possible, and the caller can still
catch any `InvalidAddressException` that gets thrown during iteration.
2025-04-21 10:20:59 -05:00
David McDonald 241e81b164 Linux Utilities: Handle InvalidAddressException
Catches a possible `InvalidAddressException` that can be raised from the
call to `vmlinux.object_from_symbol("module_kset")`.
2025-04-21 10:20:56 -05:00
David McDonald 2199375dd5 Tests: Add symlinkscan specific test 2025-04-15 10:49:43 -05:00
David McDonald 32e9cee6dd Tests: Add Symlinkscan generic test
This should be enough to prevent serious regressions that break all
output.
2025-04-15 10:49:43 -05:00
David McDonald d745a62d7f PoolScanner: Patch version bump
Bumping the patch version due to bugfix.
2025-04-15 10:21:52 -05:00
David McDonald 02fbb3ce49 Poolscanners: Fix symlink pool types
Fixes regression introduced in #1632

Symbolic links are allocated in the paged pools, not non-paged. This was
causing us to miss symlinks across both pre and post win8 samples.
2025-04-15 10:14:58 -05:00
David McDonald d29be5cbde Linux MountInfo: Remove unneeded cast 2025-04-14 18:38:47 -05:00
David McDonald a236c0dd40 linux.pagecache.Files: Trim unneeded cast
Removes casts to `int` performed before checking set membership, since
the computed `__hash__` value will be the same for both the Python
primitive and the volatility `objects.Pointer`.
2025-04-14 18:30:19 -05:00
David McDonald 9ceec51b76 Pagecache: Add comments explaining cast
Adds a couple of comments explaining why we're doing a lossy conversion
to Python `int` (saving memory).
2025-04-14 18:25:17 -05:00
David McDonald c641690c53 Pagecache: revert cast to int
`dentry.vol.offset` is already a basic Python `int`.
2025-04-14 18:25:17 -05:00
David McDonald 3b723f8be3 Linux pagecache.Files: Memory Usage
Converts `objects.Pointer` to `int` before storing them in the set. This
should have a substantial impact on memory, similar to those in #1758
2025-04-14 18:25:17 -05:00
David McDonald 2e206fe698 Add keywords to parameters 2025-04-14 17:17:02 -05:00
David McDonald 91e23e0c71 Bumps patch version for pslist plugins 2025-04-14 17:15:28 -05:00
David McDonald 8f9bebdc86 Linux PsList: Fix process list traversal
Fixes linux process listing by traversing the list backwards as well as
forwards while tracking seen process offsets to avoid duplicates.
2025-04-14 17:12:46 -05:00
David McDonald 17f9d218c9 Windows PsList: Fix list traversal logic
The traversal of `ActiveProcessLinks` from `PsActiveProcessHead` was
only being done in the forward direction; if for some reason
`PsActiveProcessHead` hasn't been updated to point at the 'current' list
head, entries in the backwards traversal direction will be missed.
2025-04-14 17:12:08 -05:00
David McDonald 62bd41980b Shimcache: Use self.Path.vol.count instead of hardcoded value 2025-04-14 11:43:57 -05:00
David McDonald 1d4893156e Shimcache Extension: Fix logic error in exec_flag
Adds needed return statements in `exec_flag` method in order to avoid
`InvalidAddressException` when reading from invalid memory after an
`is_valid` check has already been performed.
2025-04-14 11:43:57 -05:00
David McDonald 079d2801f5 ShimcacheMem: Fix offset tracking
This fixes a bug in the plugin logic that causes valid entries to be
excluded in the following scenario:

- An entry is discovered but deemed invalid due to unreadable
  size/timestamps.
- The offset gets placed into the `seen` tracking set anyway
- Another entry (this time, with valid filesize/timestamps) with the
  same physical offset is encountered, but is skipped because this
  offset is already in the `seen` tracking set.

This updates the logic to only add the offset to the tracker if the
shimcache entry is valid.
2025-04-14 11:43:57 -05:00
David McDonald b80c52873b ShimcacheMem: Use address_to_string
Uses the new `address_to_string` utility function to read filepaths, in
case a filepath crosses a boundary to a swapped page.
2025-04-14 11:43:57 -05:00
David McDonald 87cc571fbb ShimcacheMem: Fix symbol table
These SHIM_CACHE_ENTRY offsets aren't correct - should be identical to
those in the other XP symbol tables.
2025-04-14 11:43:57 -05:00
David McDonald 03e750648f Windows Extensions: remove lru_cache decorators
These don't offer enough upside to be worthwhile compared to the
decorators applied to the `add_process_layer` methods.
2025-04-14 09:20:32 -05:00
David McDonald c48ad901b0 Extensions: Add cache decorators as appropriate
I noticed that many plugins were creating duplicate per-process
translation layers - for instance, `windows.envars.Envars` was ending up
with > 30 process layers per process due to repeated calls to
`get_peb()`, which calls `add_process_space()` internally.

This adds `@functools.lru_cache` to the `get_peb()` and `get_peb32()`
methods on the `EPROCESS` extension, since these should only need to be
created once.

Also adds `@functools.lru_cache` to `add_process_space` to enable
reusing the same process address space, provided the same arguments are
passed to the `add_process_space()` method.
2025-04-10 14:57:46 -05:00
David McDonald b82458e365 Windows Thrdscan: Convert from PATCH to MINOR version bump 2025-04-10 09:51:32 -05:00
David McDonald 6237950991 Windows: Revert unneeded version bumps 2025-04-10 09:50:49 -05:00
David McDonald 7192730dea Layers: Fix exception message
Updates the exception message to report the correct dependency instead
of the layer name itself. Instead of reporting the actual dependency, it
was reporting, for example 'Layer layer_name is depended upon by
layer_name'.
2025-04-09 22:55:50 -05:00
David McDonald f091641920 Framework: Bump patch version number
Bumping the framework patch version number due to bugfix in windows'
`EPROCESS` extension class' `is_valid()` method.
2025-04-09 21:50:36 -05:00
David McDonald da73a50662 Windows ThrdScan: Bump patch version number
Bumping patch version due to bug fixes.
2025-04-09 21:49:42 -05:00
David McDonald b35f0a29bc Windows: Remove VAD length check in thread enumeration
This exclusion of threads where there are < 5 vads seems to filter valid
threads (at least, threads where the start address or Win32 start
address values are readable and valid disassembly, and the start time
makes sense in the context of the parent process).
2025-04-08 17:17:53 -05:00
David McDonald aba3b04e8d Windows Thrdscan: Fix thread filtering + tracebacks
Tracebacks were occurring across a number of samples when running the
threads/threadscan plugins due to uncaught `InvalidAddressExceptions`.
Further investigations led to the discovery of some incorrect thread
filtering that was missing valid threads.
2025-04-08 17:17:40 -05:00
David McDonald 64ecd65d2c Windows: Improve type-hints in thrdscan, extensions
This improves type-hinting in the `ThrdScan` class and in the `ETHREAD`
extension class through narrowing the return type of some methods from
`interfaces.objects.ObjectInterface` to their actual return type,
`extensions.ETHREAD`.

Also creates a `NamedTuple` for holding thread info, which cleans up the
type signature and makes the returned value easier for consumers to use.
2025-04-08 17:17:40 -05:00
David McDonald 4045b6cc8e InodePages: Add output column and render when dumped
Previously, the InodePages plugin wasn't rendering treegrid columns when
the `--dump` flag was passed. This fixes that, and adds an additional
`Output File` column that displays the name of the file containing the
dumped data.
2025-04-08 09:30:31 -05:00
David McDonald 195f4154e9 Shorten suffix 2025-04-07 16:18:22 -05:00
David McDonald e9a4ea1a9c Fix traceback in volshell's dt()
A `SymbolError` can occur when a type contains a pointer to an opaque
type. For example, `_EPROCESS` can have a member that points to an
`_EPROCESS_QUOTA_BLOCK`, but there is no definition for that type, so
its size and readability can't be determined.

This wraps the block in a try/except, and reports that the type has an
unknown size in the suffix if a `SymbolError` occurs.
2025-04-07 15:39:23 -05:00
David McDonald 39b3e76efc Add a filename to STANDARD_INFORMATION timeline entries 2025-04-04 17:46:46 -05:00
David McDonald a0ca33b284 Also yield STANDARD_INFORMATION timestamps in timeliner 2025-04-04 11:30:27 -05:00
David McDonald b15e9104e8 Rename methods, add docstrings
Improves the naming of a couple of the new extension class methods to
more accurately reflect the return type, and adds docstrings to
extensions class methods.
2025-04-04 10:32:13 -05:00
David McDonald 8428e81f03 Fix up remaining type-hints
Updates type hints on some fields of the result namedtuples to be their
`objects.Primitive` types instead of Python primitives, and does any
conversion to Python primitives in the generator methods.
2025-04-04 10:30:46 -05:00
David McDonald a5dfc6acb3 Bump required framework version on all three MFTScan plugins 2025-04-03 18:06:23 -05:00
David McDonald de117042fe Remove symbol_table_name from object constructor
Get from `self.vol.type_name` instead
2025-04-03 18:04:43 -05:00
David McDonald 41de562e55 Revert "Add versioning to MFT extension classes"
This reverts commit 1d20e65759.
2025-04-03 17:56:16 -05:00
David McDonald ebbbe913dc Convert remaining values to Python primitives 2025-04-03 17:55:42 -05:00
David McDonald 1d20e65759 Add versioning to MFT extension classes 2025-04-03 17:39:14 -05:00
David McDonald 8b308133f5 Bump required version numbers 2025-04-03 17:32:25 -05:00
David McDonald 9f85e1465e Major version bumps for all three plugins 2025-04-03 17:19:17 -05:00
David McDonald 5fda7409eb Log InvalidAddressException instances 2025-04-03 17:18:20 -05:00
David McDonald 41cf17ed65 Refactor: Ditch dictionary usage, eliminate callbacks
This simplifies the design of these plugins by moving as much MFTEntry
specific data into the extension class (caching attributes, since
they'll need to be accessed repeatedly) and moving away from the
callback-based implementation to one where classmethods consume
`mft.MFTEntry` objects in order to produce their values.

These changes do two important things:
- They allow us to preserve `object.String` objects until the generator
  function, which makes the public interface much better since people
  can navigate back the the source of the data within their context
- Completely eliminates the `record_map` that was causing so much memory
  consumption.
2025-04-03 17:18:20 -05:00
David McDonald 43e6fefe39 Add attribute iterator to MFTEntry extension class 2025-04-03 11:33:56 -05:00
David McDonald 4492da0263 Create attribute iterator method
Moves logic for iterating through `MFTEntry` attributes into a new
`attributes()` method on the extension class.
2025-04-03 10:40:05 -05:00
David McDonald e84036c5a6 Add missing 'e' to variable names 2025-04-03 10:02:08 -05:00
David McDonald 86c5c16ed6 Windows MFTScan Plugins: Performance fixes
There was a subtle issue that was causing substantial performance issues
in the MFTScan plugins. The `record_map` was purportedly of type
`Dict[str, Tuple[int, str, int]]`, but in reality, the second member was
a list, and its `str` item was actually being populated with unprocessed
values from method calls on the MFT extension classes, which actually
return `object.String`. These objects are substantially larger than
basic `str` types:

```
[ins] In [5]: pympler.asizeof.asizeof(rec_name)
Out[5]: 312648

[ins] In [6]: pympler.asizeof.asizeof(str(rec_name))
Out[6]: 64
```

This caused this dictionary to grow in size to several gigabytes on
larger samples, resulting in thrashing and OOM errors.
2025-04-02 15:46:47 -05:00
David McDonald 3c3b2b3bbd MFT Extensions: Fix type hints
These type hints are a bit misleading, and have been updated to reflect
their real return type.
2025-04-02 15:16:15 -05:00
David McDonald 5befbf8629 Tests: Fix MFTScan testdata
These test values needed updating now that the `LayerData` type is used
and presents the data a little differently than before.
2025-04-02 14:08:18 -05:00
David McDonald e446c1081d Remove debugging call 2025-04-02 09:43:20 -05:00
David McDonald 0b1bbb87ee Windows Tests: Update userassist JSON output
The new layer data type renders the output a little differently, and the
plugin also seems to render 'N/A' for a missing value where previously
it was an empty string.
2025-04-02 09:36:07 -05:00
David McDonald 1412004422 Make registry_layers -> registry_layer for consistency 2025-03-29 15:56:25 -05:00
David McDonald c17bcb644b Revert changes to intel.py 2025-03-29 15:51:19 -05:00
David McDonald ee3d965ef6 Revert changes to configuration.py 2025-03-29 15:50:36 -05:00
David McDonald 296cb3c113 Code Analysis: Give pass to 'volatility3'
Also moves some code into a private method with a docstring in the
visitor class.
2025-03-29 15:49:33 -05:00
David McDonald f72b717c00 Comment type annotation to fix circular import 2025-03-29 15:49:33 -05:00
David McDonald a3353a3cb6 CI Testing: Renames script and updates job name 2025-03-29 15:49:33 -05:00
David McDonald 47646c12d4 Framework: Fix all direct non-module imports
This fixes all import from statements in the codebase that were
importing things other than modules into module namespaces from other
volatility3 modules. This should prevent accidental re-exporting.
2025-03-29 15:49:33 -05:00
David McDonald e62cee391a Testing: Adds validation of vol3 imports in check script
This checks `ast.ImportFrom` statements to see if anything other than
modules are being imported in this way. It enumerates all instances of
this and suggests a fix.
2025-03-29 15:49:33 -05:00
David McDonald 6452fc18bd Tone down language severity in messages 2025-03-28 15:39:09 -05:00
David McDonald d7695ab9cf Simplify error message output 2025-03-28 15:36:54 -05:00
David McDonald 46e3b8ffdb Check for 'hidden' attribute when determining classes to validate 2025-03-28 15:22:37 -05:00
David McDonald 196556eab3 Test: Allow for other types of coding style violations 2025-03-28 15:18:22 -05:00
David McDonald d0a1daf82c ModuleExtract: Add missing requirement 2025-03-28 13:24:51 -05:00
David McDonald 27e59263a6 Docstring: explain version-checking script
This documents the general behavior and expectations of the
version-checking CI script.
2025-03-28 13:22:01 -05:00
David McDonald 03c6477902 Volshell: Attempt to resolve requirement conflicts
This change sets the `script`, `script-only`, and `primary` requirements
to only apply to the `generic.Volshell` class. `regex-scanner` is okay
to be shared between the base and inherited classes, but `script` and
`script-only` have to be generic-only in order to avoid conflicts when
populating the argparse parser.

`primary` must be generic-only in order to avoid ending up unsatisfied
when superclass requirements require a module, suppressing construction
of the `primary` layer.
2025-03-28 13:22:01 -05:00
David McDonald 9f024cf0f4 Refactor: use builtin ast lib instead of treesitter
Instead of using the tree-sitter third party library, this uses Python's
`ast` module to parse the source code and traverse the tree with a
visitor pattern. This is preferred because it's native to the language
itself, and Python developers are more likely to be familiar with it.
The traversal also handles nested scopes better than the prior
implementation. For example, classes that are declared inside of other
classes can now be looked up even though they don't exist at the top
level of the module namespace, since any time a class definition is
entered, that class is pushed to the top of a stack that can be examined
when visiting inner classes.

This also adds lots of log messages at different levels, plus a command
line argument for specifying verbosity, which should help with debugging
down the line.
2025-03-28 13:22:01 -05:00
David McDonald 68116556a8 Add calls to super().get_requirements() on inherited classes 2025-03-28 13:22:01 -05:00
David McDonald 0f73686364 Framework: Fix remaining missing requirements
This adds all of the missing requirements discovered via the new code
analysis script.
2025-03-28 13:22:01 -05:00
David McDonald 2ad1536b4e Testing: Verify VersionRequirements
This adds a script and GitHub action to the `test` directory that
dynamically imports all modules in `volatility3`, searches for usages of
`VersionableInterface` objects within classes that inherit from
`ConfigurableInterface` but don't enumerate the used component as a
requirement in `get_requirements()`, and returns -1 if any violations
are found.

Fixes
2025-03-28 13:21:10 -05:00
David McDonald 1c21b3cd04 Consoles: Fix requirement versions
When I updated the requirements for `Consoles` in #1738, I bumped the
version number on the `VerInfo` requirement instead of on the `Info`
requirement.

closes #1741
2025-03-26 09:07:32 -05:00
David McDonald 66992a5d9a Requirements: Insert missing version requirements
This audits the entire codebase for missing `VersionRequirements` and
adds them as needed.
2025-03-25 17:44:35 -05:00
David McDonald d5fc050224 Timeliner: add VersionableInterface superclass
This adds `interfaces.configuration.VersionableInterface` as a
superclass to `TimelinerInterface` in order to be consistent with other
versioned interfaces such as `PluginInterface`.
2025-03-25 17:44:35 -05:00
David McDonald a6f9a0e95b Framework: Replace PluginRequirements
This replaces all uses of `requirements.PluginRequirements` with
`requirements.VersionRequirement`.
2025-03-24 11:30:17 -05:00
David McDonald d097d6abeb Timers: convert general Exception to InvalidAddressException 2025-03-20 15:18:08 -05:00
David McDonald c4589a51d5 Timers: Adds debug log statement to catch-all exception 2025-03-20 15:13:26 -05:00
David McDonald 1e175b5d3b Objects: rework new get_raw_value() method
Per code review recommendations, splits the `_unmarshall` classmethod
into two components, one of which retrieves the raw value, and the other
that returns the masked pointer. The `get_raw_value` method now calls
the `_get_raw_value` classmethod using its instance information.
2025-03-20 15:11:37 -05:00
David McDonald 144fd3139a Framework: Minor version bump
Made an additive change to `Pointer` by adding the `get_raw_value()`
method, so bumping the minor version here. The `get_raw_dpc()` method
was removed from the `KTIMER` extension class, which is currently
unversioned.
2025-03-20 14:38:19 -05:00
David McDonald a8ea3aae01 Extensions: Removes the get_raw_dpc method from KTIMER
This removes the `get_raw_dpc` method from the `KTIMER` extension class.
This method was inaccurate in that it actually returns the masked
pointer value instead of the full 64-bit value encoded in that member,
which is required in order to correctly decode the 'real' pointer.

The invocation of `get_raw_dpc()` was replaced with
`self.Dpc.get_raw_value()`, which was added in the previous commit.
2025-03-20 14:32:04 -05:00
David McDonald 7b9fb91672 Objects: create get_raw_value() method for Pointer
This creates a `get_raw_value()` method for the `Pointer` class that
allows users to access the raw (unmasked) value of a pointer. This was
required in order to decode the encoded `Dpc` pointer that is part of
the `_KTIMER` Windows type. Addition of this type was favored over a
cast to `unsigned long` or `unsigned long long` due to the potential for
future instability of this type due to compiler changes.

See https://github.com/volatilityfoundation/volatility3/issues/1041 for
further discussion around the conversion of `log unsigned int` to
`unsigned long` in `clang`.

See https://github.com/volatilityfoundation/volatility3/pull/1177#discussion_r1650049299
for the original discussion around how to access this pointer in the
`Timers` plugin.
2025-03-20 14:23:24 -05:00
David McDonald 2795c7cdd2 Windows: Fix raw Dpc offset calculation
The original code was still returning this as a pointer that ended up
dereferenced in later steps. However, this pointer value actually needs
to be cast to an `unsigned long long` and decoded first.
2025-03-19 15:45:26 -05:00
David McDonald 196bf8187d Volshell: Address comments from code review
- Add failure message when readline or rlcompleter can't be imported
- Fix unclosed file handle in context manager
2025-03-14 12:22:15 -05:00
David McDonald c3123e8839 Volshell: Handle script running in ipython shell 2025-03-13 17:17:17 -05:00
David McDonald fa2a93ade4 Volshell: Fix import logic around readline + rlcomplete 2025-03-13 17:09:56 -05:00
David McDonald 6f9f5c34b9 Feature: Add support for IPython in volshell 2025-03-13 16:37:31 -05:00
David McDonald 134a3bc686 Pdbconv: Make symbol server URL constant
This removes the hard-coded symbol server URL from
`PdbRetreiver.retrieve_pdb` and defines it as a constant within the
`constants` module.
2025-03-06 15:20:38 -06:00
David McDonald 7e00f2c4c4 Windows Versions: Fix broken OSDistinguisher
Something happened when picking _EPROCESS members before that caused
this to not function properly. This one relies on a more stable type
removal instead of _EPROCESS members.
2025-03-05 17:59:49 -06:00
David McDonald dc53afb217 Code Review: Don't use to-be-deprecated static natives
This was originally done to solve a problem where `f32` wasn't available
in the native types from every kernel version. However, it ended up not
being necessary - we can just omit `native_types` from the method call,
and it will construct the types as-needed using the definition for
`float` in `base_types` from the JSON files.
2025-03-05 17:59:49 -06:00
David McDonald e8ec7b1bf7 Code Review: Remove unneeded kernel module reconstruction 2025-03-05 17:59:49 -06:00
David McDonald 77d6bf25b0 Code Review: Remove redundant kernel module reconstruction 2025-03-05 17:59:49 -06:00
David McDonald 76cceb93cb Code Review: Get rid of 'kvo' in favor of kernel.offset 2025-03-05 17:59:49 -06:00
David McDonald a192546eb0 Framework: Minor version bump
There are a lot of things going into this so we're doing a minor
framework version bump.
2025-03-05 17:59:49 -06:00
David McDonald 456d7b7db5 CodeQL Fix: Unused variable
Also underscores an unused unpacked tuple value
2025-03-05 17:59:49 -06:00