forked from ChrisCho-H/hacking
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasyHack.js
36 lines (31 loc) · 1.14 KB
/
easyHack.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
import crypto from 'crypto';
const mnemonic = "where kingdom affair speak skin blanket bright case chunk citizen ecology way";
const salt = crypto.randomBytes(32);
const initializationVector = crypto.randomBytes(16);
const cipher = crypto.createCipheriv(
"aes-256-gcm",
crypto.pbkdf2Sync(
Buffer.from("123456", 'utf-8'),
salt,
10000, 32, 'sha256'),
initializationVector);
const firstChunk = cipher.update(mnemonic);
const secondChunk = cipher.final();
const tag = cipher.getAuthTag();
const encryptedVault = Buffer.concat([firstChunk, secondChunk]);
let decryptedVault;
const start = Date.now();
const decipher = crypto.createDecipheriv(
"aes-256-gcm",
crypto.pbkdf2Sync(
Buffer.from("123456", 'utf-8'),
salt,
10000, 32, 'sha256'),
initializationVector);
decipher.setAuthTag(tag);
const firstChunk2 = decipher.update(encryptedVault);
const secondChunk2 = decipher.final();
decryptedVault = Buffer.concat([firstChunk2, secondChunk2]).toString();
const end = Date.now();
console.log(decryptedVault);
console.log("Time for single triage when iteration of 10,000: "+(end-start)/1000+"s");