Tools & Opcodes
Tools & Opcodes
Attention
Published for educational Purposes only
Welcome:-
Welcome to the wonderful world of cracking.
Cracking is the art of removing or disabling copy protected coding from programs,
this manual will go into some detail on removing copy protection from programs.
If you feel offended by this, then I would suggest you stop here....
Introduction:-
Cracking .net applications is still a new topic, and it has any similarities with
classic cracking, but I think It's much easier than cracking native code
application, the ability to see the source code and what Functions are exactly
being used with detailed information about every line being executed is what
makes this easier, here no Soft-Ice or W32Dasm are needed, we may need soft-
ice some time later, I don't know, but there is a new workflow here, and it's
basically dependent upon decompiling the IL code of the targeted assembly and
analyzing the source code that tools like reflector can generate, so a good
understanding of any one of the new .NET languages is essential and can be a
great advantage for you.
Tools:-
Before we begin, you will need certain tools, I use some of them, but this doesn't
Mean we will need them all Here, just make sure that you have them and try to
learn how to use them...
When you need to invert this jump you will need the actual bytes
Of the instruction "BGT" which Transfers control to a target
Instruction if the first value is greater than the second value.
And it's represented as "3D".
So you will need to replace the 3E with 3D in hex editor to get the job done....
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
.method public specialname instance class Scroller.Scroller/Title
get_Titles(object Index) cil managed
// SIG: 20 01 12 0C 1C
{
// Method begins at RVA 0xcd7c
// Code size 23 (0x17)
.maxstack 2
.locals init (class Scroller.Scroller/Title V_0)
IL_0000: /* 02 | */ ldarg.0
IL_0001: /* 7B | (04)00000D */ ldfld
IL_0006: /* 03 | */ ldarg.1
IL_0007: /* 28 | (0A)00005C */ call object
IL_000c: /* 6F | (0A)00005D */ callvirt instance object
IL_0011: /* 74 | (02)000003 */ castclass
Scroller.Scroller/Title
IL_0016: /* 2A | */ ret
} // end of method Scroller::get_Titles
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Don't worry if you don't understand this code, we will talk about this more later...
You will find ildasm.exe in this folder after you install .Net framework SDK
"..\..\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\"
3. Hex workshop : Hex editor
I recommend this or any hex editor that can search for Unicode
Strings and locate a series of bytes.
Very easy to find on the web, just Google it!
A debugger and Disassembler for PE files that can disassemble and debug
.net assemblies too, It shows the IL instructions and their actual bytes,
You will be able to break on any JIT compiler event and this is cool!
With this debugger you can step through the .net IL instructions
And understand what's going in the background...
You can get it from "www.smidgeonsoft.com"
You will sometimes need this tool to dump the entire .net assembly
PE file, some protection software like ".Net reactor" will pack
Your .net assembly and will produce a non-MSIL PE file that will
Unpack your assembly and execute it from memory when launched, and
This technique is used to prevent any access to the IL code of the
Original assembly itself, but you can easily overcome this by using
A simple .net generic unpacker, you can download one from
"www.ntcore.com"
Finally:-
Sometimes you will see that "Reflector" won't be able to
Decompile some procedure or function into your favorite language like
C# or VB or Delphi, so you will have to familiarize yourself with
The IL instructions, and this is like learning the classic
Assembly language to crack native code applications, but you
Will see that IL is easier and faster to learn!
The Opcodes:-
This is the most important point of cracking, as you know the .net application
Represent their program instruction in MSIL format which stands for Microsoft
Intermediate language, your source code is not translated to native machine-code
when you compile it in visual studio RAD, but it's translated to this format which
will later be compiled into native code by JIT compiler, JIT stands for just-in-time
Compiler, meaning that only certain parts of your programs will be translated into
Native code and executed on demand.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
.method public specialname instance class Scroller.Scroller/Title
get_Titles(object Index) cil managed
// SIG: 20 01 12 0C 1C
{
// Method begins at RVA 0xcd7c
// Code size 23 (0x17)
.maxstack 2
.locals init (class Scroller.Scroller/Title V_0)
IL_0000: /* 02 | */ ldarg.0
IL_0001: /* 7B | (04)00000D */ ldfld
IL_0006: /* 03 | */ ldarg.1
IL_0007: /* 28 | (0A)00005C */ call
IL_000c: /* 6F | (0A)00005D */ callvirt
IL_0011: /* 74 | (02)000003 */ castclass
IL_0016: /* 2A | */ ret
} // end of method Scroller::get_Titles
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
IL_0000: /* 02 | */ ldarg.0
If you are into cracking then you know what these instructions mean !
MSIL Opcodes are different from native Opcodes designed for the Intel
Processors, for example after you know the offset of a CALL in a native code
program you open that program in a hex editor and overwrite the right number of
bytes that call that function or whatever with 90s which stands for NOP in native
machine code.
In MSIL the NOP is represented by 00 not 90, so it's important here to list the
Opcodes For MSIL with their actual byte values now, we won't need to use them
all when We crack a program, most of the time we will be using the NOP
instruction and inverting Jumps to get the job done.
I will mark the important Opcodes in cracking in gray and orange colors so try to
focus on them.
Opcodes list
These are some of the obstacles that you will face when you crack any Assembly;
I will try to explain some of them here, for more information on any of them just
Google it.
1. Obfuscation:
It's the process of changing the method and classes names to non-
readable
Characters to make harder for us to find the "IsLicensed" function, yes;
It can make the job harder for you but believe me it's not that hard to
trace
Through the code even when it's obfuscated.
The solution here is using bookmarks in reflector to help you keep your
Sanity when moving between methods and a I suggest a paper and a pen
too,
Cracking demands patience. No patience, no cracking.
2. Encoded Strings:
This is ugly, It reminds me of old times when I was waiting for W32Dasm
to
Finish disassembling to see if there is any "Invalid Serial Number" in
String references, but with encoding strings you won't see any clear
Text wandering around to tell you what this particular function does.
The most common way to hide strings is encoding them and then saving
the
Entire encoded stream as a binary .net resource, and whenever some
string is
Needed, A function is called to get that string from encoded stream and
It will return the original string, the point that makes this technique weak
Is that it has to be fast in decoding to keep the program running fast or
At least not much slower than it used to do when strings were clear and
Retrieved quickly without decoding, most decoding functions use byte
Shifting and reordering to decode strings, and believe me they are easy
To find and reverse, as soon as you find the decoder you can reverse it
And write your own decoder, this will help you reveal most strings
Through the code quickly, Later I will show you how to reverse the
Decoding function used in commercial applications.
You can find detailed explanations about how the Strong Name Signature
works and its implementation over the internet.
We won't reinvent the wheel, read in the tools section to find the answer.
THE END
Last words:-
Best wishes,
Kurapica