728x90
Network Attacks
(아래 사이트 3번째 문제)
https://cryptohack.org/challenges/introduction/
CryptoHack – Home
A fun, free platform to learn about cryptography through solving challenges and cracking insecure code. Can you reach the top of the leaderboard?
cryptohack.org
문제 코드
#!/usr/bin/env python3
import telnetlib
import json
HOST = "socket.cryptohack.org"
PORT = 11112
tn = telnetlib.Telnet(HOST, PORT)
def readline():
return tn.read_until(b"\n")
def json_recv():
line = readline()
return json.loads(line.decode())
def json_send(hsh):
request = json.dumps(hsh).encode()
tn.write(request)
print(readline())
print(readline())
print(readline())
print(readline())
request = {
"buy": "clothes"
}
json_send(request)
response = json_recv()
print(response)
nc socket.cryptohack.org 11112 로 접속한 후 flag, clothes 등을 입력해보았지만 모두 에러 메세지가 떴다.
칼리 리눅스에서 해당 사이트에 접속하고 문제 파일을 다운 받았다. 그리고 문제 파일이 있는 디렉토리로 이동해서 파일을 실행해 보았다. 에러 메세지에 우리는 항상 'flags'만 판다고 나와있다.
문제에서 주어진 코드를 보면 buy: clothes 즉, 사는 것이 옷이라고 되어 있는데 이것을 flag로 수정하면 파는 것이 flag가 되므로 clothes->flags로 수정해주었지만 또 오류가 났다.
이번에는 아래와 같이 flag로 코드를 변경하고 실행을 했더니 플래그가 나왔다.
clothes->flag
[바꾼 파이썬 코드]
#!/usr/bin/env python3
import telnetlib
import json
HOST = "socket.cryptohack.org"
PORT = 11112
tn = telnetlib.Telnet(HOST, PORT)
def readline():
return tn.read_until(b"\n")
def json_recv():
line = readline()
return json.loads(line.decode())
def json_send(hsh):
request = json.dumps(hsh).encode()
tn.write(request)
print(readline())
print(readline())
print(readline())
print(readline())
request = {
"buy": "flag"
}
json_send(request)
response = json_recv()
print(response["flag"])
crypto{sh0pp1ng_f0r_fl4g5}
'활동들.. > Incognito' 카테고리의 다른 글
rec&일회용 패드&블록암호 (0) | 2022.10.12 |
---|---|
Feistal Network 3R 그리기 (0) | 2022.10.12 |
암호학 퀴즈 (0) | 2022.09.05 |
RSA 암호화 프로그래밍 (0) | 2022.08.08 |
ENCODING ASCII (0) | 2022.08.08 |