Skip to content

Commit 131fb21

Browse files
author
Dave Lassalle
committed
Merge branch 'develop' into 816-port-cmdscan-and-console-plugins-from-vol2-to-vol3-please
2 parents ac08f42 + 6b739f6 commit 131fb21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+8911
-220
lines changed

vol.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python3
2+
# PYTHON_ARGCOMPLETE_OK
23

34
# This file is Copyright 2019 Volatility Foundation and licensed under the Volatility Software License 1.0
45
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0

volatility3/cli/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
from typing import Any, Dict, List, Tuple, Type, Union
2323
from urllib import parse, request
2424

25+
try:
26+
import argcomplete
27+
28+
HAS_ARGCOMPLETE = True
29+
except ImportError:
30+
HAS_ARGCOMPLETE = False
31+
2532
from volatility3.cli import text_filter
2633
import volatility3.plugins
2734
import volatility3.symbols
@@ -351,6 +358,10 @@ def run(self):
351358
# Hand the plugin requirements over to the CLI (us) and let it construct the config tree
352359

353360
# Run the argparser
361+
if HAS_ARGCOMPLETE:
362+
# The autocompletion line must be after the partial_arg handling, so that it doesn't trip it
363+
# before all the plugins have been added
364+
argcomplete.autocomplete(parser)
354365
args = parser.parse_args()
355366
if args.plugin is None:
356367
parser.error("Please select a plugin to run")

volatility3/cli/volargparse.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class HelpfulSubparserAction(argparse._SubParsersAction):
2121

2222
def __init__(self, *args, **kwargs) -> None:
2323
super().__init__(*args, **kwargs)
24-
# We don't want the action self-check to kick in, so we remove the choices list, the check happens in __call__
25-
self.choices = None
2624

2725
def __call__(
2826
self,
@@ -100,3 +98,20 @@ def _match_argument(self, action, arg_strings_pattern) -> int:
10098

10199
# return the number of arguments matched
102100
return len(match.group(1))
101+
102+
def _check_value(self, action: argparse.Action, value: Any) -> None:
103+
"""This is called to ensure a value is correct/valid
104+
105+
In normal operation, it would check that a value provided is valid and return None
106+
If it was not valid, it would throw an ArgumentError
107+
108+
When people provide a partial plugin name, we want to look for a matching plugin name
109+
which happens in the HelpfulSubparserAction's __call_method
110+
111+
To get there without tripping the check_value failure, we have to prevent the exception
112+
being thrown when the value is a HelpfulSubparserAction. This therefore affects no other
113+
checks for normal parameters.
114+
"""
115+
if not isinstance(action, HelpfulSubparserAction):
116+
super()._check_value(action, value)
117+
return None

volatility3/cli/volshell/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
plugins,
2222
)
2323

24+
try:
25+
import argcomplete
26+
27+
HAS_ARGCOMPLETE = True
28+
except ImportError:
29+
HAS_ARGCOMPLETE = False
30+
31+
2432
# Make sure we log everything
2533

2634
rootlog = logging.getLogger()
@@ -276,6 +284,10 @@ def run(self):
276284
# Hand the plugin requirements over to the CLI (us) and let it construct the config tree
277285

278286
# Run the argparser
287+
if HAS_ARGCOMPLETE:
288+
# The autocompletion line must be after the partial_arg handling, so that it doesn't trip it
289+
# before all the plugins have been added
290+
argcomplete.autocomplete(parser)
279291
args = parser.parse_args()
280292

281293
vollog.log(

volatility3/framework/constants/_version.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# We use the SemVer 2.0.0 versioning scheme
22
VERSION_MAJOR = 2 # Number of releases of the library with a breaking change
3-
VERSION_MINOR = 7 # Number of changes that only add to the interface
4-
VERSION_PATCH = 2 # Number of changes that do not change the interface
3+
VERSION_MINOR = 8 # Number of changes that only add to the interface
4+
VERSION_PATCH = 0 # Number of changes that do not change the interface
55
VERSION_SUFFIX = ""
66

7-
# TODO: At version 2.0.0, remove the symbol_shift feature
8-
97
PACKAGE_VERSION = (
108
".".join([str(x) for x in [VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH]])
119
+ VERSION_SUFFIX

volatility3/framework/objects/utility.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@
77
from volatility3.framework import interfaces, objects, constants
88

99

10+
def rol(value: int, count: int, max_bits: int = 64) -> int:
11+
"""A rotate-left instruction in Python"""
12+
max_bits_mask = (1 << max_bits) - 1
13+
return (value << count % max_bits) & max_bits_mask | (
14+
(value & max_bits_mask) >> (max_bits - (count % max_bits))
15+
)
16+
17+
18+
def bswap_32(value: int) -> int:
19+
value = ((value << 8) & 0xFF00FF00) | ((value >> 8) & 0x00FF00FF)
20+
21+
return ((value << 16) | (value >> 16)) & 0xFFFFFFFF
22+
23+
24+
def bswap_64(value: int) -> int:
25+
low = bswap_32((value >> 32))
26+
high = bswap_32((value & 0xFFFFFFFF))
27+
28+
return ((high << 32) | low) & 0xFFFFFFFFFFFFFFFF
29+
30+
1031
def array_to_string(
1132
array: "objects.Array", count: Optional[int] = None, errors: str = "replace"
1233
) -> interfaces.objects.ObjectInterface:

0 commit comments

Comments
 (0)