pwnable.kr [bof]
Nana told me that buffer overflow is one of the most common software vulnerability.
Is that true?
Download : http://pwnable.kr/bin/bof
Download : http://pwnable.kr/bin/bof.c
Running at : nc pwnable.kr 9000
代码
#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;
}
代码含义:输入字符串通过栈溢出,改变函数栈帧中的第一个参数值
方法:查看函数栈帧
易得函数栈帧的大小为48h
那么可以把整个栈帧中全部充满我们需要的key值,然后就可以不用管参数值的位置,也可以改变参数值。
代码如下