Skip to content

Commit

Permalink
Improved description of operation
Browse files Browse the repository at this point in the history
  • Loading branch information
MShwed committed Mar 12, 2019
1 parent 24f3de3 commit 73fae3d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core/operations/ExtractHashes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class ExtractHashes extends Operation {

this.name = "Extract Hashes";
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.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Hash length",
name: "Hash character length",
type: "number",
value: 32
},
Expand Down Expand Up @@ -56,11 +56,16 @@ class ExtractHashes extends Operation {
const searchAllHashes = args[1];
const showDisplayTotal = args[2];

let hashLengths = [hashLength];
if (searchAllHashes) hashLengths = [4, 8, 16, 32, 64, 128, 160, 192, 224, 256, 320, 384, 512, 1024];
// Convert character length to bit length
let hashBitLengths = [(hashLength / 2) * 8];

for (let hashLength of hashLengths) {
const regex = new RegExp(`(\\b|^)[a-f0-9]{${hashLength}}(\\b|$)`, "g");
if (searchAllHashes) hashBitLengths = [4, 8, 16, 32, 64, 128, 160, 192, 224, 256, 320, 384, 512, 1024];

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);

hashCount += searchResults.split("\n").length - 1;
Expand Down

0 comments on commit 73fae3d

Please sign in to comment.