首页
社区
课程
招聘
[原创]整数溢出
发表于: 2013-7-9 17:48 3886

[原创]整数溢出

2013-7-9 17:48
3886
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

int cmdstring(char *buf1, char *buf2, int len1, int len2)
{
	char buf[256];
	if ((len1+len2) > 256)
	{
		printf("超出buf容纳范围!\n");
		return -1;
	}

	memcpy(buf, buf1, len1);
	memcpy(buf + len1, buf2, len2);
	printf("复制%d + %d = %d个字节到buf!\n", len1, len2, len1 + len2);
	return 0;
}

int main(int argc, char *argv[])
{
	cmdstring(argv[1], argv[2], atoi(argv[3]), atoi(argv[4]));
	return 0;
}


cmd运行程序
c:\>程序.exe china hello 2 5
复制2 + 5 = 7个字节到buf!

c:\>程序.exe china hello 300 200
超出buf容纳范围!

程序貌似看着没有异常,那么输入
china hello  2147483647 1
出现什么结果呢?

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 183
活跃值: (1058)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
2
LZ 的这个和malloc有什么关系?
2013-7-9 18:04
0
雪    币: 116
活跃值: (111)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
是整数溢出,呵呵
2013-7-9 18:10
0
雪    币: 90
活跃值: (80)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
4
之后就可以用argv[1]堆栈溢出了吗?利用不了吧不过
2013-7-9 18:25
0
雪    币: 264
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
你这是memcpy溢出…………
2013-7-10 13:34
0
雪    币: 3
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
int(2147483647 + 1) < 0
memcpy(buf, buf1, 2147483647) 字符串溢出
2013-7-10 16:39
0
游客
登录 | 注册 方可回帖
返回
//