4 Reverse Engineer's Blog (KDSBest)
4 Reverse Engineer's Blog (KDSBest)
4 Reverse Engineer's Blog (KDSBest)
04/12/2014
Search for:
Search
1 2 3 4 5 6 7 8 9 10 11
The compiler u use will generate assembler instruction formed in an exe file or similar to execute it on your CPU. The CPU instructions are assembler instructions (in hex format instead of human readable called Opcode). Reconstructing source code from an assembler listing is called reverse engineering. It is used in many ways. Finding Exploits, developing Shellcodes, Hacking Consoles and understanding other software are just some scenarios where this is used.
How do I start?
I always start with translating every assembler instruction into C code right away, because Im much familiar reading obfuscated C code instead of a wall of assembler code. I will cover examples and the first instruction conversions I find most in code While converting the instructions to C you will notice some things right away, later. Then feel free to optimize the code right away. A simple example is this C code:
http://www.kdsbest.com/?p=268
1/5
04/12/2014
r3 = 0x12340000003DCBA9;
1 2 3 4 5 6 7
lis %r3, 0x1234 rldicr %r3, %r3, 32 oris %r3, %r3, 0x3D ori %r3, %r3, 0xCBA9
Going Deeper
First I provide u the first direct translations to C code The bottom format will be used the whole series
1
In C
r3 = 0x12340000;
Our Example
1
In C
r3 = r3 << 32;
r3 <<= 32;
04/12/2014
1. Register, like always the destination register 2. Register, the value which will be used for the or operation (src and destination dont have to match) 3. Value which will be used for the or operation Our Example
1
In C
r3 = r3 | 0xCBA9;
r3 |= 0xCBA9;
Note: I showed ori before oris because understanding ori is easier and they are basicly the same.
1
In C
r3 = r3 | 0x3D0000;
r3 |= 0x3D0000;
The Example:
The way we got it.
1 2 3 4 5 6 7
lis %r3, 0x1234 rldicr %r3, %r3, 32 oris %r3, %r3, 0x3D ori %r3, %r3, 0xCBA9
Now just copy the C translation and fill in the right values and registers u will got this. In C
1 2 3 4
r3 r3 r3 r3
1 2
Since the left shift only adds 4 bytes of 0 bits to the right side of the value the result will be like this:
r3 = 0x1234000000000000;
Next part
1 2
r3 = 0x1234000000000000;
http://www.kdsbest.com/?p=268
3/5
04/12/2014
2 3
r3 |= 0x3D0000;
Since u know we OR just with zeros u can simply put the value in there.
r3 = 0x12340000003D0000;
1 2
r3 = 0x12340000003D0000; r3 |= 0xCBA9;
r3 = 0x12340000003DCBA9;
IMPORTANT: If u got any question I will always answer them on twitter (the fastest way to get intouch with me) I
am a nice guy dont fear me ;). There are no dumb questions. I try to answer them all https://twitter.com/KDSBest
Leave a Reply
Your email address will not be published. Required fields are marked * Name *
Email *
Website
You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym
title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike>
http://www.kdsbest.com/?p=268
4/5
04/12/2014
<strong>
Post Comment
http://www.kdsbest.com/?p=268
5/5