首页
社区
课程
招聘
【原创】第六题 WP
2019-6-27 19:00 5160

【原创】第六题 WP

2019-6-27 19:00
5160
F5  直接拉起
const char *base64code = "tuvwxTUlmnopqrs7YZabcdefghij8yz0123456VWXkABCDEFGHIJKLMNOPQRS9+/";
const char *code = "!NGV%,$h1f4S3%2P(hkQ94==";
using namespace std;

inline int charEncrypt(int data)
{
	int dataa; 
	dataa = base64code[data];
	if (dataa > '@' && dataa <= 'Z')
		return 0x9B - dataa;
	if (dataa > 0x60 && dataa <= 'z')
		return dataa - 64;
	if (dataa > '/' && dataa <= '9')
		return dataa + 50;
	if (dataa == '+')
		return 'w';
	if (dataa == '/')
		dataa = 'y';
	return dataa;
}

void OnDecodeStart(const char *code)
{
	unsigned short i, j, k;
	BYTE temp[5] = {0};
	//cout << code[0] << code[1] << code[2] << code[3];
	for (i = 0x20; i < 0x7f;i++ )
	{
		for (j = 0x20; j < 0x7f;j++)
		{
			for (k = 0x20; k < 0x7f; k++)
			{
				temp[0] = charEncrypt((i >> 2) & 0x3f);
				temp[1] = 16 * i & 0x30;
				temp[1] = temp[1] | (j >> 4);
				temp[1] = charEncrypt(temp[1]);
				temp[2] = 4 * j & 0x3C;
				temp[2] = temp[2] | (k >> 6);
				temp[2] = charEncrypt(temp[2]);
				temp[3] = (k & 0x3F);
				temp[3] = charEncrypt(temp[3]);
				if (temp[0] == code[0] && temp[1] == code[1] && temp[2] == code[2] && temp[3] == code[3])
				{
				   std::cout << (char)i << (char)j << (char)k;
				}
					
			}
		}
	}
}

int OnsolveStart()
{
	for (int i = 0; i < 6; i++)
	{
		OnDecodeStart(code+i*4);
	}
	BYTE temp[3];
	for (int i = 0x20; i < 0x7f; i++)
	{
		temp[0]= charEncrypt((i >> 2) & 0x3f);
		temp[1] = 16 * i & 0x30;
		temp[1] = temp[1];
		temp[1] = charEncrypt(temp[1]);
		if (temp[0] == '9' && temp[1] == '4')
		{
			cout << (char)i;
		}
	}
	return 1;
}
int main()
{
	OnsolveStart();
	OnDecodeStart("abcd");
    return 0;
}

得到答案   KanXue2019ctf_st

[CTF入门培训]顶尖高校博士及硕士团队亲授《30小时教你玩转CTF》,视频+靶场+题目!助力进入CTF世界

收藏
点赞1
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回