This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programming Diversions and the fly likes Help on finding a password? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "Help on finding a password?" Watch "Help on finding a password?" New topic
Author

Help on finding a password?

Dibbe Dappert
Greenhorn

Joined: Apr 26, 2007
Posts: 4
Howdy

I've got a little JavaScript form that I would like to figure out. Was hoping you guys could help me with that.

<script language="JavaScript">
<!--
x=prompt('Yay\n Enter password:',' ');
x=new String(x + " z");
var y = "1338";
var z = "1";
var f = "y - z";
if (x == f) {
location.href = "?page=soccer&pw=" + x;
}
else {
location.href = "blank.htm";
}
//-->
</script>

I can't seem to understand this. But I don't want access just to get passed it, I also want to learn how that works, so if you could explain a bit about how the code works, that would be great! Thanks

Btw, I'm Norwegian if there was any Norwegians here who finds it easier to write in our own language (if thats permitted)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42360
    
  64
I'd suggest inserting a few alert statements that show you the variable values, or, of course, a JavaScript debugger like Venkman (which is free for Firefox).

Posting in Norwegian is not allowed, since the JavaRanch staff do not speak that language.


Ping & DNS - my free Android networking tools app
Dibbe Dappert
Greenhorn

Joined: Apr 26, 2007
Posts: 4
Well, actually, I found the answer myself But how about this one?

<script language="JavaScript">
<!--
function test(passwd) {
y=String.fromCharCode(115) + String.fromCharCode(101) + String.fromCharCode(passwd.substring(0,1)*11) + String.fromCharCode(114) + String.fromCharCode(101) + String.fromCharCode((passwd.substring(0,1)*13)-1);
if (passwd.substring(1,7) == y) {
location.href = "?page=level17&pw=" + passwd;
}
else {
location.href = "levels/error.php";
}
}
//-->
</script>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help on finding a password?