.ly

Thursday, 6 June 2013

How To Crack a File

I did not write this myself but i found it extremely useful. Enjoy it

PART 1:
0. Introducion:

I have read many cracking tutorials lately. Frankly speaking, I myself learned cracking from tutorials (and some book, but this doesnt really matter). The majority of the cracking tutorials out there have a few disadvantages: either they are too long and contain a lot of garbage, or they are too short, and don't contain the basics.

I decided to write a tutorial which will not have those two disadvantaged.

Anyway, I divided the tutorial into 3 parts:

Part 1: Introduction, tools and The basics of cracking.
Part 2: Practical training, using W32Dasm, and HIEW
Part 3: Key-generators.

Welcome to the first part. ;-)

1. Disclaimer:

I created this tutorial for informational purposes only!
Much of the information in this document can be used to perform illegal activities!
Don't attempt to do anything stated in this document!
If you do attempt to do anything, you are solely and fully responsible for what you do!
If you get caught and get in any kind of trouble, it's your own fault!
If you intend to use this information to impress your friends, leave it and grow up!
If you don't agree to this, do not read any more!
If you crack a program, and either sell the crack or offer it for free, it is a crime!


2. What is Cracking?

For me, cracking is:
"Letting a program, which is on your computer behave as you want it to behave and not behave as someone else (the programmer) wants"


As INTERN said:
"Hey, it is your stuff right? your numbers, your bits, you should be able to do anything you wish to do with it "


Actually, I agree to this.


So cracking is modifying your programs, and making them work they way you want them to. U can get a free demo program, crack it, and use it. BUT!!!! I repeat, if you crack a program, and start selling the cracked version or even offering it for free, it is a crime!


After reading those three tutorials (this is the first one in thsi series), you will feel the power you have in your hands (I mean, in your head).

well, let's get started?

3. Tools
There are very few tools you need by now...
It is very easy to find them over the web, cause they are quite popular:


The first one is "Win32 Disassembler", which is also know ans W32Dasm.


The Win32 Disassembler allows you to:

Disassemble files - translate the program to it's assembly origin, or machine code.
The file types which can be disassambled in Win32 Disassembler:
exe, 386, com, cpl, drv, dll, fon, mpd, ocx, vbx, vbx and sys.
Load the program proccess and trace the program.
Browse the disassembled file and go to any code location that you want.
Find text.
Execute, insert or remove jumps and calls.
Import and export functions.
Show a HEX display of a code area.
Show the list of the STRINGS, DIALOGS and REFERENCES.
Save the Disassembly source in text format.
Well, u can get it in almost any cracking site, but I'll give you some URLs:

http://wowsites.com/meiner/w32dsm89.zip
I think that's about enough. If any of these links goes down, please alert me.

The second tool you need is Hiew, which is also known as Hacker's View. The Hacker's View Tool allowes you to:

Disassemble files.
Make changes in the disassembled file, such as:
write commands, modify commands and reassemble the file.
View the file in ASCII, Hex or assembly mode.
You can also download an excellent program for cracking called Soft-ICe. Anyway, we won't need it in this part of the tutorial. Anyway, here are some URLs for Soft-ICe.

Please use the (Astalavista.com) search engines to find this programs!

4. The Main steps of cracking

There are 7 steps in the process of cracking:

Run the program you want to crack and learn it's standard behavior. Try to locate strings and keywords, try to enter the password and see how the program responds.
Open up the program with the W32Dasm and disassamble it.
Find typical and common strings in the disassembly that appeared in the program. In most cases, you have to look for keywords such as: password, name, date, expired, time limit, wrong, entered and so on.
Find and observe the password generator, find the learn protection routine and the API calls.
Try to understand the jumping mechanism of the protection.
Open up the program in HIEW. Change the jump of the flow control to it's oposite jump command, or nop it out.
Run and see how the change you have made in the original program affected it. Feel the power you have, the power of cracking, letting programs behave as you want them to.
Learn those steps very well, until u dream of them, u will use them in every program you crack.

5. Basic terms in Assembly

A. Registers:

Registers are variables which are stored in your processor. The processor uses these variables for basic mathimatical and logical operations. The mostly used registers are: eax, ebx, ecx and edx. Sometimes you will see edi, esi, esp, ebp. There are three types of registers: 32Bit registers, 16Bit registers and 8Bit registers. The 32Bit registers start with e, such as eax. There are 16Bit equivalents of these registers. The only Difference between the two types is the veriable size. These registers are: ax, bx, cx, dx, di, si, sp, bp. There are also 8 bit registers. Tthe 8Bit registers are: al, ah, bl, bh, cl, ch, dl, dh. l - means the lower 8 bits of the 16Bit register. h - means the higher 8 bits of the 16Bit register. Here the l stands for the lower and h for the higher 8 bits of a 16 bit register.
B. Flags:

Flags are Boolean variables (get 0 or 1 values). Flags are used by the processor for internal logical and mathimatical operations, in order to get the result of the operation. The most important flag is the Zero Flag, which can get zero or non-zero (1) values.
C. Code Flow

When you are analyzing a piece of code, you must understand that the processor is actually quite stupid, and all it does is to simply follow the basic instructions, line by line. It does anything the code tells it to do, and cannot do anything that is not written in the code (unless it has been run over by a herd of cows and abducted by aliens). This is why you have to think like the processor when you're analyzing a piece of code, and to act like it (just don't get used to it! Inhale, exhale, inhale, exhale... nevermind, stupid joke) You have to do everything the processor does, you have to compare registers and variables, execute jumps and calls, calculate Basic mathimatical operations, store and load register values and adresses, and so on... The processor has an instruction pointer especially for this, which is also called IP (it has nothing to do with IP addresses in the Internet Protocol, trust me). Using the instruction pointer, the processor points to the instruction that is about to be executed. The processor also has and executes instructions which change the code flow.
These instructions can be function calls, any other routine calls, jumps, conditional jumps, which depend on the zero flag, negative conditional jumps...
6. Conclusion

In this part of the tutorial we have learnt the meaning of the word cracking. Making programs behave as you want them to, and not the way the programmer wants them to. We have also learnt about the basic and the popular tools of cracking: W32Dasm, Hiew and SoftICE. And finally we have learnt the 7 main steps of cracking.

Now, Before you go to the next chapter, you have to learn these 7 steps and download the tools mentioned above, because we can't go on to the next chapter unless you have those tools and know the steps.

PART 2:

0. Introduction:

In this part, the second part of the cracking tutorial, you will learn to use the most important tools of the common cracker: W32Dasm and HIEW. You will also learn to crack some simple programs.

The tutorials are divided into 3 parts:

Part 1: Introduction, tools and the basics of cracking.
Part 2: Practical training, using W32Dasm, and HIEW.
Part 3: key-generators.

Welcome to the second part. :-)

1. Disclaimer:

I created this tutorial for informational purposes only!
Much of the information in this document can be used to perform illegal activities!
Don't attempt to do anything stated in this document!
If you do attempt to do anything, you are solely and fully responsible for what you do!
If you get caught and get in any kind of trouble, it's your own fault!
If you intend to use this information to impress your friends, leave it and grow up!
If you don't agree to this, do not read any more!
If you crack a program, and either sell the crack or offer it for free, it is a crime!

2. The main steps of cracking

You have already seen these steps in the previous part of the tutorial, but it's very important to know them. Remembering these steps and following them is 40% of the way towards success in cracking the program!!!

There are 7 steps in the cracking process:

Run the program you want to crack and study it's behavior. try to locate strings and keywords, try to enter the password and see how the program responds.
Open the program with the W32Dasm and disassemble it.
Find typical and common Strings in the disassembly that appeared within the program.
in most cases, you have to look for keywords such as: password, name, date, expired,
Time limit, wrong, entered and so on.
Find and observe the password generator, find the learn protection routine and the API calls.
Try to understand the jumping mechanism of the protection.
Open the program in Hiew. change the jump of the flow control to it's opposite jump command, or NOP it out.
Run and check how the change you have made in the original program affected it.
Feel the power you have, the power of of cracking, making programs behave the way you want them to.
Learn those steps very well, until u dream of them, u will use them in every program you crack.

3. Additional programs you need to have for this part of the tutorial

By now, in this part of the tutorial, you have learnt the main steps of cracking. Now, you are going to crack your first program.

But before that, you need to get a little program called: "Sweet Little Piano" You can download it from: http://www.ronimusic.com/

Now, when you have the program, let's start!

4. Cracking the first program (Sweet little Piano)

Now we will follow each step and crack the program:

Step 1: Running the program:

Well, Run it! Duh... :-)

Well, what do we see here..... The program opens two text files. Also we see "Unregistered Shareware" on the caption bar... Now let's open the Help menu for any registration options... Humm, what do we see here now...
oh, it's a password option... Well, select it and enter something (don't hope it will be right :-)). To see what happens... Click OK.. Hmm, nothing happens.... Maybe it accepted it? Hmm.. no way... the caption bar still says Unregistered... Ok close it... bah ... more text files ... and a notification that the settings are not saved in the unregistered version ... well ... kind of irritating those text files! Let's fix it :-)

Step 2: Disassemble the program:

Disassemble the program. Good, small is fast :-) Always.... Now, we don't have any strings that pop up when we want to register something... Let's browse for strings like registered, unregistered, the string about the unsaved settings. Hmm... evaluation time left ... password.txt.... passworddialog.... sweet little piano - Unregistered <<-- looks like our caption bar ;-) go on...Thanks for registering ... cool! So it thanks you anyway :-) Let's jump to that place ... Double click on it an we will pop right on top of the registration routine...

Step 3: Analyzing the protection routine.... / Understanding the jumping Mechanism...

Let's analyze the protection routine.

////////////////////// Code snip ///////////////////////////
ADDRESS MACHINE CODE ASSEMBLER INSTRUCTIONS
* Possible Reference to Dialog: PASSWORDDIALOG, CONTROL_ID:0064, ""
|
:00401715 6A64 push 00000064
:00401717 53 push ebx
* Reference To: USER32.GetDlgItemTextA, Ord:0000h
|
:00401718 E8A5B50000 Call 0040CCC2
:0040171D E822FFFFFF call 00401644
:00401722 85C0 test eax, eax
:00401724 741E je 00401744
:00401726 6A30 push 00000030
* Possible StringData Ref from Data Obj ->"SweetPiano"
|
:00401728 6866D24000 push 0040D266
* Possible StringData Ref from Data Obj ->"Thanks for registering!"
|
:0040172D 68FED14000 push 0040D1FE
:00401732 53 push ebx

////////////////////// Code snip ///////////////////////////

PasswordDialog ... a call to GetDlgItemTextA ... another call.... a test... and depending on the test a je.... The je jumps over the thank you ... And just ends the dialog box ... without telling you that you entered something wrong... So this is right ... we did indeed not see that we typed something wrong ... but apparently we are supposed to see if we type something right :-)

Again execute the je jump, and look where it goes to ... return from the jump.... Now lets try to rewrite what goes on here...

call ShowPasswordDialog
call GetEnteredText
call IsEnteredTextGood
test value in eax
je QuietExit

ShowThanksForRegistering

QuietExit:

the source code must have looked like this :

GetDlgItemText(_ID_Serial);
if (EnteredTextGood) ShowThanksForRegistering

// else nothing....

This is another interesting piece of code.... test eax, eax ... this assembler instruction tests if the value of eax is equal to itself ... if it is it is equal ... so a je instruction jumps ... if it is not equal, it does not jump.... To crack this program we can change the je instruction into two nop instructions... and we are done...

We have seen here, that the call has put a value in eax.... something which is not equal to zero or a zero... In our previous example we saw that the called Is_Serial_Valid call set some value in memory ... Here we see that the called Is_Serial_Valid call sets the eax register of our processor to some value....


Step 4: Changing the original program...

So modify it :-)

Open Hiew.
Open the file within Hiew.
Find the Adress of the line in W32Dasm (it's on the status bar beginning with '@').
Press F5 in Hiew.
Enter the address you have found in (4) and press ENTER.
Press F3 - for activating the write option.
Press F2 - to change the instruction.
Replace the command by 'NOP' (without quotes), which means NO OPERATION.
Now a new command appeared in the next line.
Replace it by NOP too.
If another new instruction hasn't appeared, Press F9 to update the file.
Press F10 to exit.
Run the program and see the result.
If you didn't succeed, have any questions or need any additional information, E-Mail me and I will answer all of your questions.

5. Conclusion

I gave this quite 'hard' cracking example so that u know that if you crack this program, you can crack almost every program, and most of them are much simpler to crack. In the next part you will learn to detect key generators and crack them.

Before you go to the next chapter, go over the steps again, and also go over the protection mechanism detection and modification.

This tutorial was written by Tech Lord <http://blacksun.box.sk>
-Spyda

No comments :

Post a Comment