Thursday, 4 July 2013

Hacking C codes.The Dark Art of Reverse Engineering Part 1

Standard
Hacking C codes.
The Dark Art of Reverse Engineering Part 1: Decompile


You may or may not have used some sort of cracks ,keygens ,patches etc at some  point in your life. Have you ever thought how they are developed ? . Today in this tutorial I am going to demonstrate you the "dark art of reverse engineering"

Now before I begin I must say that Reverse Engineering is really a tough , tedious job. It requires huge amount of time.To learn reverse engineering one must show enough dedication and patience.The tutorial that I am going to demonstrate took about a hell lot of time to disassemble ,decompile and interpret the outputs.

okay so lets begin..

Caution:
This tutorial should be used for educational purpose only. I won't be responsible if you misuse this techniques and get yourself in trouble.Reverse Engineering  any software without the permission of owner's permission is treated as an illegal activity.
The software which I will be hacking as a part of the demo is developed by me.

Tools Required
  • Any Linux Distro
  • Any C executable file
  • RecStudio
Prerequisites 
  • Knowledge of C programming
  • Knowledge of ASM(not Required for this tutorial but will be helpful for Part II onward )
So the scenario goes like this.

A game developer Mr Coder has developed a game.To make sure that there is no software piracy he decides to develop it in such a way that the serial key is asked every time someone starts the game.So this is the piece of code he wrote



To make sure his code works Mr Coder runs a check and tests the output




Now he is pleased that none can have a pirated copy. So Mr Coder starts selling the hello.o file along with the serial and at the same time he keeps his source code away so that no one can read the source code.


 Somehow a cracker called Mr Cracker got the hello.o file but neither he has the serial nor he is willing to buy the game.So what to do ??? Mr Cracker decides to hack the game instead .


So he fires the RecStudio and opens the hello.o file with it . Here it how the hello.o file looks after its loaded in RecStudio



This is the ASM version of the code which is just disassembled from the executable hello.o file.


Now he finds the various segments in the Project Tab to find the equivalent decompiled code.

Now Mr Cracker goes on checking each and every decompiled code. Suddenly he encounters the main function and checking the decompiled code he found something interesting  ;) .





If we have a look at the highlighted code we find that the error message  "Not a valid serial .." is displayed when the values of _v8 and _v12 does not match. He found from above that the value of _v8 is 1234 which is compared with certain variable and the error message is generated when the results does not match.So this could be the serial.


So he enters the value 1234 when he is asked for the serial and he gets access to the game. Congos !!!


In the next tutorial I will explain you how the ASM codes can be used to perform the same operation.And in later tutorials I will explain how to make the crack for this game.

                                                    Thank You