Skip to content

Commit 142f914

Browse files
committed
Added 'LM Hash' opertaion
1 parent d634476 commit 142f914

File tree

8 files changed

+91
-14
lines changed

8 files changed

+91
-14
lines changed

Diff for: package-lock.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
"node-md6": "^0.1.0",
143143
"nodom": "^2.4.0",
144144
"notepack.io": "^3.0.1",
145+
"ntlm": "^0.1.3",
145146
"nwmatcher": "^1.4.4",
146147
"otp": "0.1.3",
147148
"path": "^0.12.7",
@@ -170,7 +171,7 @@
170171
"build": "npx grunt prod",
171172
"node": "npx grunt node",
172173
"repl": "node --experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings src/node/repl.mjs",
173-
"test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/operations/index.mjs",
174+
"test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation --openssl-legacy-provider tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation --openssl-legacy-provider tests/operations/index.mjs",
174175
"testnodeconsumer": "npx grunt testnodeconsumer",
175176
"testui": "npx grunt testui",
176177
"testuidev": "npx nightwatch --env=dev",

Diff for: src/core/config/Categories.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@
369369
"Bcrypt compare",
370370
"Bcrypt parse",
371371
"Scrypt",
372+
"NT Hash",
373+
"LM Hash",
372374
"Fletcher-8 Checksum",
373375
"Fletcher-16 Checksum",
374376
"Fletcher-32 Checksum",
@@ -378,8 +380,7 @@
378380
"CRC-8 Checksum",
379381
"CRC-16 Checksum",
380382
"CRC-32 Checksum",
381-
"TCP/IP Checksum",
382-
"NTLM"
383+
"TCP/IP Checksum"
383384
]
384385
},
385386
{

Diff for: src/core/operations/GenerateAllHashes.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import BLAKE2b from "./BLAKE2b.mjs";
3434
import BLAKE2s from "./BLAKE2s.mjs";
3535
import Streebog from "./Streebog.mjs";
3636
import GOSTHash from "./GOSTHash.mjs";
37+
import LMHash from "./LMHash.mjs";
38+
import NTHash from "./NTHash.mjs";
3739
import OperationError from "../errors/OperationError.mjs";
3840

3941
/**
@@ -107,6 +109,8 @@ class GenerateAllHashes extends Operation {
107109
{name: "Streebog-256", algo: (new Streebog), inputType: "arrayBuffer", params: ["256"]},
108110
{name: "Streebog-512", algo: (new Streebog), inputType: "arrayBuffer", params: ["512"]},
109111
{name: "GOST", algo: (new GOSTHash), inputType: "arrayBuffer", params: ["D-A"]},
112+
{name: "LM Hash", algo: (new LMHash), inputType: "str", params: []},
113+
{name: "NT Hash", algo: (new NTHash), inputType: "str", params: []},
110114
{name: "SSDEEP", algo: (new SSDEEP()), inputType: "str"},
111115
{name: "CTPH", algo: (new CTPH()), inputType: "str"}
112116
];

Diff for: src/core/operations/LMHash.mjs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @author n1474335 [[email protected]]
3+
* @copyright Crown Copyright 2022
4+
* @license Apache-2.0
5+
*/
6+
7+
import Operation from "../Operation.mjs";
8+
import {smbhash} from "ntlm";
9+
10+
/**
11+
* LM Hash operation
12+
*/
13+
class LMHash extends Operation {
14+
15+
/**
16+
* LMHash constructor
17+
*/
18+
constructor() {
19+
super();
20+
21+
this.name = "LM Hash";
22+
this.module = "Crypto";
23+
this.description = "An LM Hash, or LAN Manager Hash, is a deprecated way of storing passwords on old Microsoft operating systems. It is particularly weak and can be cracked in seconds on modern hardware using rainbow tables.";
24+
this.infoURL = "https://wikipedia.org/wiki/LAN_Manager#Password_hashing_algorithm";
25+
this.inputType = "string";
26+
this.outputType = "string";
27+
this.args = [];
28+
}
29+
30+
/**
31+
* @param {string} input
32+
* @param {Object[]} args
33+
* @returns {string}
34+
*/
35+
run(input, args) {
36+
return smbhash.lmhash(input);
37+
}
38+
39+
}
40+
41+
export default LMHash;

Diff for: src/core/operations/NTLM.mjs renamed to src/core/operations/NTHash.mjs

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ import cptable from "codepage";
1010
import {runHash} from "../lib/Hash.mjs";
1111

1212
/**
13-
* NTLM operation
13+
* NT Hash operation
1414
*/
15-
class NTLM extends Operation {
15+
class NTHash extends Operation {
1616

1717
/**
18-
* NTLM constructor
18+
* NTHash constructor
1919
*/
2020
constructor() {
2121
super();
2222

23-
this.name = "NTLM";
23+
this.name = "NT Hash";
2424
this.module = "Crypto";
25-
this.description = "Performs NTLM hashing on the input. It works by running MD4 on UTF16LE-encoded input. NTLM hashes are considered weak because they can be brute-forced very easily with modern hardware.";
26-
this.infoURL = "https://en.wikipedia.org/wiki/NT_LAN_Manager";
25+
this.description = "An NT Hash, sometimes referred to as an NTLM hash, is a method of storing passwords on Windows systems. It works by running MD4 on UTF-16LE encoded input. NTLM hashes are considered weak because they can be brute-forced very easily with modern hardware.";
26+
this.infoURL = "https://wikipedia.org/wiki/NT_LAN_Manager";
2727
this.inputType = "string";
2828
this.outputType = "string";
2929
this.args = [];
@@ -35,12 +35,12 @@ class NTLM extends Operation {
3535
* @returns {string}
3636
*/
3737
run(input, args) {
38-
const format = 1200;
38+
const format = 1200; // UTF-16LE
3939
const encoded = cptable.utils.encode(format, input);
4040
const hashed = runHash("md4", encoded);
4141

4242
return hashed.toUpperCase();
4343
}
4444
}
4545

46-
export default NTLM;
46+
export default NTHash;

Diff for: tests/operations/tests/GenerateAllHashes.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ BLAKE2s-256: f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
5050
Streebog-256: 12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
5151
Streebog-512: 7200bf5dea560f0d7960d07fdc8874ad9f3b86ece2e45f5502ae2e176f2c928e0e581152281f5aee818318bed7cbe6aa69999589234723ceb33175598365b5c8
5252
GOST: ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
53+
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
54+
NT Hash: 0CB6948805F797BF2A82807973B89537
5355
SSDEEP: 3:Hn:Hn
5456
CTPH: A:E:E
5557
@@ -79,6 +81,8 @@ MD5: 098f6bcd4621d373cade4e832627b4f6
7981
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
8082
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
8183
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
84+
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
85+
NT Hash: 0CB6948805F797BF2A82807973B89537
8286
`,
8387
recipeConfig: [
8488
{

Diff for: tests/operations/tests/NTLM.mjs

+15-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,26 @@ import TestRegister from "../../lib/TestRegister.mjs";
99

1010
TestRegister.addTests([
1111
{
12-
name: "NTLM Hashing",
12+
name: "NT Hash",
1313
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
1414
expectedOutput: "C5FA1C40E55734A8E528DBFE21766D23",
1515
recipeConfig: [
1616
{
17-
op: "NTLM",
17+
op: "NT Hash",
1818
args: [],
1919
},
2020
],
21-
}
21+
},
22+
{
23+
name: "LM Hash",
24+
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
25+
expectedOutput: "6D9DF16655336CA75A3C13DD18BA8156",
26+
recipeConfig: [
27+
{
28+
op: "LM Hash",
29+
args: [],
30+
},
31+
],
32+
},
33+
2234
]);

0 commit comments

Comments
 (0)