Created
March 28, 2021 17:31
-
-
Save PaluMacil/3992860d5d2bcedcaa91933fcd653ffe to your computer and use it in GitHub Desktop.
MD5 password file generator for demonstrating john the ripper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cryptMD5 } from 'cryptmd5'; | |
import { appendFile } from 'fs'; | |
const pwPerFile = 5; | |
function writeFile(pwSize) { | |
const filename = `pwLen${pwSize}.txt`; | |
console.log(`starting ${filename}`); | |
for (let i = 0; i < pwPerFile; i++) { | |
const password = passwordOf(pwSize); | |
const hash = cryptMD5(password, 'erXgIjX7') | |
console.log(`generated pw '${password}' and hash ${hash}`); | |
appendFile(filename, hash + '\n', function (err) { | |
if (err) { | |
console.error(`could not write ${hash} to ${filename}`); | |
console.log(err); | |
} else { | |
console.log('appended to file') | |
} | |
}) | |
} | |
console.log(`finished writing to ${filename}`); | |
} | |
function passwordOf(len) { | |
let res = ''; | |
const chars = 'abcdefghijklmnopqrstuvwxyz'; | |
const charsAvailable = chars.length; | |
for (let i = 0; i < len; i++) { | |
res += chars.charAt(Math.floor(Math.random() * charsAvailable)); | |
} | |
return res; | |
} | |
writeFile(1); | |
writeFile(2); | |
writeFile(3); | |
writeFile(4); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "pwa-node", | |
"request": "launch", | |
"name": "Launch Program", | |
"skipFiles": [ | |
"<node_internals>/**" | |
], | |
"program": "${workspaceFolder}/index.js" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "genmd5", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"type": "module", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"cryptmd5": "^0.1.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please be aware that this is designed to make passwords crackable in the blink of an eye--NOT passwords for actual use. Demonstrations of cracking tools is virtually the only good use of MD5. Last I checked, MD5 was only broken for collisions and technically isn't pre-image resistant, but it will still show red flags to pen testers and auditors. Also, if you need to look up first pre-image vs second pre-image vs collision resistance, you probably shouldn't consider MD5 anyway.