Ret 2 Win
Ret 2 Win
3. Code Auditing
a)Integer overflow/underflows
b)Type Conversion
c) Sizeof errors
Recap of what we’ve learned so far:
So far we’ve found a lot of ways to corrupt the stack memory, but what
can we actually do with that?
<- RSP
Corrupting the Stack: Stack
--8 bytes wide--
<- RSP
Corrupting the Stack: Stack
--8 bytes wide--
DDDDDDDD
CCCCCCCC
BBBBBBBB
CCCCCCCC
BBBBBBBB
BBBBBBBB
HHHHHHHH
Lets examine our code
1. Setup Stack Frame GGGGGGGG
<- RBP
<- RSP
New Program! Stack
--8 bytes wide--
<- RSP
Lets look into memory: Stack
--8 bytes wide--
<- RSP
Our New Exploit: Stack
--8 bytes wide--
win addr
1. Fill the stack until we reach
the base pointer
BBBBBBBB
<- RBP
2. Overwrite the base pointer
(doesn’t really matter what
AAAAAAAA
the value is)
AAAA
3. Set return address to our AAAAAAAA
intended destination (win
offset)
AAAAAAAA
4. Run program and you win!
AAAAAAAA <- RSP
Things to Note:
• You can to anywhere in the program
• Doesn’t have to be the start of a function, you can jump to the
center to avoid certain parts or even jump to data