기초 리버스 엔지니어링 기법
디버깅과 디스어셈블리 기술을 활용하여 소스 코드 없이 간단한 바이너리를 분석하고, 함수를 식별하며, 프로그램의 논리를 이해합니다.
기초 리버스 엔지니어링 기법은(는) CoddyKit의 무료 Assembly Language & x86 Low-Level Systems Programming 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Assembly Language & x86 Low-Level Systems Programming 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Assembly Language & x86 Low-Level Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
What is Reverse Engineering?
Reverse engineering (RE) is the process of analyzing software to understand its inner workings without having access to its original source code. Think of it as being a detective for programs!
It involves taking a compiled program (a binary) and working backward to figure out what it does, how it does it, and sometimes, why.
Your RE Toolkit
To reverse engineer, you'll primarily use two types of tools:
- Disassemblers: These tools convert machine code (the raw bytes of a program) back into human-readable assembly language. Popular examples include
objdump, IDA Pro, and Ghidra. They are your 'eyes' into the program's instructions. - Debuggers: Tools like GDB (GNU Debugger) allow you to run a program step-by-step, pause its execution, and inspect the contents of registers and memory at any point. They are your 'hands' for interacting with the live program.
Meet Our Target Program
For this lesson, we'll analyze a simple x86 assembly program. Imagine you only have its compiled version and need to figure out its logic!
This program simulates a basic 'password check' by comparing two hardcoded values and printing a message based on the result.
section .data
msg_access db "Access granted!", 0xA
len_access equ $ - msg_access
msg_denied db "Access denied.", 0xA
len_denied equ $ - msg_denied
section .text
global _start
_start:
; Simulate checking a "password" value
mov eax, 1234 ; Our "secret" password value
mov ebx, 5678 ; A "user-provided" value
cmp eax, ebx ; Compare secret with user input
je .access_granted ; If equal, jump to access granted
.access_denied:
mov eax, 4 ; sys_write
mov ebx, 1 ; stdout
mov ecx, msg_denied
mov edx, len_denied
int 0x80
jmp .exit
.access_granted:
mov eax, 4 ; sys_write
mov ebx, 1 ; stdout
mov ecx, msg_access
mov edx, len_access
int 0x80
.exit:
mov eax, 1 ; sys_exit
mov ebx, 0 ; Exit code 0
int 0x80Compiling & Disassembling
First, we'd compile our assembly program into an executable. On Linux, this typically involves an assembler (like NASM) and a linker (like LD).
nasm -f elf32 program.asm -o program.old -m elf_i386 program.o -o program
Then, we use a disassembler like objdump to see the machine code converted back into assembly:
objdump -d program
Here's a snippet of what you might see:
08048060 <_start>:
8048060: b8 d2 04 00 00 mov $0x4d2,%eax
8048065: bb 36 16 00 00 mov $0x1636,%ebx
804806a: 39 d8 cmp %ebx,%eax
804806c: 74 1c je 804808a <.access_granted>
Identifying Entry Points
When reverse engineering, one of the first things you look for is the program's entry point. This is where execution begins.
For Linux executables compiled from assembly, the entry point is often labeled _start. In our disassembled output, you can see the <_start> label at address 08048060.
This tells you exactly where the CPU starts executing instructions when the program is loaded.
Tracing Program Flow & Jumps
To understand a program's logic, you need to trace its flow of execution. Conditional jump instructions are key to understanding decision-making (like if/else statements).
In our example, after comparing eax and ebx with cmp %ebx,%eax, we see je 804808a <.access_granted>.
cmp: Compares two values and sets CPU flags.je(Jump if Equal): If the comparison result was equal, execution jumps to the address0804808a(our.access_grantedblock).- If not equal, execution continues to the next instruction in sequence (the
.access_deniedblock).
Understanding System Calls
Programs interact with the operating system through system calls. On Linux x86 (32-bit), these are typically invoked using the int 0x80 instruction.
Before int 0x80, specific registers are loaded with values:
eax: Contains the system call number (e.g.,4forsys_write,1forsys_exit).ebx, ecx, edx: Hold arguments for the system call (e.g., file descriptor, buffer address, length forsys_write).
By observing these patterns, you can identify actions like writing to the console or exiting the program.
Extracting Strings and Data
Messages and other static data are stored in data sections of the binary. You can often view these using objdump -s -j .data program or objdump -s -j .rodata program.
In the assembly, you'll see instructions that load the address of these strings into a register (e.g., mov ecx, 0x8049080 where 0x8049080 points to a string).
For our example, the messages "Access granted!" and "Access denied." would be found in the .data section, and their addresses are passed to sys_write.
Reconstructing the Original Logic
By combining all these observations, we can reconstruct the program's original logic:
- It starts at
_start. - It loads two specific integer values into
eaxandebx. - It compares these two values.
- If they are equal, it jumps to a section that prints "Access granted!" to the console.
- If they are not equal, it falls through to a section that prints "Access denied." to the console.
- After printing, the program exits gracefully.
This is the essence of reverse engineering: understanding the program's intent and behavior from its compiled form.
Quick Check
Consider the following disassembled x86 snippet. Assume 0x402000 holds the string "Yes\n" and 0x402008 holds "No\n".
0x401000: mov eax, 0x5
0x401005: mov ebx, 0x5
0x40100a: cmp eax, ebx
0x40100c: jne 0x401018
0x40100e: mov edi, 0x402000 ; "Yes\n"
0x401013: call 0x401040 <puts@plt>
0x401018: mov edi, 0x402008 ; "No\n"
0x40101d: call 0x401040 <puts@plt>
Lesson Recap
In this lesson, you've learned the fundamental techniques of basic reverse engineering:
- Understanding what RE is and its importance.
- Identifying key tools like disassemblers (
objdump) and debuggers (GDB). - Locating the program's entry point (
_start). - Tracing program flow using conditional jumps (
cmp,je). - Recognizing system calls (
int 0x80) and their parameters. - Extracting meaningful strings and data from the binary.
By applying these techniques, you can begin to reconstruct the logic and behavior of programs even without their original source code!
AI 튜터와 함께 Assembly을(를) 배우세요 — 무료
브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.
- 코스
- 12
- 레슨
- 48
자주 묻는 질문
“기초 리버스 엔지니어링 기법” 강의는 무료인가요?
네 — “기초 리버스 엔지니어링 기법” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Assembly Language & x86 Low-Level Systems Programming 강의 전체를 잠금 해제할 수 있습니다. Assembly Language & x86 Low-Level Systems Programming 강의에는 총 4개의 강의가 포함되어 있습니다.
“기초 리버스 엔지니어링 기법”에서 뭘 배우나요?
디버깅과 디스어셈블리 기술을 활용하여 소스 코드 없이 간단한 바이너리를 분석하고, 함수를 식별하며, 프로그램의 논리를 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 Assembly Language & x86 Low-Level Systems Programming을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Assembly Language & x86 Low-Level Systems Programming을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Assembly Language & x86 Low-Level Systems Programming은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.
“기초 리버스 엔지니어링 기법” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Assembly Language & x86 Low-Level Systems Programming 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Assembly Language & x86 Low-Level Systems Programming 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 어셈블리 디버깅에 GDB 사용
- 디스어셈블리 도구 소개
- 기초 리버스 엔지니어링 기법
- 추적과 후킹을 활용한 동적 분석