Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Need some help with Javascript mission!


ghost's Avatar
0 0

Okay, so here is my problem:

I just scripted my very first "mission" in javascript (and html duhuh!) It's a mission where you need to use a certain user-agent to get the update and pass. I never scripted something like this before so I was quite happy when I noticed It worked! But when I asked a friend to solve my "mission" I wasn't really happy with the method he used to pass it; He just downloaded the script and he raped all my javascript to get to the next level :( So this is the code of the first page:

<head>
</head>
<script type="text/javascript">



function checkbrowser()

{
	var browsername=navigator.appName;
	if (browsername!="FeatherFox" )
	{
		alert ("This page only contains updates for FeatherFox" )
	}
	else
	{
		window.location.href="passed.htm"
	}
}
</script>	```

and below that a link with and "onclick" to "checkbrowser()"

And here is passed.htm:

```markup<html>
<head>
<script type="text/javascript">

	var browsername=navigator.appName;
	if (browsername!="FeatherFox" )
	{
		alert ("Piss of! Do you think I'm stupid?!" +'\n'+ " It's not that easy!" )
		window.location.href="mission.htm"
	}
	</script>	```

with the check again so just replacing "mission" with "passed" in the URL bar won't make you pass the mission.

Now my question is pretty obvious:
How to I prevent people from just stripping out the javascript?
Or is the only way using PHP?
(well I hope not because PHP seems to be just a little bit to difficult for me right now)

Thanks in advance!

S-H

ghost's Avatar
0 0

I'm not good on security or PHP but I think it has to be php like this:

<?php
if($HTTP_REFERER != "mission.php") {
echo "Trying to cheat sucka?";
} else {<script type="text/javascript">

var browsername=navigator.appName;
if (browsername!="FeatherFox" )
{
alert ("Piss of! Do you think I'm stupid?!" +'\n'+ " It's not that easy!" )
window.location.href="mission.htm"
}
</script> 
}
?>