Merge branch 'extract-files-min-size' of https://github.com/n1073645/CyberChef
This commit is contained in:
commit
bb6c1c54ff
@ -38,7 +38,7 @@ class ExtractFiles extends Operation {
|
|||||||
<li>
|
<li>
|
||||||
${supportedExts.join("</li><li>")}
|
${supportedExts.join("</li><li>")}
|
||||||
</li>
|
</li>
|
||||||
</ul>`;
|
</ul>Minimum File Size can be used to prune small false positives.`;
|
||||||
this.infoURL = "https://forensicswiki.xyz/wiki/index.php?title=File_Carving";
|
this.infoURL = "https://forensicswiki.xyz/wiki/index.php?title=File_Carving";
|
||||||
this.inputType = "ArrayBuffer";
|
this.inputType = "ArrayBuffer";
|
||||||
this.outputType = "List<File>";
|
this.outputType = "List<File>";
|
||||||
@ -54,6 +54,11 @@ class ExtractFiles extends Operation {
|
|||||||
name: "Ignore failed extractions",
|
name: "Ignore failed extractions",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
value: true
|
value: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Minimum File Size",
|
||||||
|
type: "number",
|
||||||
|
value: 0
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -66,6 +71,7 @@ class ExtractFiles extends Operation {
|
|||||||
run(input, args) {
|
run(input, args) {
|
||||||
const bytes = new Uint8Array(input),
|
const bytes = new Uint8Array(input),
|
||||||
categories = [],
|
categories = [],
|
||||||
|
minSize = args.pop(1),
|
||||||
ignoreFailedExtractions = args.pop(1);
|
ignoreFailedExtractions = args.pop(1);
|
||||||
|
|
||||||
args.forEach((cat, i) => {
|
args.forEach((cat, i) => {
|
||||||
@ -80,7 +86,9 @@ class ExtractFiles extends Operation {
|
|||||||
const errors = [];
|
const errors = [];
|
||||||
detectedFiles.forEach(detectedFile => {
|
detectedFiles.forEach(detectedFile => {
|
||||||
try {
|
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) {
|
} catch (err) {
|
||||||
if (!ignoreFailedExtractions && err.message.indexOf("No extraction algorithm available") < 0) {
|
if (!ignoreFailedExtractions && err.message.indexOf("No extraction algorithm available") < 0) {
|
||||||
errors.push(
|
errors.push(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user