13 hours 15 minutes
Hello. This is Dr Miller and this is Episode 7.4 of Assembly
today. What we're gonna do is we're gonna take a program that we've already Britain and we're going to convert it so that it uses Mac Rose.
So for this program, it's the some program that we did earlier.
And when we did it, we used hard coded offsets. And so we'd like to do is convert those offsets to either parameters or arguments, depending on which one that they are.
Alright, So I've logged onto the server, and now what I'm gonna do is I've already got the code set up.
Go ahead and load that up.
And I already have the program loaded that we had started before.
And so what we're gonna do is we're going to come down here, and we're just going to convert this program so that it uses the appropriate Mac Rose.
So what we're gonna be replacing
is this here?
So the first thing that we have to do is we have to say, push some sort of context, and it's just the names of the
The assembler knows what we're doing, and then we can set our stack size,
and then we can create a special variable that the assembler will use to figure out how many local variables we have.
And we're just initializing it. And then basically, we can tell it what arguments we have. And then what? Local variables have so percent? Argh!
So n is the number that we used in our C program and then for our locals.
So I'm defining each one of these is the D word, which means of the take of four bites.
And then this should allocate the local size that it defined when it was looking for each local variable.
And so, in this case, it should be eight. Right? So we have to de words. And so it should end of generating the number eight for that.
And then we'll go down here to the bottom, and then we just got oh, pop that context.
So that will remove that context so that the assembler will work right. And then down here, instead of the epilogue, we're going to use leave,
which does the same thing,
so should fix our stack appropriately.
Now, when we come into our program, we need to find every place that we used a hard coded offset CBP minus four.
And we can just use the variable that we've defined. So this should be some.
This one is I. So I is minus eight, so I'll go ahead and find all the place I
each one of these will become, I and then minus four is some.
And then we see you had E b P plus eight, which is n and so we can just use. And in this case,
So when you start your program from scratch or to be a lot easier to start with this because then you can just use variable names instead of trying to remember the hard coded offsets.
So we should be able to build this
And we should get thesafeside results that we got before.
So we today we talked about converting our program so that it didn't use hard coded offsets, which are much more difficult,
but we saw that we had a little bit more work to do up front, and we learned what that work is. And then how we could do that. In an example,
Looking forward, we're going to start talking about floating point numbers and how we do operations on floating point numbers within a computer.
If you have questions, you can contact me at Miller MJ at you and Kate. I e to you. And you can find me on Twitter at Milhouse 30.
How to Use GDB (BSWJ)
In this part of the Breaking Stuff with Joe (BSWJ) series, Joe Perry demonstrates how ...
Certificate of Completion Offered
How to Use IDA (BSWJ)
The IDA is used throughout the IT and cybersecurity industries by exploit developers, vulnerability analysts, ...
Certificate of Completion Offered