Smash the Stack

Smash the Stack_第1张图片

https://inst.eecs.berkeley.edu/~cs161/fa08/papers/stack_smashing.pdf


重要概念: 

经常我们可以overflow 越界buffer size 去修改return 里的地址。 这样的话,可以让return address指向 我们定义的

attack code的address。

Smash the Stack_第2张图片


Smash the Stack_第3张图片

这里large_string arr是256 byte 但是 buffer[]只有16byte。直接copy进去的话会overwrite 一些别的东西。包括Frame pointer, Return address..

Smash the Stack_第4张图片




Off by one byte. 假设你overflow 修改ret 里的内容只修改了one byte. 你没成功把地址指向你想攻击的地方,而是指向了一个奇怪的地方。

Smash the Stack_第5张图片


ESP 和 EBP: ESP是当前code在stack里的执行地址, EBP是base pointer to current frame stack 的地址。

如果我们改了ESP, 

EIP是当前Frame里下一个要执行的指令的地址

Saved EIP 是上一层caller frame 下一个执行的地方。

但是发现Saved EIP竟然是在低地址????

值得注意: called by frame 和 previous frame's sp

previous frame's sp指向call当前这个function frame的caller frame 起始点。

called by frame 这个指的是the address of caller stack frame. 

可以看出, previous frame's sp的地址在stack的更上面一点。

Smash the Stack_第6张图片
Smash the Stack_第7张图片



花了超级多的时间在理解/x**/x***/x***的问题。最后发现其实就是把一个地址倒着写。。。

你可能感兴趣的:(Smash the Stack)