| Foreword |
|
vii | |
| Acknowledgments |
|
xi | |
| Introduction |
|
xxiii | |
|
|
|
1 | (138) |
|
|
|
3 | (22) |
|
What Is Reverse Engineering? |
|
|
3 | (1) |
|
Software Reverse Engineering: Reversing |
|
|
4 | (1) |
|
|
|
4 | (5) |
|
Security-Related Reversing |
|
|
5 | (1) |
|
|
|
5 | (1) |
|
Reversing Cryptographic Algorithms |
|
|
6 | (1) |
|
Digital Rights Management |
|
|
7 | (1) |
|
Auditing Program Binaries |
|
|
7 | (1) |
|
Reversing in Software Development |
|
|
8 | (1) |
|
Achieving Interoperability with Proprietary Software |
|
|
8 | (1) |
|
Developing Competing Software |
|
|
8 | (1) |
|
Evaluating Software Quality and Robustness |
|
|
9 | (1) |
|
|
|
9 | (4) |
|
|
|
10 | (1) |
|
|
|
11 | (1) |
|
Virtual Machines and Bytecodes |
|
|
12 | (1) |
|
|
|
13 | (1) |
|
|
|
13 | (1) |
|
|
|
14 | (1) |
|
|
|
14 | (1) |
|
|
|
14 | (3) |
|
|
|
15 | (1) |
|
|
|
15 | (1) |
|
|
|
15 | (1) |
|
|
|
16 | (1) |
|
|
|
17 | (6) |
|
|
|
17 | (1) |
|
|
|
18 | (1) |
|
|
|
19 | (1) |
|
Trade Secrets and Patents |
|
|
20 | (1) |
|
The Digital Millenium Copyright Act |
|
|
20 | (2) |
|
|
|
22 | (1) |
|
License Agreement Considerations |
|
|
23 | (1) |
|
|
|
23 | (1) |
|
|
|
23 | (2) |
|
|
|
25 | (44) |
|
|
|
26 | (11) |
|
|
|
26 | (2) |
|
|
|
28 | (1) |
|
|
|
28 | (1) |
|
|
|
29 | (1) |
|
|
|
30 | (1) |
|
User-Defined Data Structures |
|
|
30 | (1) |
|
|
|
31 | (1) |
|
|
|
32 | (1) |
|
|
|
33 | (1) |
|
|
|
34 | (1) |
|
|
|
35 | (1) |
|
|
|
36 | (1) |
|
|
|
36 | (1) |
|
|
|
37 | (7) |
|
Low-Level Data Management |
|
|
37 | (2) |
|
|
|
39 | (1) |
|
|
|
40 | (2) |
|
|
|
42 | (1) |
|
|
|
43 | (1) |
|
|
|
43 | (1) |
|
|
|
44 | (9) |
|
|
|
44 | (2) |
|
|
|
46 | (1) |
|
|
|
47 | (1) |
|
|
|
48 | (1) |
|
|
|
49 | (1) |
|
|
|
49 | (1) |
|
|
|
50 | (1) |
|
|
|
51 | (1) |
|
|
|
51 | (1) |
|
|
|
52 | (1) |
|
A Primer on Compilers and Compilation |
|
|
53 | (7) |
|
|
|
54 | (1) |
|
|
|
55 | (1) |
|
|
|
55 | (1) |
|
Intermediate Representations |
|
|
55 | (1) |
|
|
|
56 | (1) |
|
|
|
57 | (1) |
|
|
|
58 | (1) |
|
|
|
59 | (1) |
|
|
|
60 | (8) |
|
Software Execution Environments (Virtual Machines) |
|
|
60 | (1) |
|
|
|
61 | (1) |
|
|
|
61 | (1) |
|
|
|
62 | (1) |
|
|
|
62 | (1) |
|
Hardware Execution Environments in Modern Processors |
|
|
63 | (2) |
|
|
|
65 | (1) |
|
|
|
65 | (1) |
|
|
|
65 | (2) |
|
|
|
67 | (1) |
|
|
|
68 | (1) |
|
|
|
69 | (40) |
|
Components and Basic Architecture |
|
|
70 | (1) |
|
|
|
70 | (1) |
|
|
|
70 | (1) |
|
|
|
71 | (1) |
|
|
|
71 | (9) |
|
Virtual Memory and Paging |
|
|
72 | (1) |
|
|
|
73 | (1) |
|
|
|
73 | (1) |
|
|
|
74 | (1) |
|
Kernel Memory and User Memory |
|
|
74 | (1) |
|
|
|
75 | (2) |
|
|
|
77 | (1) |
|
|
|
78 | (1) |
|
|
|
78 | (1) |
|
|
|
79 | (1) |
|
|
|
80 | (3) |
|
|
|
81 | (2) |
|
|
|
83 | (5) |
|
|
|
84 | (1) |
|
|
|
84 | (1) |
|
|
|
85 | (1) |
|
|
|
86 | (1) |
|
Process Initialization Sequence |
|
|
87 | (1) |
|
Application Programming Interfaces |
|
|
88 | (5) |
|
|
|
88 | (2) |
|
|
|
90 | (1) |
|
|
|
91 | (2) |
|
|
|
93 | (10) |
|
|
|
93 | (2) |
|
|
|
95 | (1) |
|
|
|
95 | (1) |
|
Dynamically Linked Libraries |
|
|
96 | (1) |
|
|
|
97 | (2) |
|
|
|
99 | (1) |
|
|
|
99 | (4) |
|
|
|
103 | (2) |
|
|
|
103 | (1) |
|
|
|
104 | (1) |
|
|
|
105 | (1) |
|
Structured Exception Handling |
|
|
105 | (2) |
|
|
|
107 | (2) |
|
|
|
109 | (30) |
|
Different Reversing Approaches |
|
|
110 | (1) |
|
Offline Code Analysis (Dead-Listing) |
|
|
110 | (1) |
|
|
|
110 | (1) |
|
|
|
110 | (6) |
|
|
|
112 | (3) |
|
|
|
115 | (1) |
|
|
|
116 | (13) |
|
|
|
118 | (1) |
|
|
|
118 | (1) |
|
|
|
119 | (2) |
|
|
|
121 | (1) |
|
PEBrowse Professional Interactive |
|
|
122 | (1) |
|
|
|
122 | (1) |
|
Kernel Debugging in WinDbg |
|
|
123 | (1) |
|
|
|
124 | (3) |
|
Kernel Debugging on Virtual Machines |
|
|
127 | (2) |
|
|
|
129 | (1) |
|
|
|
129 | (2) |
|
|
|
131 | (2) |
|
|
|
131 | (2) |
|
Miscellaneous Reversing Tools |
|
|
133 | (5) |
|
|
|
133 | (1) |
|
|
|
133 | (4) |
|
|
|
137 | (1) |
|
|
|
137 | (1) |
|
|
|
138 | (1) |
|
Part II Applied Reversing |
|
|
139 | (168) |
|
|
|
141 | (58) |
|
Reversing and Interoperability |
|
|
142 | (1) |
|
|
|
142 | (1) |
|
Locating Undocumented APIs |
|
|
143 | (2) |
|
|
|
144 | (1) |
|
Case Study: The Generic Table API in NTDLL.DLL |
|
|
145 | (51) |
|
RtlInitializeGenericTable |
|
|
146 | (5) |
|
RtlNumberGenericTableElements |
|
|
151 | (1) |
|
|
|
152 | (1) |
|
RtlGetElementGenericTable |
|
|
153 | (2) |
|
|
|
155 | (4) |
|
|
|
159 | (2) |
|
|
|
161 | (2) |
|
|
|
163 | (1) |
|
|
|
164 | (1) |
|
|
|
165 | (1) |
|
Reconstructing the Source Code |
|
|
165 | (3) |
|
RtlInsertElementGenericTable |
|
|
168 | (2) |
|
RtlLocateNodeGenericTable |
|
|
170 | (8) |
|
RtlRealInsertElementWorker |
|
|
178 | (9) |
|
|
|
187 | (1) |
|
RtlLookupElementGenericTable |
|
|
188 | (5) |
|
RtlDeleteElementGenericTable |
|
|
193 | (1) |
|
Putting the Pieces Together |
|
|
194 | (2) |
|
|
|
196 | (3) |
|
|
|
199 | (44) |
|
|
|
200 | (1) |
|
|
|
201 | (1) |
|
|
|
202 | (5) |
|
The Password Verification Process |
|
|
207 | (11) |
|
Catching the ``Bad Password'' Message |
|
|
207 | (3) |
|
The Password Transformation Algorithm |
|
|
210 | (3) |
|
|
|
213 | (5) |
|
|
|
218 | (9) |
|
Analyzing the Directory Processing Code |
|
|
218 | (5) |
|
|
|
223 | (4) |
|
Dumping the Directory Layout |
|
|
227 | (1) |
|
The File Extraction Process |
|
|
228 | (11) |
|
|
|
234 | (1) |
|
|
|
235 | (1) |
|
The Floating-Point Sequence |
|
|
236 | (2) |
|
|
|
238 | (1) |
|
|
|
239 | (1) |
|
|
|
239 | (2) |
|
|
|
241 | (1) |
|
|
|
242 | (1) |
|
Auditing Program Binaries |
|
|
243 | (30) |
|
|
|
243 | (2) |
|
|
|
245 | (17) |
|
|
|
245 | (2) |
|
A Simple Stack Vulnerability |
|
|
247 | (2) |
|
Intrinsic Implementations |
|
|
249 | (1) |
|
|
|
250 | (4) |
|
|
|
254 | (1) |
|
|
|
255 | (1) |
|
|
|
256 | (1) |
|
|
|
256 | (2) |
|
Arithmetic Operations on User-Supplied Integers |
|
|
258 | (2) |
|
|
|
260 | (2) |
|
Case-Study: The IIS Indexing Service Vulnerability |
|
|
262 | (9) |
|
CVariableSet::AddExtensionControlBlock |
|
|
263 | (4) |
|
|
|
267 | (4) |
|
|
|
271 | (2) |
|
|
|
273 | (34) |
|
|
|
274 | (3) |
|
|
|
274 | (1) |
|
|
|
274 | (1) |
|
|
|
275 | (1) |
|
|
|
276 | (1) |
|
|
|
276 | (1) |
|
|
|
276 | (1) |
|
|
|
277 | (1) |
|
|
|
278 | (2) |
|
Information-Stealing Worms |
|
|
278 | (1) |
|
|
|
279 | (1) |
|
|
|
280 | (1) |
|
|
|
281 | (1) |
|
|
|
282 | (1) |
|
|
|
283 | (2) |
|
Establishing a Secure Environment |
|
|
285 | (1) |
|
|
|
285 | (19) |
|
|
|
286 | (4) |
|
|
|
290 | (1) |
|
|
|
291 | (3) |
|
Initializing Communications |
|
|
294 | (2) |
|
|
|
296 | (2) |
|
|
|
298 | (1) |
|
Communicating with the Backdoor |
|
|
299 | (4) |
|
|
|
303 | (1) |
|
|
|
303 | (1) |
|
The Backdoor.Hacarmy.D: A Command Reference |
|
|
304 | (2) |
|
|
|
306 | (1) |
|
|
|
307 | (114) |
|
Piracy and Copy Protection |
|
|
309 | (18) |
|
Copyrights in the New World |
|
|
309 | (1) |
|
|
|
310 | (1) |
|
|
|
310 | (4) |
|
|
|
311 | (1) |
|
|
|
312 | (1) |
|
|
|
313 | (1) |
|
The Theoretically Uncrackable Model |
|
|
314 | (1) |
|
|
|
314 | (4) |
|
|
|
314 | (1) |
|
|
|
315 | (1) |
|
Challenge Response and Online Activations |
|
|
315 | (1) |
|
Hardware-Based Protections |
|
|
316 | (1) |
|
|
|
317 | (1) |
|
Advanced Protection Concepts |
|
|
318 | (1) |
|
|
|
318 | (1) |
|
Digital Rights Management |
|
|
319 | (2) |
|
|
|
320 | (1) |
|
The Windows Media Rights Manager |
|
|
321 | (1) |
|
|
|
321 | (1) |
|
|
|
321 | (1) |
|
|
|
322 | (2) |
|
Attacking Copy Protection Technologies |
|
|
324 | (1) |
|
|
|
324 | (3) |
|
|
|
327 | (30) |
|
|
|
327 | (1) |
|
Basic Approaches to Antireversing |
|
|
328 | (1) |
|
Eliminating Symbolic Information |
|
|
329 | (1) |
|
|
|
330 | (1) |
|
Active Antidebugger Techniques |
|
|
331 | (5) |
|
|
|
331 | (1) |
|
The IsDebuggerPresent API |
|
|
332 | (1) |
|
SystemKernelDebuggerInformation |
|
|
333 | (1) |
|
Detecting SoftICE Using the Single-Step Interrupt |
|
|
334 | (1) |
|
|
|
335 | (1) |
|
|
|
335 | (1) |
|
|
|
336 | (8) |
|
Linear Sweep Disassemblers |
|
|
337 | (1) |
|
Recursive Traversal Disassemblers |
|
|
338 | (5) |
|
|
|
343 | (1) |
|
|
|
344 | (2) |
|
Control Flow Transformations |
|
|
346 | (9) |
|
|
|
346 | (2) |
|
|
|
348 | (1) |
|
|
|
348 | (5) |
|
|
|
353 | (1) |
|
|
|
354 | (1) |
|
|
|
355 | (1) |
|
|
|
355 | (1) |
|
Modifying Variable Encoding |
|
|
355 | (1) |
|
|
|
356 | (1) |
|
|
|
356 | (1) |
|
|
|
357 | (64) |
|
|
|
358 | (6) |
|
|
|
364 | (1) |
|
Ripping Key-Generation Algorithms |
|
|
365 | (5) |
|
Advanced Cracking: Defender |
|
|
370 | (45) |
|
Reversing Defender's Initialization Routine |
|
|
377 | (10) |
|
Analyzing the Decrypted Code |
|
|
387 | (9) |
|
|
|
396 | (1) |
|
Reversing the Secondary Thread |
|
|
396 | (3) |
|
Defeating the ``Killer'' Thread |
|
|
399 | (1) |
|
|
|
400 | (1) |
|
Reencrypting the Function |
|
|
401 | (1) |
|
|
|
402 | (2) |
|
Parsing the Program Parameters |
|
|
404 | (2) |
|
|
|
406 | (1) |
|
Validating User Information |
|
|
407 | (2) |
|
|
|
409 | (1) |
|
Brute-Forcing Your Way through Defender |
|
|
409 | (6) |
|
Protection Technologies in Defender |
|
|
415 | (4) |
|
Localized Function-Level Encryption |
|
|
415 | (1) |
|
Relatively Strong Cipher Block Chaining |
|
|
415 | (1) |
|
|
|
416 | (1) |
|
Obfuscated Application/Operating System Interface |
|
|
416 | (1) |
|
Processor Time-Stamp Verification Thread |
|
|
417 | (1) |
|
Runtime Generation of Decryption Keys |
|
|
418 | (1) |
|
|
|
418 | (1) |
|
User-Input-Based Decryption Keys |
|
|
419 | (1) |
|
|
|
419 | (1) |
|
|
|
419 | (2) |
|
Part IV Beyond Disassembly |
|
|
421 | (58) |
|
|
|
423 | (34) |
|
|
|
424 | (2) |
|
|
|
426 | (3) |
|
|
|
426 | (2) |
|
.NET Programming Languages |
|
|
428 | (1) |
|
|
|
428 | (1) |
|
Intermediate Language (IL) |
|
|
429 | (14) |
|
|
|
430 | (1) |
|
|
|
430 | (1) |
|
|
|
430 | (3) |
|
|
|
433 | (1) |
|
|
|
433 | (3) |
|
|
|
436 | (7) |
|
|
|
443 | (1) |
|
|
|
444 | (1) |
|
|
|
444 | (1) |
|
|
|
444 | (1) |
|
Breaking Decompilation and Disassembly |
|
|
444 | (1) |
|
Reversing Obfuscated Code |
|
|
445 | (10) |
|
|
|
446 | (2) |
|
DotFuscator by Preemptive Solutions |
|
|
448 | (3) |
|
Remotesoft Obfuscator and Linker |
|
|
451 | (1) |
|
|
|
452 | (1) |
|
|
|
453 | (1) |
|
|
|
453 | (2) |
|
|
|
455 | (2) |
|
|
|
457 | (22) |
|
Native Code Decompilation: An Unsolvable Problem? |
|
|
457 | (2) |
|
Typical Decompiler Architecture |
|
|
459 | (1) |
|
Intermediate Representations |
|
|
459 | (4) |
|
Expressions and Expression Trees |
|
|
461 | (1) |
|
|
|
462 | (1) |
|
|
|
463 | (3) |
|
|
|
463 | (1) |
|
Generating Control Flow Graphs |
|
|
464 | (2) |
|
|
|
466 | (10) |
|
|
|
466 | (1) |
|
Single Static Assignment (SSA) |
|
|
467 | (1) |
|
|
|
468 | (2) |
|
Register Variable Identification |
|
|
470 | (1) |
|
|
|
471 | (1) |
|
|
|
472 | (1) |
|
|
|
472 | (1) |
|
|
|
473 | (2) |
|
|
|
475 | (1) |
|
Finding Library Functions |
|
|
475 | (1) |
|
|
|
476 | (1) |
|
Real-World IA-32 Decompilation |
|
|
477 | (1) |
|
|
|
477 | (2) |
| Appendix A Deciphering Code Structures |
|
479 | (40) |
| Appendix B Understanding Compiled Arithmetic |
|
519 | (18) |
| Appendix C Deciphering Program Data |
|
537 | (24) |
| Index |
|
561 | |