Javascript - Authentication 2
Description
Yes folks, Javascript is damn easy :)
Solution
Let’s visit the site’s source code by this command
1
curl http://challenge01.root-me.org/web-client/ch11/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<html>
<head>
<title>JS Authentication</title>
<script language="JavaScript" src="login.js"></script>
</head>
<body><link rel='stylesheet' property='stylesheet' id='s' type='text/css' href='/template/s.css' media='all' /><iframe id='iframe' src='https://www.root-me.org/?page=externe_header'></iframe>
<div id=EchoTopic>
<p>Authentication</p>
<p><input type="button" value="login" onclick="connexion();"></p>
<br/><br/>
<a href="javascript:window.close();">Close Window</a>
</div>
</body>
</html>
Let’s check the login.js
file:
1
curl http://challenge01.root-me.org/web-client/ch11/login.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function connexion(){
var username = prompt("Username :", "");
var password = prompt("Password :", "");
var TheLists = ["GOD:HIDDEN"];
for (i = 0; i < TheLists.length; i++)
{
if (TheLists[i].indexOf(username) == 0)
{
var TheSplit = TheLists[i].split(":");
var TheUsername = TheSplit[0];
var ThePassword = TheSplit[1];
if (username == TheUsername && password == ThePassword)
{
alert("Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)");
}
}
else
{
alert("Nope, you're a naughty hacker.")
}
}
}
We have:
1
2
username=="GOD"
password=="HIDDEN"
See JavaScript String split() for more information.
They said:
1
You can use this password to validate this challenge (uppercase)
The flag is:
1
HIDDEN
This post is licensed under CC BY 4.0 by the author.