-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·39 lines (32 loc) · 1.24 KB
/
index.js
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
#!/usr/bin/env node
const readlineSync = require('readline-sync');
const chalk = require('chalk');
const { displayHelp, hashPassword, fetchHashList } = require('./util');
let option, password, passwordHash;
let isPawned = false;
// Check option
[,, option, password] = process.argv; // Retrieve user password and option from args
if ((option !== '--password') && (option !== '-p')) {
displayHelp();
}
// Check if a password was passed
if (!password) {
passwordHash = hashPassword(readlineSync.question('Password: ', { hideEchoBack: true }));
} else {
console.log(chalk.red('Typing your password within the terminal is unsafe!'));
console.log('Use the --password(-p) option without any arguments to hide your password.\n');
passwordHash = hashPassword(password);
password = '';
}
fetchHashList(passwordHash, hashList => {
hashList.forEach(element => {
if (element.passwordHash === passwordHash.substring(5)) {
isPawned = true;
console.log(chalk.red('Your password has been compromised!'));
console.log(`It appears ${chalk.red(element.appearances)} times within the data set.`);
}
});
if (!isPawned) {
console.log(chalk.green('Your password was not found within the data set of compromised passwords.'));
}
});