Part 7 - Debugging Basic I/O

For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/hacking\_c-\_arm64

Today we are going to debug our very basic input validation program from last lecture.

To begin let's open up our binary in Radare2.

radare2 ./0x02_asm_64_basicio

Let's take advantage of Radare2's auto analysis feature.

aaa

The next thing we want to do logically is fire up the program in debug mode so it maps the raw machine code from disk to a running process.

ood

Now that we have a running instance we can seek to the main entry point of the binary.

s main

Let us take an initial examination by doing the following.

v

A couple things to note we see at 0x5566be00cc the output of "Enter Age: " and at 0x5566be017c a call to istream which is going to capture the values from stdin to which we identify a failure condition at 0x5566be01d0 where we find "Dude be real!" and we see the results of a proper input validation starting at 0x5566be0218 _where we say "You are " and then we see a call to the output stream at _0x5566be0238 and then the continuation of the validation string at 0x5566be0244 where we say " years old, seems legit!".

The next step is to look at the binary with a visual graph.

q
VV
ppppp

This is our zoomed out visual graph. We can see how the program moves from function to function. You will notice there are a series of tags such as [ol] or [ok] and you can literally type the following:

p
ol

Now we are inside that function.

Then to go back to main.

qq
s main
VV

This will take us to an expanded graph that we can also use our arrow keys to look around.

Let's set a breakpoint at 0x5566be00c4 where we bne 0x5566be0214 which is where we see the success route of our binary.

[0x5566be0194]> db 0x5566be00c4
[0x5566be0194]> dc
hit breakpoint at: 0x5566be00c4
Enter Age: 33
hit breakpoint at: 0x5566be00c4
[0x5566be0194]> dc
Your are 33 years old, seems legit!
(2215) Process exited with status=0x0

As you can see we cycled the loop and entered in a correct validation and was able to get our success return.

In our next lesson we will hack the validation.

results matching ""

    No results matching ""