Created
December 28, 2015 16:01
-
-
Save kvermeille/9757545d4b7f90a84d74 to your computer and use it in GitHub Desktop.
A naive nodejs script to brute force password protected zip files, with all password that match /[a-z]+/
This file contains 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
// zipping: | |
// zip -e target.zip file.something #...prompt for password | |
// unzipping: | |
// 7z e target.zip -pPASSWORD | |
//////////////////// | |
function Dictionary(ab) { | |
this.ab = ab; | |
this.abl = ab.length; | |
} | |
Dictionary.prototype.excelColumn = function(index) { | |
index--; | |
var value = ''; | |
while (index >= 0) { | |
value = this.ab[index % this.abl] + value; | |
index = Math.floor(index / this.abl) - 1; | |
} | |
return value; | |
} | |
Dictionary.prototype.valueAsString = function(index) { | |
return index.toString(this.abl).split('').map(function(c) { return this.ab[parseInt(c,this.abl)]; }.bind(this)).join(''); | |
} | |
//////////////////// | |
var spawn = require('child_process').spawn; | |
var dict = new Dictionary('abcdefghijklmnopqrstuvwxyz'); | |
var file = 'safe.zip'; | |
var threads = 2; | |
var start = 4400000; | |
function checkPassByIndex(i) { | |
var pass = dict.excelColumn(i); | |
spawn('7z', ['e', file, '-otarget/', '-y', '-p' + pass]).on('exit', function(code) { | |
console.log(code ? "failed on" : "ffffffffffound! [:", i, pass); | |
code ? checkPassByIndex(i+threads) : process.exit(); | |
}); | |
} | |
for (var t=0; t<threads; t++) { | |
checkPassByIndex(t+start); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment