程序崩溃原因总结

 

测试环境: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版)

 

  • 1
    点赞
  • 1
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cutter2002

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值