Skip to content

Commit e9f142e

Browse files
dorpvomqkaiser
authored andcommitted
feat(processing/cli): added cli option to skip extraction (-s/--skip-extraction) along with matching functionality
1 parent a725eb5 commit e9f142e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

unblob/cli.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ def __init__(
151151
type=click.Path(path_type=Path),
152152
help="File to store metadata generated during the extraction process (in JSON format).",
153153
)
154+
@click.option(
155+
"-s",
156+
"--skip_extraction",
157+
"skip_extraction",
158+
is_flag=True,
159+
show_default=True,
160+
help="Only carve chunks and skip further extraction",
161+
)
154162
@click.option(
155163
"-k",
156164
"--keep-extracted-chunks",
@@ -176,6 +184,7 @@ def cli(
176184
depth: int,
177185
entropy_depth: int,
178186
skip_magic: Iterable[str],
187+
skip_extraction: bool,
179188
keep_extracted_chunks: bool,
180189
handlers: Handlers,
181190
plugins_path: Optional[Path],
@@ -194,6 +203,7 @@ def cli(
194203
max_depth=depth,
195204
entropy_depth=entropy_depth,
196205
entropy_plot=bool(verbose >= 3),
206+
skip_extraction=skip_extraction,
197207
skip_magic=skip_magic,
198208
process_num=process_num,
199209
handlers=handlers,

unblob/processing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ExtractionConfig:
8080
entropy_plot: bool = False
8181
max_depth: int = DEFAULT_DEPTH
8282
skip_magic: Iterable[str] = DEFAULT_SKIP_MAGIC
83+
skip_extraction: bool = False
8384
process_num: int = DEFAULT_PROCESS_NUM
8485
keep_extracted_chunks: bool = False
8586
extract_suffix: str = "_extract"
@@ -374,6 +375,10 @@ def _extract_chunk(self, file, chunk: ValidChunk):
374375
extract_dir = self.carve_dir / (inpath.name + self.config.extract_suffix)
375376
carved_path = inpath
376377

378+
if self.config.skip_extraction:
379+
fix_extracted_directory(extract_dir, self.result)
380+
return
381+
377382
extraction_reports = []
378383
try:
379384
chunk.extract(inpath, extract_dir)

0 commit comments

Comments
 (0)