mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Merge 843e65242e
into d3357d2acd
This commit is contained in:
commit
b0246e9609
2 changed files with 48 additions and 1 deletions
|
@ -444,7 +444,8 @@
|
||||||
"CRC-8 Checksum",
|
"CRC-8 Checksum",
|
||||||
"CRC-16 Checksum",
|
"CRC-16 Checksum",
|
||||||
"CRC-32 Checksum",
|
"CRC-32 Checksum",
|
||||||
"TCP/IP Checksum"
|
"TCP/IP Checksum",
|
||||||
|
"Generate SSHA Hash"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
46
src/core/operations/GenerateSSHAHash.mjs
Normal file
46
src/core/operations/GenerateSSHAHash.mjs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* @author git-commit-amen [daniel@danielwallace.com.au]
|
||||||
|
* @copyright Crown Copyright 2024
|
||||||
|
* @license Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Operation from "../Operation.mjs";
|
||||||
|
import CryptoJS from "crypto-js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate SSHA Hash operation
|
||||||
|
*/
|
||||||
|
class GenerateSSHAHash extends Operation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GenerateSSHAHash constructor
|
||||||
|
*/
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.name = "Generate SSHA Hash";
|
||||||
|
this.module = "Crypto";
|
||||||
|
this.description = "Generates an RFC 2307-compliant, cryptographically-secure SSHA (Salted SHA1) password hash - commonly used for storing passwords in systems such as OpenLDAP.";
|
||||||
|
this.infoURL = "https://www.openldap.org/faq/data/cache/347.html";
|
||||||
|
this.inputType = "string";
|
||||||
|
this.outputType = "string";
|
||||||
|
this.args = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} input
|
||||||
|
* @param {Object[]} args
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
run(input, args) {
|
||||||
|
if (!input) return "";
|
||||||
|
|
||||||
|
const salt = CryptoJS.lib.WordArray.random(128/8).toString().substr(0, 4);
|
||||||
|
const hash = CryptoJS.SHA1(input + salt);
|
||||||
|
const result = CryptoJS.enc.Latin1.parse(hash.toString(CryptoJS.enc.Latin1) + salt).toString(CryptoJS.enc.Base64);
|
||||||
|
return `{SSHA}${result}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GenerateSSHAHash;
|
Loading…
Add table
Add a link
Reference in a new issue