mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Add "Extract EXIF" operation
This commit is contained in:
parent
31e5d785fe
commit
1b8a25ec88
6 changed files with 152 additions and 0 deletions
|
@ -68,6 +68,7 @@
|
||||||
"escodegen": "^1.8.1",
|
"escodegen": "^1.8.1",
|
||||||
"esmangle": "^1.0.1",
|
"esmangle": "^1.0.1",
|
||||||
"esprima": "^3.1.3",
|
"esprima": "^3.1.3",
|
||||||
|
"exif-parser": "^0.1.9",
|
||||||
"google-code-prettify": "^1.0.5",
|
"google-code-prettify": "^1.0.5",
|
||||||
"jquery": "^3.1.1",
|
"jquery": "^3.1.1",
|
||||||
"jsbn": "^1.1.0",
|
"jsbn": "^1.1.0",
|
||||||
|
|
|
@ -207,6 +207,7 @@ const Categories = [
|
||||||
"Regular expression",
|
"Regular expression",
|
||||||
"XPath expression",
|
"XPath expression",
|
||||||
"CSS selector",
|
"CSS selector",
|
||||||
|
"Extract EXIF",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ import Endian from "../operations/Endian.js";
|
||||||
import Entropy from "../operations/Entropy.js";
|
import Entropy from "../operations/Entropy.js";
|
||||||
import Extract from "../operations/Extract.js";
|
import Extract from "../operations/Extract.js";
|
||||||
import FileType from "../operations/FileType.js";
|
import FileType from "../operations/FileType.js";
|
||||||
|
import Image from "../operations/Image.js";
|
||||||
import Hash from "../operations/Hash.js";
|
import Hash from "../operations/Hash.js";
|
||||||
import Hexdump from "../operations/Hexdump.js";
|
import Hexdump from "../operations/Hexdump.js";
|
||||||
import HTML from "../operations/HTML.js";
|
import HTML from "../operations/HTML.js";
|
||||||
|
@ -3249,6 +3250,15 @@ const OperationConfig = {
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Extract EXIF": {
|
||||||
|
description: [
|
||||||
|
].join("\n"),
|
||||||
|
run: Image.runEXIF,
|
||||||
|
inputType: "byteArray",
|
||||||
|
outputType: "string",
|
||||||
|
args: [
|
||||||
|
]
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default OperationConfig;
|
export default OperationConfig;
|
||||||
|
|
36
src/core/operations/Image.js
Normal file
36
src/core/operations/Image.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import * as ExifParser from "exif-parser";
|
||||||
|
import Utils from "../Utils.js";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Image operations.
|
||||||
|
*
|
||||||
|
* @author tlwr [toby@toby.codes]
|
||||||
|
* @copyright Crown Copyright 2017
|
||||||
|
* @license Apache-2.0
|
||||||
|
*
|
||||||
|
* @namespace
|
||||||
|
*/
|
||||||
|
const Image = {
|
||||||
|
runEXIF(input, args) {
|
||||||
|
try {
|
||||||
|
let bytes = Uint8Array.from(input);
|
||||||
|
let parser = ExifParser.create(bytes.buffer);
|
||||||
|
let result = parser.parse();
|
||||||
|
|
||||||
|
let lines = [];
|
||||||
|
for (let tagName in result.tags) {
|
||||||
|
let value = result.tags[tagName];
|
||||||
|
lines.push(`${tagName}: ${value}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
let numTags = lines.length;
|
||||||
|
lines.unshift(`Found ${numTags} tags.\n`);
|
||||||
|
return lines.join("\n");
|
||||||
|
} catch (err) {
|
||||||
|
throw "Could not EXIF data from image: " + err;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Image;
|
|
@ -15,6 +15,7 @@ import "./tests/operations/Base58.js";
|
||||||
import "./tests/operations/ByteRepr.js";
|
import "./tests/operations/ByteRepr.js";
|
||||||
import "./tests/operations/Compress.js";
|
import "./tests/operations/Compress.js";
|
||||||
import "./tests/operations/FlowControl.js";
|
import "./tests/operations/FlowControl.js";
|
||||||
|
import "./tests/operations/Image.js";
|
||||||
import "./tests/operations/MorseCode.js";
|
import "./tests/operations/MorseCode.js";
|
||||||
import "./tests/operations/StrUtils.js";
|
import "./tests/operations/StrUtils.js";
|
||||||
|
|
||||||
|
|
103
test/tests/operations/Image.js
Normal file
103
test/tests/operations/Image.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue