-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathhashcat.js
More file actions
44 lines (36 loc) · 1.29 KB
/
hashcat.js
File metadata and controls
44 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { exec } = require('child_process');
function runHashcat(algorithm) {
const hashesFile = algorithm + '_hashes.txt'; // Hashes file // Algorithm name (e.g., 'md5', 'sha1')
const crackedFile = 'cracked.txt'; // Output file for cracked hashes
// Map algorithms to Hashcat mode IDs
const algorithmModeMap = {
md5: 0,
sha1: 100,
sha256: 1400,
sha512: 1700,
'sha3-256': 17400
};
const hashcatMode = algorithmModeMap[algorithm];
if (hashcatMode === undefined) {
const error = new Error(`Unsupported algorithm: ${algorithm}`);
console.error(error.message);
return;
}
const mask = '?a?a?a?a?a';
console.log(`Running Hashcat for ${algorithm}...`);
// Construct the Hashcat command
const command = `hashcat --potfile-disable -m ${hashcatMode} -a 3 -o ${crackedFile} ${hashesFile} ${mask}`;
// Execute the Hashcat command
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`Hashcat Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`Hashcat Stderr: ${stderr}`);
}
console.log(`Hashcat Output:\n${stdout}`);
});
}
const args = process.argv.slice(2);
runHashcat(args[0]);