2022-09-27 23:13:22 +02:00
/ * *
* @ author brun0ne [ brunonblok @ gmail . com ]
* @ copyright Crown Copyright 2022
* @ license Apache - 2.0
* /
import Operation from "../Operation.mjs" ;
import { runHash } from "../lib/Hash.mjs" ;
/ * *
2022-10-15 00:13:39 +01:00
* NT Hash operation
2022-09-27 23:13:22 +02:00
* /
2022-10-15 00:13:39 +01:00
class NTHash extends Operation {
2022-09-27 23:13:22 +02:00
/ * *
2022-10-15 00:13:39 +01:00
* NTHash constructor
2022-09-27 23:13:22 +02:00
* /
constructor ( ) {
super ( ) ;
2022-10-15 00:13:39 +01:00
this . name = "NT Hash" ;
2022-09-27 23:13:22 +02:00
this . module = "Crypto" ;
2022-10-15 00:13:39 +01:00
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." ;
this . infoURL = "https://wikipedia.org/wiki/NT_LAN_Manager" ;
2022-09-27 23:13:22 +02:00
this . inputType = "string" ;
this . outputType = "string" ;
this . args = [ ] ;
}
/ * *
* @ param { string } input
* @ param { Object [ ] } args
* @ returns { string }
* /
run ( input , args ) {
2023-03-09 18:06:32 +00:00
// Convert to UTF-16LE
const buf = new ArrayBuffer ( input . length * 2 ) ;
const bufView = new Uint16Array ( buf ) ;
for ( let i = 0 ; i < input . length ; i ++ ) {
bufView [ i ] = input . charCodeAt ( i ) ;
}
const hashed = runHash ( "md4" , buf ) ;
2022-09-27 23:13:22 +02:00
return hashed . toUpperCase ( ) ;
}
}
2022-10-15 00:13:39 +01:00
export default NTHash ;