mirror of
https://github.com/gchq/CyberChef
synced 2024-11-15 09:07:06 +00:00
Merge branch 'master' into feature-sass
This commit is contained in:
commit
04432385b3
7 changed files with 174 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cyberchef",
|
||||
"version": "5.3.5",
|
||||
"version": "5.4.1",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
|
@ -73,6 +73,7 @@
|
|||
"escodegen": "^1.8.1",
|
||||
"esmangle": "^1.0.1",
|
||||
"esprima": "^3.1.3",
|
||||
"exif-parser": "^0.1.9",
|
||||
"google-code-prettify": "^1.0.5",
|
||||
"jquery": "^3.1.1",
|
||||
"jsbn": "^1.1.0",
|
||||
|
|
|
@ -207,6 +207,7 @@ const Categories = [
|
|||
"Regular expression",
|
||||
"XPath expression",
|
||||
"CSS selector",
|
||||
"Extract EXIF",
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ import Endian from "../operations/Endian.js";
|
|||
import Entropy from "../operations/Entropy.js";
|
||||
import Extract from "../operations/Extract.js";
|
||||
import FileType from "../operations/FileType.js";
|
||||
import Image from "../operations/Image.js";
|
||||
import Hash from "../operations/Hash.js";
|
||||
import Hexdump from "../operations/Hexdump.js";
|
||||
import HTML from "../operations/HTML.js";
|
||||
|
@ -2221,7 +2222,7 @@ const OperationConfig = {
|
|||
]
|
||||
},
|
||||
"To UNIX Timestamp": {
|
||||
description: "Parses a datetime string and returns the corresponding UNIX timestamp.<br><br>e.g. <code>Mon 1 January 2001 11:00:00 UTC</code> becomes <code>978346800</code>",
|
||||
description: "Parses a datetime string in UTC and returns the corresponding UNIX timestamp.<br><br>e.g. <code>Mon 1 January 2001 11:00:00</code> becomes <code>978346800</code>",
|
||||
run: DateTime.runToUnixTimestamp,
|
||||
inputType: "string",
|
||||
outputType: "number",
|
||||
|
@ -2230,6 +2231,11 @@ const OperationConfig = {
|
|||
name: "Units",
|
||||
type: "option",
|
||||
value: DateTime.UNITS
|
||||
},
|
||||
{
|
||||
name: "Treat as UTC",
|
||||
type: "boolean",
|
||||
value: DateTime.TREAT_AS_UTC
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -3334,6 +3340,19 @@ const OperationConfig = {
|
|||
},
|
||||
]
|
||||
},
|
||||
"Extract EXIF": {
|
||||
description: [
|
||||
"Extracts EXIF data from an image.",
|
||||
"<br><br>",
|
||||
"EXIF data is metadata embedded in images (JPEG, JPG, TIFF) and audio files.",
|
||||
"<br><br>",
|
||||
"EXIF data from photos usually contains information about the image file itself as well as the device used to create it.",
|
||||
].join("\n"),
|
||||
run: Image.runEXIF,
|
||||
inputType: "byteArray",
|
||||
outputType: "string",
|
||||
args: [],
|
||||
},
|
||||
};
|
||||
|
||||
export default OperationConfig;
|
||||
|
|
|
@ -46,6 +46,12 @@ const DateTime = {
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* @constant
|
||||
* @default
|
||||
*/
|
||||
TREAT_AS_UTC: true,
|
||||
|
||||
/**
|
||||
* To UNIX Timestamp operation.
|
||||
*
|
||||
|
@ -55,7 +61,8 @@ const DateTime = {
|
|||
*/
|
||||
runToUnixTimestamp: function(input, args) {
|
||||
let units = args[0],
|
||||
d = moment(input);
|
||||
treatAsUTC = args[1],
|
||||
d = treatAsUTC ? moment.utc(input) : moment(input);
|
||||
|
||||
if (units === "Seconds (s)") {
|
||||
return d.unix();
|
||||
|
|
47
src/core/operations/Image.js
Normal file
47
src/core/operations/Image.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
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 = {
|
||||
|
||||
/**
|
||||
* Extract EXIF operation.
|
||||
*
|
||||
* Extracts EXIF data from a byteArray, representing a JPG or a TIFF image.
|
||||
*
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
runEXIF(input, args) {
|
||||
try {
|
||||
const bytes = Uint8Array.from(input);
|
||||
const parser = ExifParser.create(bytes.buffer);
|
||||
const result = parser.parse();
|
||||
|
||||
let lines = [];
|
||||
for (let tagName in result.tags) {
|
||||
let value = result.tags[tagName];
|
||||
lines.push(`${tagName}: ${value}`);
|
||||
}
|
||||
|
||||
const numTags = lines.length;
|
||||
lines.unshift(`Found ${numTags} tags.\n`);
|
||||
return lines.join("\n");
|
||||
} catch (err) {
|
||||
throw "Could not extract EXIF data from image: " + err;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
export default Image;
|
|
@ -16,6 +16,7 @@ import "./tests/operations/ByteRepr.js";
|
|||
import "./tests/operations/Code.js";
|
||||
import "./tests/operations/Compress.js";
|
||||
import "./tests/operations/FlowControl.js";
|
||||
import "./tests/operations/Image.js";
|
||||
import "./tests/operations/MorseCode.js";
|
||||
import "./tests/operations/StrUtils.js";
|
||||
|
||||
|
|
95
test/tests/operations/Image.js
Normal file
95
test/tests/operations/Image.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue