Lab use only. All programs analyzed below are intentionally vulnerable CrackMe binaries created for reverse engineering education. Never reverse engineer or patch commercial software without proper authorization.
When you compile a C or C++ program, the human-readable source code disappears. What remains is machine code: raw bytes that the CPU decodes into assembly instructions. For many developers, that binary file feels like an impenetrable black box.
Reverse engineering is the art of opening that box. A CrackMe is an intentionally locked program designed to teach that skill. There are no source files, no symbols, and no documentation. You are given an executable file and a simple goal: find the correct serial key, remove an annoying nag screen, extend an expired trial, or write a key generator.
In this walkthrough, we will analyze five classic x86 Win32 CrackMes from scratch using x32dbg.
Each challenge introduces a core reverse-engineering pattern used in real-world binary analysis.
| # | Challenge | Target Mechanism | Primary Technique |
|---|---|---|---|
| 1 | CrackMe 1 | Hardcoded serial comparison | String references & conditional jump flipping (JNE -> JE) |
| 2 | CrackMe 2 | Keyfile licensing | File I/O analysis & creating valid keyfile.txt |
| 3 | CrackMe 3 | Opening/closing nag screens & registration check | NOP padding (0x90) & branching modification |
| 4 | CrackMe 4 | Expired 30-day trial period | System time arithmetic analysis (GetLocalTime) & value patching |
| 5 | CrackMe 5 | Algorithmic username-to-serial check | Dynamic key analysis (wsprintfA) & writing a Python keygen |
Run it yourself
You can download the exact challenge binaries and follow along step by step on Windows.
| Target | CrackMe 1 to 5 (Win32 Portable Executable) |
| Author | Paul Chin / Cracking Lessons |
| Source | GitHub repository |
| Tool | x64dbg / x32dbg (Open Source x86/x64 Debugger) |
| Archive password | crackinglessons.com |
Setup steps:
- Download the CrackMe zips (
CrackMe1.ziptoCrackMe5.zip) from the GitHub archive and extract them using passwordcrackinglessons.com. - Download and install
x64dbg. We will usex32dbg.exelocated in therelease/x32folder because these samples are 32-bit PE files. - Open
x32dbg, configure basic preferences (Options -> Preferences -> uncheck System Breakpoint if you want to land straight at the Entry Point), and you are ready.
Challenge 1: hardcoded strings and jump flipping
We start with CrackMe1.exe. Running the executable presents a simple dialog with a text input box. Typing a random serial key and clicking Check yields an immediate error:

The error message “Wrong serial key. Try again.” is our anchor. In compiled software, user-facing error text must exist in memory, and looking up where that text is referenced points us directly to the check logic.
Find the reference in x32dbg
Open CrackMe1.exe in x32dbg. In the CPU view, right-click, select Search for -> All User Modules -> String References.
Filter for Wrong serial key:

Double-clicking the line jumps directly to address 00401159 in the disassembler:
00401137 | 85C0 | test eax, eax
00401139 | 75 19 | jne crackme1.401154
0040113B | 68 E81A4100 | push crackme1.411AE8 ; "Congrats!"
00401140 | 68 F41A4100 | push crackme1.411AF4 ; "Well done!"
00401145 | 50 | push eax
00401146 | FF15 18D14000 | call dword ptr [<&MessageBoxA>]
...
00401154 | 68 001B4100 | push crackme1.411B00 ; "Sorry"
00401159 | 68 081B4100 | push crackme1.411B08 ; "Wrong serial key. Try again."
0040115E | 6A 00 | push 0
00401160 | FF15 18D14000 | call dword ptr [<&MessageBoxA>]
Notice the branch at 00401139: jne crackme1.401154. If eax is not zero, the program jumps over the “Well done!” block straight to the error message.
Looking just a few lines above 00401137, we find a string comparison routine comparing our input with address 00411AD8:

At address 00411AD8 sits the hardcoded string: cr4ckingL3ssons.
We have two ways to solve this:
- Enter the valid serial key directly:
cr4ckingL3ssons. - Patch the binary: double-click address
00401139and changejne(75 19) toje(74 19), or changetest eax, eaxtoxor eax, eax.
Save the patched file via File -> Patch file. Running the patched executable with any random text displays the success dialog:

Challenge 2: licensing via keyfiles
CrackMe2.exe introduces another common licensing scheme: keyfiles. When launched without a license file, the application immediately displays an unregistered notice:

The window displays “Unregistered Software. Please crack me.” with no input fields on the interface.
Tracing the File Check in x32dbg
Loading CrackMe2.exe into x32dbg and searching String References reveals an immediate clue: keyfile.txt.

Following the reference to 0040103E exposes the Win32 file handling sequence:
0040103E | 68 281B4100 | push crackme2.411B28 ; "keyfile.txt"
00401043 | FF15 00D04000 | call dword ptr [<&CreateFileA>]
00401049 | 8BF0 | mov esi, eax ; Store returned handle
0040104B | 83FE FF | cmp esi, -1 ; Compare against INVALID_HANDLE_VALUE (-1)
0040104E | 74 51 | je crackme2.4010A1 ; If not found, jump to unregistered branch
00401050 | 6A 00 | push 0
00401052 | 68 04434100 | push crackme2.414304
00401057 | 6A 1F | push 1F ; nNumberOfBytesToRead = 31 bytes
00401059 | 68 E4424100 | push crackme2.4142E4 ; Output buffer
0040105E | 56 | push esi ; File handle
0040105F | FF15 08D04000 | call dword ptr [<&ReadFile>]
...
0040109B | FF15 04D04000 | call dword ptr [<&CloseHandle>]
The validation operates in three stages:
CreateFileAattempts to openkeyfile.txtin the executable’s directory withOPEN_EXISTING.- If the file is missing, it returns
-1(INVALID_HANDLE_VALUE) andje crackme2.4010A1branches to the unregistered dialog. - If present,
ReadFilereads up to 31 bytes into004142E4, closes the handle, and appends the content afterRegistered to:. No signature check or encryption is applied.
Creating a Valid Keyfile
We create a plain text file named keyfile.txt in the same directory as CrackMe2.exe. Inside Notepad, enter the desired username:

Save it with standard ANSI encoding. Relaunching CrackMe2.exe:

The status text in the dialog updates immediately to Registered to: khanh1916. Challenge solved without modifying binary code.
Challenge 3: eliminating nag screens and NOP patching
CrackMe3.exe demonstrates annoying pop-up screens (nag screens) on launch and exit, along with an About dialog marking the software as unregistered. The challenge has three distinct objectives:
- Remove the opening nag screen (“Opening Nag”).
- Remove the closing nag screen (“Closing Nag”).
- Make the About dialog display “REGISTERED” instead of “Unregistered”.

Objective 1: Bypassing the Opening Nag
Searching for “Opening Nag” in x32dbg leads to address 0040102D:

0040101D | 833D A0424100 00 | cmp dword ptr [4142A0], 0
00401024 | A3 A4424100 | mov dword ptr [4142A4], eax
00401029 | 75 19 | jne crackme3.401044
0040102B | 6A 00 | push 0
0040102D | 68 D81A4100 | push crackme3.411AD8 ; "Opening Nag"
00401032 | 68 E41A4100 | push crackme3.411AE4 ; "I am a nag screen"
00401037 | 6A 00 | push 0
00401039 | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
0040103F | A1 A4424100 | mov eax, dword ptr [4142A4]
00401044 | 56 | push esi
At 00401029, jne crackme3.401044 skips the MessageBoxA call when the condition is met. Inverting this jump from jne to je (74 19) ensures the opening nag screen is always skipped on startup.
Objective 2: Neutralizing the Closing Nag with NOPs
Searching for “Closing Nag” lands in the exit procedure around 0040110D. Unlike the opening nag, there is no conditional branch guarding the popup:
0040110D | 6A 00 | push 0
0040110F | 68 501B4100 | push crackme3.411B50 ; "Closing Nag"
00401114 | 68 E41A4100 | push crackme3.411AE4 ; "I am a nag screen\nPlease remove me."
00401119 | 6A 00 | push 0
0040111B | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
Without a branch to flip, we use NOP padding (0x90 - No Operation). Selecting the instruction range from 00401107 to 00401120 (filled with 90), right-click and choose Fill with NOPs:

The CPU slides through these NOP instructions without executing any popup.
Objective 3: Flipping the About Dialog
In the About box handler:
004010D8 | 74 12 | je crackme3.4010EC ; jumps to push "Unregistered"
004010DA | 68 101B4100 | push crackme3.411B10 ; "Status:\n\nREGISTERED"
004010DF | 50 | push eax
004010E0 | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
...
004010EC | 68 241B4100 | push crackme3.411B24 ; "Status:\n\nUnregistered\n\nPlease register me"
004010F1 | 6A 00 | push 0
004010F3 | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
Address 004010D8 contains je 004010EC (74 12). Changing je to jne (75 12) redirects execution directly into the REGISTERED string block.
Save the patched file: both nag popups are gone, and the About box displays REGISTERED:

Challenge 4: extending trial periods and basic arithmetic
Many commercial applications enforce a 30-day trial period. CrackMe4.exe simulates this mechanism. Upon execution, a window appears warning how many days remain in our trial:

Analyzing System Time Logic
Searching for string %d days trial period remaining takes us to address 00401056:
00401036 | 0FB705 EE424100 | movzx eax, word ptr [4142EE] ; Day of month
0040103D | B9 1E000000 | mov ecx, 1E ; ECX = 30 (0x1E)
00401042 | 2BC8 | sub ecx, eax ; ECX = 30 - current_day
00401044 | 890D A0424100 | mov dword ptr [4142A0], ecx ; Store remaining days
0040104A | 85C9 | test ecx, ecx
0040104C | 7F 07 | jg crackme4.401055
0040104E | 68 E81A4100 | push crackme4.411AE8 ; "Trial Period has expired"
00401053 | EB 19 | jmp crackme4.40106E
00401055 | 51 | push ecx ; Number of days
00401056 | 68 041B4100 | push crackme4.411B04 ; "%d days trial period remaining"
Look closely at lines 00401036 to 00401042:
- The program calls
GetLocalTime, passing the address of aSYSTEMTIMEstructure at004142E8. - Offset
+0x6(004142EE) iswDay(the day of the month).movzx eax, word ptr [4142EE]loads this number intoeax. mov ecx, 1Eloads hexadecimal1E(decimal30) into registerecx.sub ecx, eaxsubtracts the current day of the month from 30!- If today is the 3rd,
30 - 3 = 27 days remaining. Ifecx <= 0, it jumps to “Trial Period has expired”.

Patching the Trial Duration
To extend the trial period, we simply increase the baseline limit at address 0040103D:
mov ecx, 1E ; 30 days
to:
mov ecx, 32 ; 50 in decimal
With ecx set to 0x32 (50), 50 - 3 = 47 days remaining. Patching the file and restarting produces:

Trial extended. A single byte change (1E -> 32) altered the application’s business logic entirely.
Challenge 5: dynamic serial algorithms and writing a Keygen
CrackMe5.exe elevates the game: the serial key is no longer hardcoded in plaintext. Instead, it is dynamically computed at runtime based on our input username and the current system date.
Entering a test username (khanh) and arbitrary serial key triggers the rejection message:

Tracing the Generator Algorithm
Searching for string references, we find a format string at 00411AE8:
"%s-%d%d%d"
Let’s inspect the code pushing parameters into this format string around 00401146:
00401146 | 0FB705 A6424100 | movzx eax, word ptr [4142A6] ; wDay (e.g. 10)
0040114D | 50 | push eax
0040114E | 0FB705 A2424100 | movzx eax, word ptr [4142A2] ; wMonth (e.g. 6)
00401155 | 50 | push eax
00401156 | 0FB705 A0424100 | movzx eax, word ptr [4142A0] ; wYear (e.g. 2025)
0040115D | 05 D2040000 | add eax, 4D2 ; eax = wYear + 0x4D2 (1234)
00401162 | 50 | push eax
00401163 | 8D45 D0 | lea eax, [ebp-30] ; Username pointer ("khanh")
00401166 | 50 | push eax
00401167 | 8D45 90 | lea eax, [ebp-70] ; Destination buffer
0040116A | 68 E81A4100 | push crackme5.411AE8 ; "%s-%d%d%d"
0040116F | 50 | push eax
00401170 | FF15 0CD14000 | call dword ptr [<&wsprintfA>]

The assembly reveals the exact formula:
- It calls
GetLocalTimeto extract the system date components: Year (wYear), Month (wMonth), and Day (wDay). - It takes
wYearand adds hexadecimal0x4D2(which equals decimal1234).- For year 2025:
2025 + 1234 = 3259. - For year 2026:
2026 + 1234 = 3260.
- For year 2025:
- It calls
wsprintfAwith format string"%s-%d%d%d":- First argument
%s: your input username. - Second argument
%d:wYear + 1234. - Third argument
%d:wMonth. - Fourth argument
%d:wDay.
- First argument
If username is khanh, date is June 10th, 2025:
- Serial:
khanh-3259610.
If date is September 5th, 2025:
- Serial:
khanh-325995.
Writing a Python Keygen
Instead of patching the binary, we write a standalone Python script to generate valid keys for any name on any given day:
import datetime
def generate_key(username: str, date: datetime.date = None) -> str:
if date is None:
date = datetime.date.today()
transformed_year = date.year + 1234
return f"{username}-{transformed_year}{date.month}{date.day}"
if __name__ == "__main__":
name = "khanh"
key = generate_key(name)
print(f"Generated Serial for '{name}': {key}")
Entering the generated key into CrackMe5.exe yields immediate success:

Defense: how to protect software against binary reversing
These five challenges illustrate the fundamental vulnerabilities of naive client-side software protections. Every weakness here has an established defensive remedy:
| Vulnerability in CrackMe | How It Was Exploited | How Developers Should Fix It |
|---|---|---|
| Plaintext hardcoded strings | String reference search in debugger | Encrypt strings at compile time or use stack strings; resolve strings dynamically at runtime. |
| Single conditional jump checks | Flipped JNE to JE with 1 byte edit |
Perform integrity checks on executable sections (.text checksum / digital signatures); verify authorization server-side. |
| In-memory popup execution | Filled MessageBoxA call with NOPs |
Avoid client-only enforcement; tie core operational logic to cryptographic tokens rather than visual popups. |
| Predictable local clock reads | Modified mov ecx, 1E calculation |
Fetch tamper-proof time stamps from a secure remote NTP server or digital license server. |
| Reversible keygen formula | Derived arithmetic in wsprintfA |
Use asymmetric cryptography (RSA / Ed25519) for offline licensing: software verifies signature with public key; only developer holds private key. |
Practice files archive: github.com/tiendungdo12/crackmes-crackinglessons.com
Analysis tool: x64dbg / x32dbg
Mọi file nhị phân bên dưới là các bài tập CrackMe mẫu dùng cho mục đích học tập dịch ngược mã. Đừng bao giờ áp dụng kỹ thuật bẻ khóa này lên các phần mềm thương mại có bản quyền.
Khi bạn biên dịch một chương trình C hay C++, mã nguồn dễ đọc sẽ biến mất. Thứ còn lại
chỉ là mã máy: các byte dữ liệu thô mà CPU dịch thành các lệnh hợp ngữ (Assembly). Với nhiều
lập trình viên, file nhị phân .exe đó giống như một chiếc hộp đen bất khả xâm phạm.
Dịch ngược mã (Reverse Engineering) là kỹ thuật mở chiếc hộp đen đó. Một file CrackMe là
một chương trình được cố tình khóa lại nhằm mục đích luyện tập. Bạn không có mã nguồn, không
có file symbol (.pdb), và không có tài liệu hướng dẫn. Trong tay chỉ có một file thực thi
và một mục tiêu cụ thể: tìm đúng serial key, gỡ bỏ màn hình nag screen khó chịu, gia hạn
bản dùng thử đã hết hạn, hoặc viết ra một trình sinh key tự động (Keygen).
Ta sẽ mổ xẻ năm bài CrackMe kinh điển dạng Win32 x86 bằng công cụ
x32dbg. Mỗi bài đại diện cho một kỹ thuật dịch ngược cốt lõi thường gặp trong phân tích mã độc
và bảo mật phần mềm.
| # | Thử thách | Cơ chế mục tiêu | Kỹ thuật giải quyết |
|---|---|---|---|
| 1 | CrackMe 1 | So sánh chuỗi kiểm tra cố định | Tìm string reference & đảo cờ nhảy điều kiện (JNE -> JE) |
| 2 | CrackMe 2 | Bản quyền qua file giấy phép (Keyfile) | Phân tích API đọc file & tạo file keyfile.txt hợp lệ |
| 3 | CrackMe 3 | Màn hình nhắc nhở (Nag screens) & trạng thái đăng ký | Lấp lệnh bằng NOP (0x90) & đổi nhánh gọi chuỗi |
| 4 | CrackMe 4 | Hạn dùng thử 30 ngày (Trial period) | Phân tích phép toán thời gian (GetLocalTime) & sửa trực tiếp giá trị |
| 5 | CrackMe 5 | Thuật toán sinh serial theo tên người dùng | Dịch ngược hàm định dạng (wsprintfA) & viết Keygen bằng Python |
Môi trường thực hành
Bạn có thể tải đúng bộ mẫu CrackMe này về và tự thực hành từng bước trên Windows.
| Mục tiêu | CrackMe 1 đến 5 (Win32 Portable Executable) |
| Tác giả | Paul Chin / Cracking Lessons |
| Nguồn file | Kho lưu trữ GitHub |
| Công cụ | x64dbg / x32dbg (Trình debugger x86 mã nguồn mở) |
| Mật khẩu giải nén | crackinglessons.com |
Các bước chuẩn bị:
- Tải các file zip (
CrackMe1.zipđếnCrackMe5.zip) từ kho GitHub và giải nén bằng mật khẩucrackinglessons.com. - Tải và cài đặt
x64dbg. Ta sẽ dùng filex32dbg.exenằm trong thư mụcrelease/x32vì các mẫu CrackMe này đều là ứng dụng 32-bit. - Khởi chạy
x32dbg, cấu hình cơ bản (Options -> Preferences -> bỏ chọn System Breakpoint nếu muốn dừng thẳng ở Entry Point của chương trình).
Challenge 1: tìm chuỗi cố định và đảo cờ lệnh nhảy
Ta bắt đầu với CrackMe1.exe. Chạy file, chương trình hiện ra một hộp thoại đơn giản với một ô nhập serial. Nhập thử một chuỗi bất kỳ rồi bấm Check, chương trình lập tức báo lỗi:

Thông báo lỗi “Wrong serial key. Try again.” chính là manh mối. Trong phần mềm đã biên dịch, chuỗi thông báo hiển thị cho người dùng bắt buộc phải nằm trong bộ nhớ. Lần ra vị trí đoạn text đó được gọi trong mã Assembly sẽ đưa ta đến đúng khối lệnh kiểm tra bản quyền.
Tìm vết chuỗi trong x32dbg
Kéo file CrackMe1.exe vào x32dbg. Tại màn hình CPU, click chuột phải, chọn Search for -> All User Modules -> String References.
Gõ lọc từ khóa Wrong serial key:

Double-click vào dòng tìm được, debugger sẽ nhảy thẳng đến địa chỉ 00401159:
00401137 | 85C0 | test eax, eax
00401139 | 75 19 | jne crackme1.401154
0040113B | 68 E81A4100 | push crackme1.411AE8 ; "Congrats!"
00401140 | 68 F41A4100 | push crackme1.411AF4 ; "Well done!"
00401145 | 50 | push eax
00401146 | FF15 18D14000 | call dword ptr [<&MessageBoxA>]
...
00401154 | 68 001B4100 | push crackme1.411B00 ; "Sorry"
00401159 | 68 081B4100 | push crackme1.411B08 ; "Wrong serial key. Try again."
0040115E | 6A 00 | push 0
00401160 | FF15 18D14000 | call dword ptr [<&MessageBoxA>]
Để ý lệnh rẽ nhánh tại 00401139: jne crackme1.401154. Nếu kết quả kiểm tra eax khác 0, chương trình sẽ nhảy cóc qua khối “Well done!” để lao thẳng xuống thông báo lỗi.
Cuộn ngược lên vài dòng trước 00401137, ta thấy đoạn so sánh chuỗi nhập vào với vùng nhớ tại 00411AD8:

Tại địa chỉ 00411AD8 chứa sẵn chuỗi cố định: cr4ckingL3ssons.
Đến đây ta có hai cách vượt qua:
- Nhập key hợp lệ: điền thẳng
cr4ckingL3ssonsvào ô nhập. - Patch file nhị phân: double-click vào dòng
00401139, sửa lệnhjne(75 19) thànhje(74 19), hoặc sửatest eax, eaxthànhxor eax, eax.
Lưu file đã vá qua menu File -> Patch file. Chạy thử file đã patch với một key bất kỳ, chương trình lập tức hiện thông báo thành công:

Challenge 2: bản quyền qua file giấy phép (Keyfile)
CrackMe2.exe đưa ra một mô hình cấp phép quen thuộc khác: sử dụng file bản quyền riêng biệt (keyfile). Khi khởi chạy ứng dụng mà chưa có file giấy phép, cửa sổ hiển thị thông báo chưa đăng ký:

Hộp thoại ghi rõ “Unregistered Software. Please crack me.” và hoàn toàn không có ô nhập serial key nào trên giao diện.
Phân tích hàm kiểm tra file trong x32dbg
Nạp CrackMe2.exe vào x32dbg, nhấn F9 để chạy qua breakpoint hệ thống đến mã nguồn chính của chương trình. Tìm kiếm chuỗi (String References), ta thấy ngay một tên file đáng ngờ: keyfile.txt.

Đi tới địa chỉ gọi chuỗi tại 0040103E, ta thấy rõ quy trình gọi các Win32 API xử lý file:
0040103E | 68 281B4100 | push crackme2.411B28 ; "keyfile.txt"
00401043 | FF15 00D04000 | call dword ptr [<&CreateFileA>]
00401049 | 8BF0 | mov esi, eax ; Lưu handle trả về
0040104B | 83FE FF | cmp esi, -1 ; So sánh với INVALID_HANDLE_VALUE (-1)
0040104E | 74 51 | je crackme2.4010A1 ; Không tìm thấy file -> nhảy sang nhánh Unregistered
00401050 | 6A 00 | push 0
00401052 | 68 04434100 | push crackme2.414304
00401057 | 6A 1F | push 1F ; nNumberOfBytesToRead = 31 bytes
00401059 | 68 E4424100 | push crackme2.4142E4 ; Bộ đệm lưu nội dung đọc được
0040105E | 56 | push esi ; Handle của file
0040105F | FF15 08D04000 | call dword ptr [<&ReadFile>]
...
0040109B | FF15 04D04000 | call dword ptr [<&CloseHandle>]
Quy trình kiểm tra diễn ra theo ba bước:
CreateFileAcố gắng mở filekeyfile.txtngay trong thư mục chứa chương trình.- Nếu file không tồn tại, hàm trả về
-1(INVALID_HANDLE_VALUE), cờ nhảyje crackme2.4010A1kích hoạt đưa luồng thực thi xuống nhánh “Unregistered Software”. - Nếu file tồn tại,
ReadFileđọc tối đa 31 byte nội dung vào bộ đệm tại004142E4, sau đó đóng file bằngCloseHandlevà hiển thị chuỗi đọc được sau tiền tốRegistered to:. Chương trình không hề có thuật toán mã hóa hay kiểm tra chữ ký của file.
Tạo file keyfile.txt hợp lệ
Biết được quy luật, ta chỉ cần tạo một file văn bản tên keyfile.txt nằm cùng thư mục với CrackMe2.exe. Mở Notepad, nhập tên người dùng mong muốn:

Lưu file với định dạng ANSI chuẩn. Khởi chạy lại CrackMe2.exe:

Dòng trạng thái trong hộp thoại lập tức đổi thành Registered to: khanh1916. Thử thách được giải quyết hoàn toàn mà không cần sửa bất kỳ byte nào trong file thực thi.
Challenge 3: gỡ bỏ nag screen và vá lệnh bằng NOP
CrackMe3.exe mô phỏng dạng phần mềm thường xuyên hiển thị các cửa sổ làm phiền (nag screen) lúc mở và lúc tắt ứng dụng, đồng thời ô About chỉ ghi trạng thái chưa đăng ký. Thử thách đặt ra ba mục tiêu cần xử lý:
- Gỡ màn hình nag lúc mở phần mềm (“Opening Nag”).
- Gỡ màn hình nag lúc tắt phần mềm (“Closing Nag”).
- Chuyển trạng thái trong hộp About từ “Unregistered” sang “REGISTERED”.

Mục tiêu 1: Bỏ qua Opening Nag
Mở CrackMe3.exe trong x32dbg, quét String references và tìm chuỗi “Opening Nag”:

Double-click để nhảy tới địa chỉ 0040102D:
0040101D | 833D A0424100 00 | cmp dword ptr [4142A0], 0
00401024 | A3 A4424100 | mov dword ptr [4142A4], eax
00401029 | 75 19 | jne crackme3.401044
0040102B | 6A 00 | push 0
0040102D | 68 D81A4100 | push crackme3.411AD8 ; "Opening Nag"
00401032 | 68 E41A4100 | push crackme3.411AE4 ; "I am a nag screen"
00401037 | 6A 00 | push 0
00401039 | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
0040103F | A1 A4424100 | mov eax, dword ptr [4142A4]
00401044 | 56 | push esi
Tại dòng 00401029, lệnh jne crackme3.401044 nhảy cóc qua lệnh gọi MessageBoxA nếu thỏa mãn điều kiện. Ta đảo lệnh này bằng cách sửa jne thành je (74 19). Khi khởi động, chương trình sẽ luôn nhảy qua hộp thoại nag đầu tiên.
Mục tiêu 2: Triệt tiêu Closing Nag bằng NOP
Tìm kiếm chuỗi “Closing Nag” sẽ dẫn ta tới hàm xử lý đóng chương trình quanh địa chỉ 0040110D. Khác với lúc khởi động, tại đây không có bất kỳ lệnh nhảy điều kiện nào để rẽ nhánh; lệnh gọi MessageBoxA được thực thi trực tiếp:
0040110D | 6A 00 | push 0
0040110F | 68 501B4100 | push crackme3.411B50 ; "Closing Nag"
00401114 | 68 E41A4100 | push crackme3.411AE4 ; "I am a nag screen\nPlease remove me."
00401119 | 6A 00 | push 0
0040111B | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
Khi không có cờ nhảy để đảo, ta dùng kỹ thuật lấp lệnh bằng NOP (0x90 - No Operation). Ta bôi đen dải lệnh từ 00401107 đến 00401120, click chuột phải, chọn Fill with NOPs:

Khi gặp các byte NOP này, CPU chỉ lướt qua mà không thực thi bất kỳ thao tác nào, nhờ đó hộp thoại thông báo khi tắt ứng dụng hoàn toàn bị vô hiệu hóa.
Mục tiêu 3: Đổi trạng thái trong About
Trong hàm xử lý hộp thoại About:
004010D8 | 74 12 | je crackme3.4010EC ; nhảy xuống chuỗi "Unregistered"
004010DA | 68 101B4100 | push crackme3.411B10 ; "Status:\n\nREGISTERED"
004010DF | 50 | push eax
004010E0 | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
...
004010EC | 68 241B4100 | push crackme3.411B24 ; "Status:\n\nUnregistered\n\nPlease register me"
004010F1 | 6A 00 | push 0
004010F3 | FF15 14D14000 | call dword ptr [<&MessageBoxA>]
Tại 004010D8, câu lệnh đang là je 004010EC (74 12). Ta đảo lệnh je thành jne (75 12), ép luồng thực thi không nhảy sang nhánh Unregistered mà đi thẳng vào khối nạp chuỗi REGISTERED.
Lưu file đã vá và mở lại: cả hai màn hình nag biến mất hoàn toàn, mục About hiển thị trạng thái REGISTERED:

Challenge 4: nới hạn dùng thử qua phân tích phép toán
Rất nhiều phần mềm thương mại áp dụng chính sách dùng thử 30 ngày. CrackMe4.exe tạo dựng lại đúng cơ chế này. Khi mở app, một hộp thoại cảnh báo số ngày dùng thử còn lại:

Phân tích logic đồng hồ hệ thống
Tìm chuỗi %d days trial period remaining dẫn ta đến địa chỉ 00401056:
00401036 | 0FB705 EE424100 | movzx eax, word ptr [4142EE] ; Lấy ngày trong tháng
0040103D | B9 1E000000 | mov ecx, 1E ; ECX = 30 (0x1E)
00401042 | 2BC8 | sub ecx, eax ; ECX = 30 - ngày_hiện_tại
00401044 | 890D A0424100 | mov dword ptr [4142A0], ecx ; Lưu số ngày còn lại
0040104A | 85C9 | test ecx, ecx
0040104C | 7F 07 | jg crackme4.401055
0040104E | 68 E81A4100 | push crackme4.411AE8 ; "Trial Period has expired"
00401053 | EB 19 | jmp crackme4.40106E
00401055 | 51 | push ecx ; Đẩy số ngày vào tham số
00401056 | 68 041B4100 | push crackme4.411B04 ; "%d days trial period remaining"
Nhìn kỹ đoạn lệnh từ 00401036 đến 00401042:
- Chương trình gọi hàm
GetLocalTime, truyền vào địa chỉ cấu trúc thời gianSYSTEMTIMEtại004142E8. - Offset
+0x6(004142EE) chính là trườngwDay(ngày trong tháng). Lệnhmovzx eax, word ptr [4142EE]nạp con số ngày này vào thanh ghieax. - Lệnh
mov ecx, 1Egán giá trị hex1E(tức 30 trong hệ thập phân) vàoecx. - Lệnh
sub ecx, eaxlấy 30 trừ đi ngày hiện tại. - Nếu hôm nay là ngày 3, thì
30 - 3 = 27 ngày còn lại. Nếuecx <= 0, chương trình nhảy sang báo “Trial Period has expired”.

Vá mốc thời gian dùng thử
Muốn nới hạn dùng thử, ta không cần tắt đoạn so sánh, mà chỉ cần tăng mốc giới hạn ban đầu.
Tại địa chỉ 0040103D, ta sửa:
mov ecx, 1E ; 30 ngày
thành:
mov ecx, 32 ; 50 ngày (trong hệ thập phân)
Với ecx đặt thành 0x32 (50), lấy 50 - 3 = 47 ngày còn lại. Lưu file patch và mở lại:

Hạn dùng thử đã được kéo dài. Chỉ một byte duy nhất (1E thành 32) đã làm thay đổi hoàn toàn logic nghiệp vụ của ứng dụng.
Challenge 5: giải mã thuật toán sinh serial và viết Keygen
CrackMe5.exe nâng độ khó lên một mức mới: serial key không còn nằm sẵn dưới dạng văn bản tĩnh trong file, mà được tính toán động ngay lúc chạy dựa trên tên người dùng nhập vào kết hợp với ngày tháng của hệ thống.
Khởi chạy ứng dụng, nhập thử tên (khanh) và một serial ngẫu nhiên, chương trình lập tức từ chối và báo lỗi:

Bóc tách thuật toán sinh mã
Quét danh sách String references, ta bắt gặp chuỗi định dạng tại 00411AE8:
"%s-%d%d%d"
Xem đoạn code đẩy tham số vào định dạng này quanh địa chỉ 00401146:
00401146 | 0FB705 A6424100 | movzx eax, word ptr [4142A6] ; wDay (ví dụ ngày 10)
0040114D | 50 | push eax
0040114E | 0FB705 A2424100 | movzx eax, word ptr [4142A2] ; wMonth (ví dụ tháng 6)
00401155 | 50 | push eax
00401156 | 0FB705 A0424100 | movzx eax, word ptr [4142A0] ; wYear (ví dụ năm 2025)
0040115D | 05 D2040000 | add eax, 4D2 ; eax = wYear + 0x4D2 (1234)
00401162 | 50 | push eax
00401163 | 8D45 D0 | lea eax, [ebp-30] ; Con trỏ chuỗi Username ("khanh")
00401166 | 50 | push eax
00401167 | 8D45 90 | lea eax, [ebp-70] ; Bộ đệm lưu kết quả
0040116A | 68 E81A4100 | push crackme5.411AE8 ; "%s-%d%d%d"
0040116F | 50 | push eax
00401170 | FF15 0CD14000 | call dword ptr [<&wsprintfA>]

Đoạn mã hợp ngữ cho thấy rõ công thức tính toán:
- Gọi
GetLocalTimelấy các thành phần ngày tháng: Năm (wYear), Tháng (wMonth), và Ngày (wDay). - Lấy
wYearcộng thêm giá trị hex0x4D2(tương đương 1234 trong hệ thập phân).- Với năm 2025:
2025 + 1234 = 3259. - Với năm 2026:
2026 + 1234 = 3260.
- Với năm 2025:
- Gọi hàm
wsprintfAvới mẫu"%s-%d%d%d":- Tham số
%sđầu tiên: chuỗi Username bạn gõ vào. - Tham số
%dthứ hai:wYear + 1234. - Tham số
%dthứ ba:wMonth. - Tham số
%dthứ tư:wDay.
- Tham số
Nếu Username là khanh, ngày chạy là 10/06/2025:
- Serial hợp lệ là:
khanh-3259610.
Nếu ngày chạy là 05/09/2025:
- Serial hợp lệ là:
khanh-325995.
Tự viết trình sinh key (Keygen bằng Python)
Thay vì vá mã nhị phân, ta viết một script Python ngắn để tự tạo serial chuẩn cho bất kỳ ai vào bất kỳ ngày nào:
import datetime
def generate_key(username: str, date: datetime.date = None) -> str:
if date is None:
date = datetime.date.today()
transformed_year = date.year + 1234
return f"{username}-{transformed_year}{date.month}{date.day}"
if __name__ == "__main__":
name = "khanh"
key = generate_key(name)
print(f"Serial hợp lệ cho '{name}': {key}")
Nhập key vừa sinh vào CrackMe5.exe, hộp thoại báo thành công hiện lên ngay lập tức:

Remediation
Cả năm thử thách trên cho thấy các điểm yếu cố hữu khi đặt toàn bộ cơ chế bảo vệ ở phía client (máy người dùng). Mỗi điểm yếu đều có biện pháp khắc phục chuẩn mực từ góc nhìn của lập trình viên:
| Điểm yếu trong CrackMe | Cách thức bị khai thác | Cách khắc phục chuẩn mực |
|---|---|---|
| Chuỗi cố định để lộ dạng text | Tìm string reference trong debugger | Mã hóa chuỗi nhạy cảm khi biên dịch hoặc dùng stack string; giải mã động trong runtime. |
| Chỉ kiểm tra qua một lệnh nhảy đơn | Đảo JNE thành JE chỉ với 1 byte |
Kiểm tra tính toàn vẹn của phân vùng code (.text hash checksum / chữ ký số); xác thực bản quyền qua server. |
| Nag screen chạy cục bộ | Lấp lệnh gọi MessageBoxA bằng NOP |
Không phụ thuộc vào giao diện hiển thị; gắn logic nghiệp vụ cốt lõi với khóa giải mã thay vì hiển thị popup. |
| Lấy giờ từ đồng hồ máy tính cá nhân | Sửa phép toán mov ecx, 1E |
Đồng bộ thời gian qua server NTP có chứng thực hoặc kiểm tra token từ license server. |
| Thuật toán sinh key đối xứng dễ đoán | Dịch ngược phép cộng trong wsprintfA |
Áp dụng mật mã bất đối xứng (RSA / Ed25519): phần mềm chỉ lưu public key để xác thực chữ ký của license; private key nằm an toàn ở server nhà phát triển. |
File mẫu thực hành: github.com/tiendungdo12/crackmes-crackinglessons.com
Công cụ phân tích: x64dbg / x32dbg