Showing posts with label Hacking Lessons. Show all posts
Showing posts with label Hacking Lessons. Show all posts

Olga Lednichenko has a Kick ass Blog On Security and Hacking :

Click here: http://olgalednichenko.wordpress.com/2008/09/06/a-basic-approach-attacking-a-remote-computer-by-guest-editor-olga-lednichenko/

HACKING TEST 17

Reverse Engineering Contd………

How to Clear Hacking Test 5?

Steps…..

1).Open the file in OllyDbg.

2).This program has an option to execute one line at a time (shortcut F8).

3).Keep on pressing F8 and at the same time keep an eye on all the 5 windows (upper left, upper center, upper right, lower left and lower right). Whenever you’ll press F8 you will see some changes in all these 5 windows.

4). Keep on pressing F8 until you reach the following instruction “CMP EAX, -1” followed by “JNZ Short 0040109A”.

What’s happening here?

Here Value in EAX is compared with -1 i.e. FFFFFFFF and if the result is Zero then the JNZ (Jump if not Zero) instruction will not result in a jump and the instruction following JNZ will be executed.

Check out the value stored in the EAX registers (See just above the lower left window), its FFFFFFFF.

So the Jump will not take place and hence the next instruction will get executed which will inevitably take you to “Evaluation period out of date, purchase new license”.

So we need to somehow skip this instruction.

Check out the upper right window, here you can see the flags which are set when the jump instruction is executed. Currently the value of Z flag is 1 so if we change this value to zero then the JNZ instruction will result in a jump (double click on it, the value will be changed to zero).

So, this way we were able to skip this first barrier. Check out the program you’ll find three more of them.


5).Keep on pressing F8 until you reach the following instruction “JNZ SHORT 004010B4” followed by “JMP SHORT 004010F7”.

What’s happening here?

Here you can see that if JNZ instruction will not make a jump then JMP instruction will make a jump to 004010F7 which will inevitably take you to “Keyfile is not valid, Sorry”.

So here again you have to perform the same step just change the value of Z flag from 1 to zero.

So, this way we were again able to skip the second barrier.


6).Keep on pressing F8 until you reach the following instruction “JL SHORT 004010F7”.

What’s happening here?

Here you can see that there is no JNZ instruction but the JL instruction is again making the jump to 004010F7 which will inevitably take you to “Keyfile is not valid, Sorry”.

So here again you have to perform the same step but with a twist just change the value of S flag from 1 to zero. Since, this is the flag which gets affected when the JL instruction is executed.

So this way we were again able to skip the third barrier.

The next jump instruction i.e. JE SHORT 004010D3 is not taking us to any barrier so don’t change any value, and keep on pressing F8, but again we reach the instruction JL SHORT 004010F7 which will again take us to “Keyfile is not valid, Sorry”, but if we are able to skip this instruction then the next jump is to the address 00401205 which stores the value “You really did it! Congratz !!!”.

So all we need to do is just set the S flag to zero and we will reach our destination.

Finalizing the patch-

……………will continue

HACKING LESSON 18

Finalizing the patch-

In order to finalize the patch and make an executable running file we need to perform the following steps –
Repeat all the steps that we perform earlier but this time we have to change the instruction instead of flags.

1). Keep on pressing F8 until you reach the following instruction “CMP EAX, -1” followed by “JNZ Short 0040109A”.

Double click on “JNZ Short 0040109A”, a window will open. Remember, here we need to perform the jump in order to bypass the barrier so change JNZ to JMP, and click on assemble, rest remains the same.

2). Keep on pressing F8 until you reach the following instruction “JNZ SHORT 004010B4” followed by “JMP SHORT 004010F7”.

Double click on “JNZ Short 004010B4”, a window will open. Here also we need to perform the jump in order to bypass the barrier so change JNZ to JMP, and click on assemble, rest remains the same.

3).Keep on pressing F8 until you reach the following instruction “JL SHORT 004010F7”.

Double click on “JL Short 004010F7”, a window will open. Remember, here we do not need to jump because it will jump directly to the barrier so we need to skip this instruction. Change “JL Short 004010F7” to NOP, click on assemble, rest remains the same.

4).Keep on pressing F8 until you again reach the following instruction “JL SHORT 004010F7”.

Repeat step number 3.

Now all the four patches have been applied, next we need to save these patches and create an executable file.

1).Select the code from where you started applying patches i.e. from the opcode “00401073” to “004010D0”.

2).Right click on the selection and select copy to executable > selection.

3).A new window will open, again right click inside the window and select save file. Make sure it is saved as an executable file.

4). Now click on the new file.

The file is cracked.