<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by _cheese on Medium]]></title>
        <description><![CDATA[Stories by _cheese on Medium]]></description>
        <link>https://medium.com/@5023798?source=rss-6ed57817c8cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uMkStbLeC2kCWj8q0LwA7g.jpeg</url>
            <title>Stories by _cheese on Medium</title>
            <link>https://medium.com/@5023798?source=rss-6ed57817c8cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 04:21:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@5023798/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[[Log #02] CTF 풀이 01]]></title>
            <link>https://medium.com/@5023798/log-02-ctf-%ED%92%80%EC%9D%B4-01-f78474d17ea4?source=rss-6ed57817c8cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f78474d17ea4</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[dreamhack]]></category>
            <dc:creator><![CDATA[_cheese]]></dc:creator>
            <pubDate>Sun, 18 Jan 2026 08:50:16 GMT</pubDate>
            <atom:updated>2026-01-18T08:50:16.265Z</atom:updated>
            <content:encoded><![CDATA[<p>어제에 이어서 Dreamhack Crypto CTF 몇 문제를 풀었습니다. 기초적인 내용들이라 길게 적기는 뭐해서 뭐 풀었는지만 기록할까 해요.</p><p>web3 해킹 캠프를 하면서 느낀건데, 해커 지망이 아니더라도 공부를 할때 해킹을 중심으로 Edge Case를 중심으로 학습하는게 깊이있는 이해에 좋다는 생각이 들더군요.(해킹이라 하긴 뭐한 기초 문제긴 함)</p><h3><a href="https://dreamhack.io/wargame/challenges/1114">addition-quiz</a></h3><blockquote>랜덤한 2개의 숫자를 더한 결과가 입력 값과 일치하는지 확인하는 과정을 50번 반복하는 프로그램입니다. 모두 일치하면 flag 파일에 있는 플래그를 출력합니다. 알맞은 값을 입력하여 플래그를 획득하세요.</blockquote><p>pwntools를 사용해서 exploit 작성하는 테스팅용 문제.</p><h3><a href="https://dreamhack.io/wargame/challenges/1874">flag-shop</a></h3><blockquote>flag-shop에 오신 것을 환영합니다! 주어진 10개의 아이템 중 flag를 정확히 골라서 구매해야 합니다. 제한 시간은 10초입니다.</blockquote><p>비슷</p><p>고전 암호도 공부했는데, 치환 암호, 전치 암호, 블록 암호, 스트림 암호 … 어디서 들어본 내용의 연속이더군요. 오랜만에 교양 쌓는 느낌으로 쭉 읽었습니다. Sage Math 설치하다가 혈압이 올랐는데 어찌어찌 되긴 했습니다. Go 로만 암호학 코딩을 해봤었는데, Python 암호학 라이브러리 한번씩 만저보니 왜 쓰는지 알 것 같네요. 편해요</p><h3><a href="https://dreamhack.io/wargame/challenges/1118">Double DES</a></h3><blockquote>4바이트 전수 조사 쯤이야 간단하죠! <a href="https://dreamhack.io/lecture/courses/543">Exploit Tech: Meet in the middle attack</a>에서 함께 실습하는 문제입니다.</blockquote><p>DES의 총 4바이트의 random성을 유추하는 문제. 완전 탐색으로는 2³²의 루프를 돌아야 해서 15초 타임아웃 안에는 안되더라구요.</p><pre>&gt;&gt;&gt; print(f&quot;Hint for you :&gt; {encrypt(b&#39;DreamHack_blocks&#39;).hex()}&quot;)<br>Hint for you :&gt; dcbc7dc9aea1e1ff8e37814d54f2dd4c<br>&gt;&gt;&gt; print(f&quot;Hint for you :&gt; {encrypt(b&#39;DreamHack_alocks&#39;).hex()}&quot;)<br>Hint for you :&gt; dcbc7dc9aea1e1ffd79e830def96a012</pre><p>처음 생각한 방법은 left 4bytes는 그대로고, right 4 bytes만 바뀌는 Block 암호의 특성을 이용하면 어캐 되지 않을까 고민했습니다.</p><pre>key = b&#39;Dream_&#39; + os.urandom(4) + b&#39;Hacker&#39;<br>key1 = key[:8]<br>key2 = key[8:]<br>cipher1 = DES.new(key1, DES.MODE_ECB)<br>cipher2 = DES.new(key2, DES.MODE_ECB)<br>encrypt = lambda x: cipher2.encrypt(cipher1.encrypt(x))<br>decrypt = lambda x: cipher1.decrypt(cipher2.decrypt(x))</pre><p>근데 문제는 key1, key2 의 각 2바이트를 유추하는건데 DES 연산에서 2중으로 모든 key가 관여하기 때문에 분할해서 계산하는 방식이 직관적으로 불가능해 보이더군요.</p><p>알고리즘 푼지 오래돼서 놓치고 있었는데(고민하다 답지를 봄) Hashmap 을 통해서 ciper1.encrypt 에 대한 연산 값만 DP 알고리즘 풀듯이 기록해두는 방식으로 exploit 하였습니다. 이러면 key1, key2를 분할해서 기록하여 2¹⁶ 씩 탐색하면 되더군요.</p><p>답지를 본 나에게 반성하는 시간을 조금 가졌습니다.</p><h3>40 Birthdays</h3><blockquote>생일이 같은 두 친구를 찾아주세요! <a href="https://dreamhack.io/lecture/courses/561">Exploit Tech: Birthday paradox</a>에서 함께 실습하는 문제입니다.</blockquote><p>반성하면서 비슷한 문제를 가져왔습니다. 근데 그냥 똑같이 middle attack 으로 풀려서 풀이하기 뭐하네요. 2분 걸렸어요.</p><p>오늘 목표 끝</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f78474d17ea4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Log #01] Pwntools and Linux]]></title>
            <link>https://medium.com/@5023798/log-01-pwntools-and-linux-73913e4f82a0?source=rss-6ed57817c8cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/73913e4f82a0</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[_cheese]]></dc:creator>
            <pubDate>Sat, 17 Jan 2026 09:52:29 GMT</pubDate>
            <atom:updated>2026-01-17T09:55:20.232Z</atom:updated>
            <content:encoded><![CDATA[<p>현재 Web3 개발을 하다가, 기본기 부족을 통감하고 1일 1 로그로 학습 회고를 남기기로 했습니다. 암호학이나 검증 가능한 컴퓨팅 등에 관심이 많습니다.</p><p><strong>주요 관심사: </strong>Dreamhack Crypto, Crypto CTF 문제 풀이, LWE, FHE, zk infra(RISC Zero, SP1, Noir), On-chain Darkpool &amp; mixer</p><p>목표는 지식에 대한 정리가 아니라 과정을 기록하는 겁니다. 지식에 대한 정리는 너무 시간이 많이 들고, 공부하는데 방해가 되며, 다른 분들에게 제 수준의 글은 큰 도움이 안될 것 같아요. 주요 관심사들 하나씩 도장깨기 할 것 같아요.</p><h3>Pwntools and Linux</h3><p>오늘은 Dreamhack의 Crypto Course를 학습했습니다. pwntools의 필요성에 대한 의문들이 있더라구요. 최근 프롬프팅 방법론 중에서 학습에 좋았던 것은 `Generate Knowledge Prompting` 인데 대충 이렇습니다.</p><blockquote>“Before addressing my specific question, please provide some foundational knowledge. I would like an overview of the background of the pwntools library and an introduction to CryptoHack. As a beginner in cryptography who needs to learn quickly, what are the essential concepts I should focus on first?”</blockquote><p>Number Theory, Symmetric Cryptography, Asymmetric Cryptography와 같은 것들을 추천해주고, Pwntools에 대해서는 아래와 같습니다.</p><ul><li><strong>Remote Interaction:</strong> Most crypto challenges provide a network address (IP and port). Pwntools allows you to connect and interact with these services easily using the remote module.</li><li><strong>Data Conversion:</strong> Cryptography involves constant switching between data formats. Pwntools has built-in functions for this (e.g., p64() to pack integers into bytes, hex() for hexadecimal representation, and xor() for bitwise operations).</li><li><strong>Automation:</strong> Crypto attacks often require thousands of requests or complex calculations. Pwntools lets you automate the “handshake” with a server so you can focus on the math.</li></ul><p>TCP의 3-way handshake 과정의 추상화나 데이터 변환 등의 서버와의 Interaction 자동화에 도움을 주는 툴인 것 같아요.</p><p>저는 Mac을 사용하기도 하고, 미니PC 한 대 셋팅했는데 우분투 24.04 버전이여서 셋업하는데 조금 시간을 뺏겼습니다. process(), remote() 처럼 로컬 환경과 서버 환경에서 pwntools를 사용하는 연습을 했습니다. GDB 디버거 예제와 pack &amp; unpack 등등 유용한 기능들이 있는데, 설명은 생략합니다.</p><p>제가 주로 마주한 장애물들은 ELF 와 MMAP, ELP Header과 같은 Linux와 Python 내부적인 동작에 대한 지식 없음 이슈였습니다.</p><pre>(venv) ham@ham-SER8:~/Documents/crypto$ echo -e &#39;#include &lt;stdio.h&gt;\nint main(){ printf(&quot;Hello from the binary!\\n&quot;); return 0; }&#39; &gt; test.c<br>(venv) ham@ham-SER8:~/Documents/crypto$ ls<br>test.c  venv<br>(venv) ham@ham-SER8:~/Documents/crypto$ gcc test.c -o example<br>(venv) ham@ham-SER8:~/Documents/crypto$ ls -l example<br>-rwxrwxr-x 1 ham ham 15960 Jan 17 15:16 example<br><br>(venv) ham@ham-SER8:~/Documents/crypto$ touch example2<br>(venv) ham@ham-SER8:~/Documents/crypto$ chmod +x example2<br>(venv) ham@ham-SER8:~/Documents/crypto$ ls<br>example  example2  test.c  venv<br><br>(venv) ham@ham-SER8:~/Documents/crypto$ python<br>Python 3.12.3 (main, Jan  8 2026, 11:30:50) [GCC 13.3.0] on linux<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>&gt;&gt;&gt; from pwn import *<br>&gt;&gt;&gt; elf = ELF(&#39;./example&#39;)<br>[*] &#39;/home/ham/Documents/crypto/example&#39;<br>    Arch:       amd64-64-little<br>    RELRO:      Full RELRO<br>    Stack:      No canary found<br>    NX:         NX enabled<br>    PIE:        PIE enabled<br>    SHSTK:      Enabled<br>    IBT:        Enabled<br>    Stripped:   No<br>&gt;&gt;&gt; print(f&quot;Entry Point: {hex(elf.entry)}&quot;)<br>Entry Point: 0x1060<br>&gt;&gt;&gt; print(f&quot;Architecture: {elf.arch}&quot;)<br>Architecture: amd64<br>&gt;&gt;&gt; print(f&quot;Bits: {elf.bits}&quot;)<br>Bits: 64<br>&gt;&gt;&gt; elf = ELF(&#39;./example2&#39;)<br>Traceback (most recent call last):<br>  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>  File &quot;/home/ham/Documents/crypto/venv/lib/python3.12/site-packages/pwnlib/elf/elf.py&quot;, line 224, in __init__<br>    self.mmap = mmap.mmap(self.file.fileno(), 0, access=mmap.ACCESS_COPY)<br>                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^<br>ValueError: cannot mmap an empty file<br>&gt;&gt;&gt;<br></pre><p>mmap</p><p>디스크에 있는 파일을 메모리(RAM) 주소 공간에 직접 매핑하는 시스템 콜입니다. 메모리는 보통 4KB(Page) 단위로 관리됩니다. 0바이트 파일은 매핑할 ‘공간’ 자체가 존재하지 않기 때문에 커널 수준에서 에러를 뱉고, 파이썬의 mmap 모듈이 이를 ValueError로 전달한 것입니다.</p><p>ELF 헤더의 최소 요건</p><p>pwntools의 ELF() 클래스는 파일을 열자마자 가장 먼저 Magic Bytes를 확인합니다. 파일의 첫 4바이트가 \x7fELF 여야만 “아, 이 파일은 실행 파일이구나!”라고 인식합니다. Touch 로 파일 생성 및 chmod 로 +x 권한을 줘도 당연히 실패하겠죠.</p><p>2번째 이슈는 GDB 디버거 테스팅하다가 발생한 리눅스의 Yama 보안모델과 ssh 접속 이슈들이였습니다. 환경 세팅 중 gdb.attach(p)가 15초 타임아웃과 함께 실패하는 문제를 겪었습니다. 원인은 리눅스 보안 메커니즘과 프로세스 관리 방식에 있었습니다.</p><pre>(venv) ham@ham-SER8:~/Documents/crypto$ python<br>from pwn import *<br>(venv) ham@ham-SER8:~/Documents/crypto$ sudo sysctl -w kernel.yama.ptrace_scope=0<br>kernel.yama.ptrace_scope = 0<br>(venv) ham@ham-SER8:~/Documents/crypto$ python<br>Python 3.12.3 (main, Jan  8 2026, 11:30:50) [GCC 13.3.0] on linux<br>Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>&gt;&gt;&gt; from pwn import *<br>&gt;&gt;&gt; context.terminal = [&quot;tmux&quot;, &quot;splitw&quot;, &quot;-h&quot;]<br>&gt;&gt;&gt; p = process(&quot;./example&quot;)<br>[x] Starting local process &#39;./example&#39;<br>[+] Starting local process &#39;./example&#39;: pid 23541<br>&gt;&gt;&gt; gdb.attach(p)<br>[*] running in new terminal: [&#39;/usr/bin/gdb&#39;, &#39;-q&#39;, &#39;./example&#39;, &#39;-p&#39;, &#39;23541&#39;]<br>[x] Waiting for debugger<br>[-] Waiting for debugger: Debugger did not attach to pid 23541 within 15 seconds</pre><p>ptrace는 한 프로그램(Tracer, 예: GDB)이 다른 프로그램(Tracee, 예: 실행 바이너리)의 실행을 관찰하고 제어할 수 있게 해주는 시스템 콜입니다. 메모리를 읽거나 레지스터를 수정하고, 실행을 일시 정지시킬 수 있는 강력한 권한을 가집니다.</p><p>GDB가 디버깅 대상에 붙지 못하고 타임아웃이 발생하는 동안, 바이너리는 실행을 끝내고 종료됩니다. 이때 부모 프로세스(Python 스크립트)가 자식의 종료 상태를 확인(wait)하지 못하면, 해당 프로세스는 프로세스 테이블에 정보만 남은 <strong>‘좀비(Zombie)’</strong> 상태가 됩니다.</p><p>물론 이걸 적용해도 제가 만든 executable file이 너무 빨라서 디버거 로드 이전에 실행되어서 실패했습니다만, 추후에 필요하면 사용해볼 것 같아요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73913e4f82a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>