程序崩溃原因总结

测试环境:redhat程序跑飞原因分析Buffer overflows (缓冲区溢出) Integer overflows (整数翻转&#xff

 

测试环境:redhat

 

程序跑飞原因分析

  •  Buffer overflows (缓冲区溢出)
  •  Integer overflows (整数翻转)
  •  Signedness issues (符号)
  •  Invalid memory references (非法指针)
  •  Infinite loops (死循环)

 

程序崩溃分析:

指针,空指针使用(NULL),非法指针(0x00000000)

栈溢出, strcpy拷贝长字符串到局部变量

格式化串, printf漏写或多写变量

堆溢出, malloc会保存一些控制数据(元数据)在分配给用户的内存块前/后位置。

 

#include<stdio.h>

#include<stdlib.h>

 

intmain(int argc, char** argv){

char *buf;

char *buf2;

buf =(char*)malloc(1024);

buf2 =(char*)malloc(1024);

printf("buf=%pbuf2=%p\n", buf, buf2);

 

strcpy(buf,argv[1]);

free(buf2);

printf("afterfree buf2.\n");

free(buf);

}

 

[wuchao@localhostbasicheap]$ gcc -o basicheap  basicheap.c

[wuchao@localhostbasicheap]$ ./basicheap  `perl -e 'print"A" x 5000'`

buf=0x8f44008buf2=0x8f44410

Segmentationfault (core dumped)

 

0x8f44410 - 0x8f44008 = 0x408 (十进制1032),所以有8字节的元数据。

 

参考资料:

The Art of File Format Fuzzing

黑客攻防技术宝典:系统实战篇(第2版)

 

发布者:admin,转转请注明出处:http://www.yc00.com/web/1754940419a5218049.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信