From 42c911838d9f29c7156aad5d52af4d58058859bf Mon Sep 17 00:00:00 2001 From: n1073645 Date: Fri, 17 Jun 2022 11:18:49 +0100 Subject: [PATCH] Add min size to Extract Files --- src/core/operations/ExtractFiles.mjs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/operations/ExtractFiles.mjs b/src/core/operations/ExtractFiles.mjs index fce23a9a..8c313f59 100644 --- a/src/core/operations/ExtractFiles.mjs +++ b/src/core/operations/ExtractFiles.mjs @@ -38,7 +38,7 @@ class ExtractFiles extends Operation {
  • ${supportedExts.join("
  • ")}
  • - `; + Minimum File Size can be used to prune small false positives.`; this.infoURL = "https://forensicswiki.xyz/wiki/index.php?title=File_Carving"; this.inputType = "ArrayBuffer"; this.outputType = "List"; @@ -54,6 +54,11 @@ class ExtractFiles extends Operation { name: "Ignore failed extractions", type: "boolean", value: true + }, + { + name: "Minimum File Size", + type: "number", + value: 0 } ]); } @@ -66,6 +71,7 @@ class ExtractFiles extends Operation { run(input, args) { const bytes = new Uint8Array(input), categories = [], + minSize = args.pop(1), ignoreFailedExtractions = args.pop(1); args.forEach((cat, i) => { @@ -80,7 +86,9 @@ class ExtractFiles extends Operation { const errors = []; detectedFiles.forEach(detectedFile => { try { - files.push(extractFile(bytes, detectedFile.fileDetails, detectedFile.offset)); + let file; + if ((file = extractFile(bytes, detectedFile.fileDetails, detectedFile.offset)).size >= minSize) + files.push(file); } catch (err) { if (!ignoreFailedExtractions && err.message.indexOf("No extraction algorithm available") < 0) { errors.push(