maco-extractor 1.2.18__tar.gz → 1.2.20__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {maco_extractor-1.2.18/maco_extractor.egg-info → maco_extractor-1.2.20}/PKG-INFO +1 -1
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/cli.py +34 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/collector.py +1 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/extractor.py +2 -1
- {maco_extractor-1.2.18 → maco_extractor-1.2.20/maco_extractor.egg-info}/PKG-INFO +1 -1
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/LICENSE.md +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/README.md +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/__init__.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/base_test.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/exceptions.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/model/__init__.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/model/model.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/utils.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco/yara.py +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco_extractor.egg-info/SOURCES.txt +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco_extractor.egg-info/dependency_links.txt +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco_extractor.egg-info/requires.txt +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco_extractor.egg-info/top_level.txt +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/pyproject.toml +0 -0
- {maco_extractor-1.2.18 → maco_extractor-1.2.20}/setup.cfg +0 -0
|
@@ -27,6 +27,7 @@ def process_file(
|
|
|
27
27
|
pretty: bool,
|
|
28
28
|
force: bool,
|
|
29
29
|
include_base64: bool,
|
|
30
|
+
extracted_dir: str = "",
|
|
30
31
|
):
|
|
31
32
|
"""Process a filestream with the extractors and rules.
|
|
32
33
|
|
|
@@ -37,6 +38,7 @@ def process_file(
|
|
|
37
38
|
pretty (bool): Pretty print the JSON output
|
|
38
39
|
force (bool): Run all extractors regardless of YARA rule match
|
|
39
40
|
include_base64 (bool): include base64'd data in output
|
|
41
|
+
extracted_dir (str): directory to write CaRTed binary data to
|
|
40
42
|
|
|
41
43
|
Returns:
|
|
42
44
|
(dict): The output from the extractors analyzing the sample
|
|
@@ -87,6 +89,34 @@ def process_file(
|
|
|
87
89
|
if include_base64:
|
|
88
90
|
# this can be large
|
|
89
91
|
row["base64"] = base64.b64encode(row["data"]).decode("utf8")
|
|
92
|
+
|
|
93
|
+
# write binary data to disk if enabled
|
|
94
|
+
if extracted_dir:
|
|
95
|
+
# only allow writes to already existing directories with permissions
|
|
96
|
+
if os.path.isdir(extracted_dir) and os.access(extracted_dir, os.W_OK):
|
|
97
|
+
filepath = os.path.abspath(os.path.join(extracted_dir, f"{row['sha256']}.cart"))
|
|
98
|
+
# don't overwrite existing files
|
|
99
|
+
if os.path.exists(filepath):
|
|
100
|
+
logger.debug(f"{filepath} already exists.")
|
|
101
|
+
else:
|
|
102
|
+
# CaRT data before writing to disk
|
|
103
|
+
in_stream = io.BytesIO(row["data"])
|
|
104
|
+
output_stream = io.BytesIO()
|
|
105
|
+
try:
|
|
106
|
+
cart.pack_stream(in_stream, output_stream)
|
|
107
|
+
except Exception:
|
|
108
|
+
logger.error(f"Error trying to CaRT binary output ({row['sha256']}) from {path_file}.")
|
|
109
|
+
else:
|
|
110
|
+
output_stream.seek(0)
|
|
111
|
+
try:
|
|
112
|
+
with open(filepath, "wb") as f:
|
|
113
|
+
f.write(output_stream.getbuffer())
|
|
114
|
+
logger.debug(f"Wrote binary output to {filepath}.")
|
|
115
|
+
except (FileNotFoundError, PermissionError, OSError):
|
|
116
|
+
logger.error(f"Error trying to write binary output to {filepath}")
|
|
117
|
+
else:
|
|
118
|
+
logger.error(f"Cannot write files to {extracted_dir}")
|
|
119
|
+
|
|
90
120
|
# do not print raw bytes to console
|
|
91
121
|
row.pop("data")
|
|
92
122
|
ret[extractor_name] = resp
|
|
@@ -107,6 +137,7 @@ def process_filesystem(
|
|
|
107
137
|
include_base64: bool,
|
|
108
138
|
create_venv: bool = False,
|
|
109
139
|
skip_install: bool = False,
|
|
140
|
+
extracted_dir: str = "",
|
|
110
141
|
) -> Tuple[int, int, int]:
|
|
111
142
|
"""Process filesystem with extractors and print results of extraction.
|
|
112
143
|
|
|
@@ -159,6 +190,7 @@ def process_filesystem(
|
|
|
159
190
|
pretty=pretty,
|
|
160
191
|
force=force,
|
|
161
192
|
include_base64=include_base64,
|
|
193
|
+
extracted_dir=extracted_dir,
|
|
162
194
|
)
|
|
163
195
|
if resp:
|
|
164
196
|
num_hits += 1
|
|
@@ -194,6 +226,7 @@ def main():
|
|
|
194
226
|
help="Include base64 encoded binary data in output "
|
|
195
227
|
"(can be large, consider printing to file rather than console)",
|
|
196
228
|
)
|
|
229
|
+
parser.add_argument("--binarydir", type=str, help="directory to write extracted binary data to")
|
|
197
230
|
parser.add_argument("--logfile", type=str, help="file to log output")
|
|
198
231
|
parser.add_argument("--include", type=str, help="comma separated extractors to run")
|
|
199
232
|
parser.add_argument("--exclude", type=str, help="comma separated extractors to not run")
|
|
@@ -268,6 +301,7 @@ def main():
|
|
|
268
301
|
include_base64=args.base64,
|
|
269
302
|
create_venv=args.create_venv,
|
|
270
303
|
skip_install=not args.force_install,
|
|
304
|
+
extracted_dir=args.binarydir,
|
|
271
305
|
)
|
|
272
306
|
|
|
273
307
|
|
|
@@ -25,7 +25,8 @@ class Extractor:
|
|
|
25
25
|
family: Union[str, List[str]] = None # family or families of malware that is detected by the extractor
|
|
26
26
|
author: str = None # author of the extractor (name@organisation)
|
|
27
27
|
last_modified: str = None # last modified date (YYYY-MM-DD)
|
|
28
|
-
sharing: str = "TLP:
|
|
28
|
+
sharing: str = "TLP:CLEAR" # who can this be shared with?
|
|
29
|
+
result_sharing: str = sharing # who can the results be shared with? (defaults to sharing)
|
|
29
30
|
yara_rule: str = None # yara rule that we filter inputs with
|
|
30
31
|
reference: str = None # link to malware report or other reference information
|
|
31
32
|
logger: logging.Logger = None # logger for use when debugging
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{maco_extractor-1.2.18 → maco_extractor-1.2.20}/maco_extractor.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|