内存攻击
承接上文,本文继续介绍《Hardware/Software Interface》的实验三。
Level 2: Firecracker
Your task is to get bufbomb to execute the code for bang() rather than returning to test(). Before this, however, you must set global variable global_value to your cookie.
这次任务就需要向缓存区中注入指令来修改全局变量global_value的值,然后再ret命令跳转到test函数,做法是先写汇编代码,再将汇编代码编译成目标文件,再利用objdump命令将文件反汇编:找到对应命令的二进制机器码。
可查找到bang函数指令地址为0x401020,查看bang函数的汇编代码可知道全局变量global_value的内存地址为0x602308,那么编写的汇编代码bang.s如下:
mov $0x5be053965365c085,%rax # set global = cookie
mov %rax,0x0000000000602308
push $0x0000000000401020 # Push 0x401020 on to the stack
ret # Return
执行以下语句对代码编译和反汇编: