LEVEL 1

Double DES

crypto
  • 문제 정보
  • 풀이 25
  • 난이도 투표 45
  • 질문 2
  • 최근 풀이자 562
  • 댓글 4

문제 설명

4바이트 전수 조사 쯤이야 간단하죠!

난이도 투표 45

질문 2

문제 풀이에 어려움이 있으신가요?
커뮤니티에서 문제에 대한 질문하고 답변 얻기
최종 솔브 코드 어떻게?
로드맵 강의 천천히 따라가면서 Meet-in-the-middle attack을 실습하고 있습니다. 첨부파일 다운로드 하고 코드 분석, 익스플로잇 설계까지 코드 모두 이해했습니다. 문제 prob.py파일 코드** #!/usr/bin/env python3 from Crypto.Cipher import DES import signal import os if name == "main": signal.alarm(15) with open("flag", "rb") as f: flag = f.read() key = b'Dream_' + os.urandom(4) + b'Hacker' key1 = key[:8] key2 = key[8:] print("4-byte Brute-forcing is easy. But can you do it in 15 seconds?") cipher1 = DES.new(key1, DES.MODE_ECB) cipher2 = DES.new(key2, DES.MODE_ECB) encrypt = lambda x: cipher2.encrypt(cipher1.encrypt(x)) decrypt = lambda x: cipher1.decrypt(cipher2.decrypt(x)) print(f"Hint for you :> {encrypt(b'DreamHack_blocks').hex()}") msg = bytes.fromhex(input("Send your encrypted message(hex) > ")) if decrypt(msg) == b'give_me_the_flag': print(flag) else: print("Nope!") 최종 솔브 코드** from pwn import * from Crypto.Cipher import DES io = process(["python3", "prob.py"]) io = remote("host3.dreamhack.games", 18664) io.recvuntil(b":> ") hint = bytes.fromhex(io.recvline().decode()) conflict = dict() for i in range(65536): b = i.to_bytes(2, "big") cipher = DES.new(b"Dream_" + b, DES.MODE_ECB) enc = cipher.encrypt(b"DreamHack_blocks") conflict[enc] = b"Dream_" + b for i in range(65536): b = i.to_bytes(2, "big") cipher = DES.new(b + b"Hacker", DES.MODE_ECB) dec = cipher.decrypt(hint) if dec in conflict: key1 = conflict[dec] key2 = b + b"Hacker" break cipher1 = DES.new(key1, DES.MODE_ECB) cipher2 = DES.new(key2, DES.MODE_ECB) encrypt = lambda x: cipher2.encrypt(cipher1.encrypt(x)) assert encrypt(b"DreamHack_blocks") == hint io.sendlineafter(b'> ', encrypt(b"give_me_the_flag").hex().encode()) flag = eval(io.recvline()) io.close() print(flag.decode()) 강의에서 설명하는 원리와 코드는 이해했는데 이를 환경에 어떻게 적용해서 flag를 얻어야 할지 모르겠습니다. 칼리 리눅스, zsh, pwntools, tqdm, pycryptodome 패키지 모두 설치했습니다.
lnan9yeol
LEVEL 1

Double DES

crypto

출제자 정보

avatar
Dreamhack
대표 업적 없음

First Blood!

avatar
One_
웹해킹 고인물
출제된 지 3개월 만에 풀이 완료!

최근 풀이자 562

Maruchi
대표 업적 없음
sq777
대표 업적 없음
RsutLover
대표 업적 없음
avatar
aran08
.HACK 2025 참가자
practice10234987
대표 업적 없음
stce1009
대표 업적 없음
no_hoguma
대표 업적 없음
kimjw
대표 업적 없음
AKO
리버싱 초심자

댓글 4

avatar
Rootsquare
바탈리온
브루트포스 전략 연습
avatar
Zer0Luck
대표 업적 없음
강의 복습에 아주 유용했습니다. 👍
avatar
스카이넷
워게임 고인물
ez
avatar
One_
웹해킹 고인물
기존 로드맵에 비해 설명이 많아서 확실히 이해하는데에 도움이 많이 됩니다. GOAT 드림핵 😎