这是一个任务,但我对基本理解有问题。
弱势法典:
int choc(char *arg)
{
char buf[400];
snprintf(buf, sizeof buf, arg);
return 0;
}
我的理解是,一个动力需要是一种模式,它将随着我希望执行的法典的地址而超出返回地址。 但是,我难以确定模式。
因此,说明形式的内容需要:
- the address of the return instruction, which I need to overwrite
- A list of %x
- The value which I would write on the return address. This would be the address of the code I want to execute.
为了获得返回地址,我只需要看一下右翼的训令的地址? 百分比的目的是什么? 我如何把守则的论述编码成正文,我想以说明形式执行?
A test I did: Using gdb I found that the address of my buf is 0xbffffba0. I generated arg to be "xa0xfbxffxbf_%x.%x.%n"; Shouldn t this write some value to the start of the buff at the address 0xbffffba0? However I get a segfault. What am I doing wrong?
Any help would be appreciated!