mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 23:06:16 -04:00
Improved description of operation
This commit is contained in:
parent
98edef389c
commit
de8ed6962d
1 changed files with 11 additions and 6 deletions
|
@ -20,13 +20,13 @@ class ExtractHashes extends Operation {
|
||||||
|
|
||||||
this.name = "Extract Hashes";
|
this.name = "Extract Hashes";
|
||||||
this.module = "Regex";
|
this.module = "Regex";
|
||||||
this.description = "Extracts hash values based on hash byte length";
|
this.description = "Extracts potential hashes based on hash character length";
|
||||||
this.infoURL = "https://en.wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions";
|
this.infoURL = "https://en.wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [
|
||||||
{
|
{
|
||||||
name: "Hash length",
|
name: "Hash character length",
|
||||||
type: "number",
|
type: "number",
|
||||||
value: 32
|
value: 32
|
||||||
},
|
},
|
||||||
|
@ -56,11 +56,16 @@ class ExtractHashes extends Operation {
|
||||||
const searchAllHashes = args[1];
|
const searchAllHashes = args[1];
|
||||||
const showDisplayTotal = args[2];
|
const showDisplayTotal = args[2];
|
||||||
|
|
||||||
let hashLengths = [hashLength];
|
// Convert character length to bit length
|
||||||
if (searchAllHashes) hashLengths = [4, 8, 16, 32, 64, 128, 160, 192, 224, 256, 320, 384, 512, 1024];
|
let hashBitLengths = [(hashLength / 2) * 8];
|
||||||
|
|
||||||
for (let hashLength of hashLengths) {
|
if (searchAllHashes) hashBitLengths = [4, 8, 16, 32, 64, 128, 160, 192, 224, 256, 320, 384, 512, 1024];
|
||||||
const regex = new RegExp(`(\\b|^)[a-f0-9]{${hashLength}}(\\b|$)`, "g");
|
|
||||||
|
for (let hashBitLength of hashBitLengths) {
|
||||||
|
// Convert bit length to character length
|
||||||
|
let hashCharacterLength = (hashBitLength / 8) * 2;
|
||||||
|
|
||||||
|
const regex = new RegExp(`(\\b|^)[a-f0-9]{${hashCharacterLength}}(\\b|$)`, "g");
|
||||||
const searchResults = search(input, regex, null, false);
|
const searchResults = search(input, regex, null, false);
|
||||||
|
|
||||||
hashCount += searchResults.split("\n").length - 1;
|
hashCount += searchResults.split("\n").length - 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue