Skip to content

Commit 42a89cf

Browse files
authored
Merge pull request #1037 from forensicxlab/feature/bucket-s3
Feature: Remote analysis on cloud object-storage.
2 parents 21af01d + 1f5a18d commit 42a89cf

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ pycryptodome
1616

1717
# This is required for memory acquisition via leechcore/pcileech.
1818
leechcorepyc>=2.4.0
19+
20+
# This is required for memory analysis on a Amazon/MinIO S3 and Google Cloud object storage
21+
gcsfs>=2023.1.0
22+
s3fs>=2023.1.0
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# This file is Copyright 2022 Volatility Foundation and licensed under the Volatility Software License 1.0
2+
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0
3+
#
4+
5+
import logging
6+
import urllib.parse
7+
from typing import Optional, Any, List
8+
9+
try:
10+
import s3fs
11+
12+
HAS_S3FS = True
13+
except ImportError:
14+
HAS_S3FS = False
15+
16+
try:
17+
import gcsfs
18+
19+
HAS_GCSFS = True
20+
except ImportError:
21+
HAS_GCSFS = False
22+
23+
from volatility3.framework import exceptions
24+
from volatility3.framework.layers import resources
25+
26+
vollog = logging.getLogger(__file__)
27+
28+
if HAS_S3FS:
29+
30+
class S3FileSystemHandler(resources.VolatilityHandler):
31+
@classmethod
32+
def non_cached_schemes(cls) -> List[str]:
33+
return ["s3"]
34+
35+
@staticmethod
36+
def default_open(req: urllib.request.Request) -> Optional[Any]:
37+
"""Handles the request if it's the s3 scheme."""
38+
if req.type == "s3":
39+
object_uri = "://".join(req.full_url.split("://")[1:])
40+
return s3fs.S3FileSystem().open(object_uri)
41+
return None
42+
43+
44+
if HAS_GCSFS:
45+
46+
class GSFileSystemHandler(resources.VolatilityHandler):
47+
@classmethod
48+
def non_cached_schemes(cls) -> List[str]:
49+
return ["gs"]
50+
51+
@staticmethod
52+
def default_open(req: urllib.request.Request) -> Optional[Any]:
53+
"""Handles the request if it's the gs scheme."""
54+
if req.type == "gs":
55+
object_uri = "://".join(req.full_url.split("://")[1:])
56+
return gcsfs.GCSFileSystem().open(object_uri)
57+
return None

0 commit comments

Comments
 (0)