pwnable-[collision]

博客讲述进入服务器查看代码,因flag无r权限,代码需读取20个字符串并每四个转换为int数据。已知shellcode值,经处理后利用python脚本进行注入,同时提到字符串转整型时要注意小端存储数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

进入服务器查看代码 ,flag必然没有r权限

#include <stdio.h>
#include <string.h>
unsigned long hashcode = 0x21DD09EC;
unsigned long check_password(const char* p){
	int* ip = (int*)p;
	int i;
	int res=0;
	for(i=0; i<5; i++){
		res += ip[i];
	}
	return res;
}

int main(int argc, char* argv[]){
	if(argc<2){
		printf("usage : %s [passcode]\n", argv[0]);
		return 0;
	}
	if(strlen(argv[1]) != 20){
		printf("passcode length should be 20 bytes\n");
		return 0;
	}

	if(hashcode == check_password( argv[1] )){
		system("/bin/cat flag");
		return 0;
	}
	else
		printf("wrong passcode.\n");
	return 0;
}

代码意思就是读取20个字符串 , 然后每四个转换为int 数据, 我们知道shellcode = 0x21DD09EC , 转换为十进制‭568134124‬ , 不是5的倍数 ,所以方便起见 , +1 后除以 5 ,最后一个数据减 1 ,同时字符串转整型 要注意小端存储数据,所以利用python脚本我们注入

`python  -c 'print  "\xc9\xce\xc5\x06"*4+"\xc8\xce\xc5\x06"'`
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值