1.37k likes | 1.52k Views
Breaking Protection. Overview. Here, we discuss cracking examples Examples are not from real software “Crackme” --- program designed for studying cracking/protection techniques Why learn cracking? So that you can better protect software
E N D
Breaking Protection Breaking Protection 1
Overview • Here, we discuss cracking examples • Examples are not from real software • “Crackme” --- program designed for studying cracking/protection techniques • Why learn cracking? • So that you can better protect software • “…protection technologies developed by people who have never attempted cracking are never effective!” Breaking Protection 2
Patching • Consider the following application • KeygenMe-3 by Bengaly • No useful info here • What to do? • Enter some data and see what happens Breaking Protection 3
Patching • Get invalid serial number message: • Now what? • OllyDbg, of course… Breaking Protection 4
Patching • Looking for message box Breaking Protection 5
Patching • What about lpk.dll? Breaking Protection 6
Patching • Imports/exports Breaking Protection 7
Patching • References to MessageBoxA • OK, now what? Breaking Protection 8
Patching • Third MsgBoxA reference Breaking Protection 9
Patching • Now patch it in OllyDbg… • …success Breaking Protection 10
Keygenning • Spse program asks for ID & serial number • Such a program may have keygen algorithm • Generate a “key” or serial number based on ID • Attacker might want access to keygen algorithm • Why? • To generate many valid ID/serial number pairs • Why isn’t 1 such pair sufficient? Breaking Protection 11
Ripping Keygen Algorithm • Goal is to create working copy of keygen algorithm • Just for creating valid ID/serial number pairs • This code can be “ripped” from the application • Following example is from… • KeygenMe-3 by Bengaly Breaking Protection 12
Ripping Keygen Algorithm • Code Part 1 Breaking Protection 13
Ripping Keygen Algorithm Code Part 2 Breaking Protection 14
Ripping Keygen Algorithm • Code Part 3 Breaking Protection 15
Ripping Keygen Algorithm • Take a look at Key4.00401388 Breaking Protection 16
Ripping Keygen Algorithm • Code for keygen algorithm… • Uppercase asm is ripped from app • Note: there is no need to understand the details! Breaking Protection 17
Ripping Keygen Algorithm • Insert previous code into console app • And try it out… Breaking Protection 18
Advanced Cracking: Defender • Application developed to demonstrate protection techniques • “…similar to what you would find in real-world commercial protection…” • Difficult, but not impossible • “…all it takes is a lot of knowledge and a lot of patience” Breaking Protection 19
Defender Interface • Launch without command-line options Breaking Protection 20
Defender Interface • Launched with “random” username/serial number Breaking Protection 21
Defender: Linked Modules • Load into OllyDbg and look at Executable Modules window • Gives exe modules that are statically linked • Just standard stuff here Breaking Protection 22
Defender: Imports/Exports • Imports/exports • Only API called is IsDebuggerPresent? • This is very strange Breaking Protection 23
Defender: DUMPBIN • Anything? • Still just one API? • What about summary? Breaking Protection 24
DUMPBIN /HEADERS • Try long listing --- find the following • …………………………………………………………… Breaking Protection 25
DUMPBIN /HEADERS • And… • …………………………………………………………… Breaking Protection 26
DUMPBIN /HEADERS • And… • …………………………………………………………… Breaking Protection 27
DUMPBIN /HEADERS • And… • …………………………………………………………… Breaking Protection 28
Strange Section Names • May be indication that program is packed • What to do? • Try unpacking • Will only work if it is standard packer Breaking Protection 29
Defender: PEiD • Try PEiD for common packers • Nothing interesting… Breaking Protection 30
Defender: Initialization • Want to figure out where “Bad key, try again” msg comes from • But, Defender does not call any API??? • So, no obvious place to set break point • What to do? • Look at initialization routine… Breaking Protection 31
Initialization Disassembly I Breaking Protection 32
Initialization Disassembly II Breaking Protection 33
Initialization Disassembly III Breaking Protection 34
Initialization Disassembly IV Breaking Protection 35
Initialization Disassembly V Breaking Protection 36
Initialization • Consider this code • fs register for thread-related info • What’s at offset “+30”? Breaking Protection 37
Initialization • For any thread fs:0 is “Thread Environment Block” (TEB) • What to do? • Look up the TEB data stucture… Breaking Protection 38
TEB • At +30 we have PEB • Process Environment Block • Just like TEB, but for a process • Program access +c in PEB • So, program accesses PEB via TEB Breaking Protection 39
PEB • What is at +c in PEB? • _PEB_LDR_DATA • Go look at that data structure… Breaking Protection 40
_PEB_LDR_DATA • Program get +c here too • LIST_ENTRY • Look at data structure (next slide) Breaking Protection 41
LIST_ENTRY • Goes to offset +0 here • That is, LIST_ENTRY again Breaking Protection 42
LIST_ENTRY • Goes to offset +18 here • That is, DllBase Breaking Protection 43
What Does it all Mean? • After all of that, program has found base of some DLL • Dump loader data structures • InLoadOrderModuleList from PEB_LDR_DATA • Next slide… Breaking Protection 44
Initialization Breaking Protection 45
Initialization • Bottom line? • The function at 00402EA8 obtains in-memory address of NTDLL.DLL • Program must communicate with OS • And this is a highly obfuscated way to (begin to) do so! Breaking Protection 46
Initialization • Then what? • Next, goes to function at 004033D1 • Listing starts on next slide… Breaking Protection 47
Function at 004033D1 Breaking Protection 48
Function at 004033D1 Breaking Protection 49
Function at 004033D1 Breaking Protection 50