mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-11 00:31:31 -04:00
Merge pull request #4 from windhamwong/master
Updating + patching image issue
This commit is contained in:
commit
90802db3c4
8 changed files with 130 additions and 12 deletions
18
Gruntfile.js
18
Gruntfile.js
|
@ -206,14 +206,14 @@ module.exports = function (grunt) {
|
||||||
limit: 10000
|
limit: 10000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ // First party images are saved as files to be cached
|
// { // First party images are saved as files to be cached
|
||||||
test: /\.(png|jpg|gif|svg)$/,
|
// test: /\.(png|jpg|gif|svg)$/,
|
||||||
exclude: /node_modules/,
|
// exclude: /node_modules/,
|
||||||
loader: "file-loader",
|
// loader: "file-loader",
|
||||||
options: {
|
// options: {
|
||||||
name: "images/[name].[ext]"
|
// name: "images/[name].[ext]"
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
{ // Third party images are inlined
|
{ // Third party images are inlined
|
||||||
test: /\.(png|jpg|gif|svg)$/,
|
test: /\.(png|jpg|gif|svg)$/,
|
||||||
exclude: /web\/static/,
|
exclude: /web\/static/,
|
||||||
|
@ -321,7 +321,7 @@ module.exports = function (grunt) {
|
||||||
},
|
},
|
||||||
src: "build/prod/index.html",
|
src: "build/prod/index.html",
|
||||||
dest: "build/prod/index.html"
|
dest: "build/prod/index.html"
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
chmod: {
|
chmod: {
|
||||||
build: {
|
build: {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cyberchef",
|
"name": "cyberchef",
|
||||||
"version": "5.9.2",
|
"version": "5.10.1",
|
||||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||||
"author": "n1474335 <n1474335@gmail.com>",
|
"author": "n1474335 <n1474335@gmail.com>",
|
||||||
"homepage": "https://gchq.github.io/CyberChef",
|
"homepage": "https://gchq.github.io/CyberChef",
|
||||||
|
|
|
@ -196,6 +196,8 @@ const Categories = [
|
||||||
"Translate DateTime Format",
|
"Translate DateTime Format",
|
||||||
"From UNIX Timestamp",
|
"From UNIX Timestamp",
|
||||||
"To UNIX Timestamp",
|
"To UNIX Timestamp",
|
||||||
|
"Windows Filetime to UNIX Timestamp",
|
||||||
|
"UNIX Timestamp to Windows Filetime",
|
||||||
"Extract dates",
|
"Extract dates",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -2259,7 +2259,7 @@ const OperationConfig = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"From UNIX Timestamp": {
|
"From UNIX Timestamp": {
|
||||||
description: "Converts a UNIX timestamp to a datetime string.<br><br>e.g. <code>978346800</code> becomes <code>Mon 1 January 2001 11:00:00 UTC</code>",
|
description: "Converts a UNIX timestamp to a datetime string.<br><br>e.g. <code>978346800</code> becomes <code>Mon 1 January 2001 11:00:00 UTC</code><br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).",
|
||||||
run: DateTime.runFromUnixTimestamp,
|
run: DateTime.runFromUnixTimestamp,
|
||||||
inputType: "number",
|
inputType: "number",
|
||||||
outputType: "string",
|
outputType: "string",
|
||||||
|
@ -2272,7 +2272,7 @@ const OperationConfig = {
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"To UNIX Timestamp": {
|
"To UNIX Timestamp": {
|
||||||
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>",
|
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><br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).",
|
||||||
run: DateTime.runToUnixTimestamp,
|
run: DateTime.runToUnixTimestamp,
|
||||||
inputType: "string",
|
inputType: "string",
|
||||||
outputType: "number",
|
outputType: "number",
|
||||||
|
@ -2289,6 +2289,32 @@ const OperationConfig = {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"Windows Filetime to UNIX Timestamp":{
|
||||||
|
description: "Converts a Windows Filetime value to a UNIX timestamp.<br><br>A Windows Filetime is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC.<br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>This operation also supports UNIX timestamps in milliseconds, microseconds and nanoseconds.",
|
||||||
|
run: DateTime.runFromFiletimeToUnix,
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "string",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Output units",
|
||||||
|
type: "option",
|
||||||
|
value: DateTime.UNITS
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"UNIX Timestamp to Windows Filetime":{
|
||||||
|
description: "Converts a UNIX timestamp to a Windows Filetime value.<br><br>A Windows Filetime is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC.<br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>This operation also supports UNIX timestamps in milliseconds, microseconds and nanoseconds.",
|
||||||
|
run: DateTime.runToFiletimeFromUnix,
|
||||||
|
inputType: "string",
|
||||||
|
outputType: "string",
|
||||||
|
args: [
|
||||||
|
{
|
||||||
|
name: "Input units",
|
||||||
|
type: "option",
|
||||||
|
value: DateTime.UNITS
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"Translate DateTime Format": {
|
"Translate DateTime Format": {
|
||||||
description: "Parses a datetime string in one format and re-writes it in another.<br><br>Run with no input to see the relevant format string examples.",
|
description: "Parses a datetime string in one format and re-writes it in another.<br><br>Run with no input to see the relevant format string examples.",
|
||||||
run: DateTime.runTranslateFormat,
|
run: DateTime.runTranslateFormat,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import {BigInteger} from "jsbn";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date and time operations.
|
* Date and time operations.
|
||||||
*
|
*
|
||||||
|
@ -78,6 +80,58 @@ const DateTime = {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Windows Filetime to Unix Timestamp operation.
|
||||||
|
*
|
||||||
|
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
runFromFiletimeToUnix: function(input, args) {
|
||||||
|
let units = args[0];
|
||||||
|
input = new BigInteger(input).subtract(new BigInteger("116444736000000000"));
|
||||||
|
if (units === "Seconds (s)"){
|
||||||
|
input = input.divide(new BigInteger("10000000"));
|
||||||
|
} else if (units === "Milliseconds (ms)") {
|
||||||
|
input = input.divide(new BigInteger("10000"));
|
||||||
|
} else if (units === "Microseconds (μs)") {
|
||||||
|
input = input.divide(new BigInteger("10"));
|
||||||
|
} else if (units === "Nanoseconds (ns)") {
|
||||||
|
input = input.multiply(new BigInteger("100"));
|
||||||
|
} else {
|
||||||
|
throw "Unrecognised unit";
|
||||||
|
}
|
||||||
|
return input.toString();
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unix Timestamp to Windows Filetime operation.
|
||||||
|
*
|
||||||
|
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
runToFiletimeFromUnix: function(input, args) {
|
||||||
|
let units = args[0];
|
||||||
|
input = new BigInteger(input);
|
||||||
|
if (units === "Seconds (s)"){
|
||||||
|
input = input.multiply(new BigInteger("10000000"));
|
||||||
|
} else if (units === "Milliseconds (ms)") {
|
||||||
|
input = input.multiply(new BigInteger("10000"));
|
||||||
|
} else if (units === "Microseconds (μs)") {
|
||||||
|
input = input.multiply(new BigInteger("10"));
|
||||||
|
} else if (units === "Nanoseconds (ns)") {
|
||||||
|
input = input.divide(new BigInteger("100"));
|
||||||
|
} else {
|
||||||
|
throw "Unrecognised unit";
|
||||||
|
}
|
||||||
|
return input.add(new BigInteger("116444736000000000")).toString();
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constant
|
* @constant
|
||||||
* @default
|
* @default
|
||||||
|
|
|
@ -146,6 +146,7 @@ const HTTP = {
|
||||||
return e.toString() +
|
return e.toString() +
|
||||||
"\n\nThis error could be caused by one of the following:\n" +
|
"\n\nThis error could be caused by one of the following:\n" +
|
||||||
" - An invalid URL\n" +
|
" - An invalid URL\n" +
|
||||||
|
" - Making a request to an insecure resource (HTTP) from a secure source (HTTPS)\n" +
|
||||||
" - Making a cross-origin request to a server which does not support CORS\n";
|
" - Making a cross-origin request to a server which does not support CORS\n";
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,6 +16,7 @@ import "./tests/operations/ByteRepr.js";
|
||||||
import "./tests/operations/CharEnc.js";
|
import "./tests/operations/CharEnc.js";
|
||||||
import "./tests/operations/Code.js";
|
import "./tests/operations/Code.js";
|
||||||
import "./tests/operations/Compress.js";
|
import "./tests/operations/Compress.js";
|
||||||
|
import "./tests/operations/DateTime.js";
|
||||||
import "./tests/operations/FlowControl.js";
|
import "./tests/operations/FlowControl.js";
|
||||||
import "./tests/operations/Image.js";
|
import "./tests/operations/Image.js";
|
||||||
import "./tests/operations/MorseCode.js";
|
import "./tests/operations/MorseCode.js";
|
||||||
|
|
34
test/tests/operations/DateTime.js
Normal file
34
test/tests/operations/DateTime.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* DateTime tests.
|
||||||
|
*
|
||||||
|
* @author bwhitn [brian.m.whitney@outlook.com]
|
||||||
|
*
|
||||||
|
* @copyright Crown Copyright 2017
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
import TestRegister from "../../TestRegister.js";
|
||||||
|
|
||||||
|
TestRegister.addTests([
|
||||||
|
{
|
||||||
|
name: "Filetime to Unix",
|
||||||
|
input: "129207366395297693",
|
||||||
|
expectedOutput: "1276263039529769300",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "Windows Filetime to UNIX Timestamp",
|
||||||
|
args: ["Nanoseconds (ns)"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Unix to Filetime",
|
||||||
|
input: "1276263039529769300",
|
||||||
|
expectedOutput: "129207366395297693",
|
||||||
|
recipeConfig: [
|
||||||
|
{
|
||||||
|
op: "UNIX Timestamp to Windows Filetime",
|
||||||
|
args: ["Nanoseconds (ns)"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]);
|
Loading…
Add table
Add a link
Reference in a new issue