What am I doing wrong here?!

Intro 10

Codex561
9 years ago | edited 9 years ago

0

First of all, I never studied javascript… now that I think of it I just kinda “know” programing languages (strange but thats not the point).
So I see this script:

[/spoiler ]
And as a logical person I see that it looks like php, a language I happen to know quite well. So I dissect it:

<!-
var thecode = ‘code123’;[/spoiler]
this gives me the thought that it is the password itself but cannot be sure.

<!-
(function(){ $(‘.level-form’).submit(function(e){ e.preventDefault();[/spoiler]
This line, I assume this is meant to detect when I press the “submit” button and trigger the script.

[spoiler]
if ($(‘.level-form #pass’)[0].value == thecode)

This one is quite obvious, if the password I entered is thecode or in other words “code123”

[spoiler]
{ document.location = “?pass=” + thecode; } else { alert(‘Incorrect Password’); } }); }); -!>
If the above is true than I should be forwarded to ?pass=code123 but instead I just get the error alert.

[spoiler]
So I tried making the GET request manually but no luck
https://www.hackthis.co.uk/levels/javascript/3?pass=code123
-!>
What did I do wrong?!?!

13replies
7voices
478views
Cyan Wind [freewind1012]
9 years ago | edited 9 years ago

0

Well, what you did wrong is to spoil this level. Please edit your post by using spoiler tag like this:
[ spoiler ]Your spoiler goes here.[ /spoiler ] (Please remember to remove the spaces!)

About your problem: Have you ever heard about overriding a variable?

Codex561
9 years ago | edited 9 years ago

0

@freewind is there really any point in overriding variables if I already know the value? To what am I suppose to override it?
Oh and also how do I tag people?

rushA [xzy123prog]
9 years ago

0

To tag people just use the “@” symbol, just make sure to write their whole name so that it tags them.

Holographic
9 years ago

0

@Codex561 who said you need to override the variable?

Codex561
9 years ago

0

@holographic freewind1012 did or implied that I need to do so.

I just do not see what I am doing wrong :s

Cyan Wind [freewind1012]
9 years ago | edited 9 years ago

0

@Codex561: Well, I did not say that you needed to override a variable. The variable has already been overridden.

Codex561
9 years ago

0

@freewind1012 Um ok I just solved but it is still confusing….
Thecode is getting set to “code123”, why is the password not “code123”?
var thecode = ‘code123’;
And where does the password pop out of, I do not see it anywhere in the sourcecode

Holographic
9 years ago | edited 9 years ago

0

declaring var thecode inside the function creates another instance of it inside the function. There is another thecode as a global. If you wanted to check against “code123”, you would have to do if ($(‘.level-form #pass’)[0].value == this.thecode)

Codex561
9 years ago

0

@holographic so it was there just to throw people off?

Holographic
9 years ago

0

well, that’s the whole point of the challenge

Evo Prime [littleRed]
8 years ago | edited 8 years ago

0

Your starting point is right, you have to let #pass == thecode;
Use the console in the web dev tool.

check every variable,Than you will get the answer.

Spoonisi
8 years ago | edited 8 years ago

0

Yes littleRed is correct

If you put a variable name in the console and hit enter, this will return the value of the variable

Alien [necromonger]
5 years ago

0

@Spoonisi Thank you for your hint! It was really helpful!

You must be logged in to reply to this discussion. Login
1 of 14

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss