-
-
看雪CTF.TSRC 2018 团队赛-第2题
-
发表于:
2018-12-3 17:22
3701
-
1.
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
#define BUF_SIZE (30)
static char g_buf[BUF_SIZE];
static char *g_psz_input = new char[BUF_SIZE];
static char g_expected[] = "invalid argument";
class ClsVerify
{
public:
~ClsVerify()
{
void verify(char *buf);
verify(g_expected);
}
};
static ClsVerify g_cls_verify;
void process(char *buf)
{
buf[7] = '#';
for (size_t i = 0; i < strlen(buf); ++i)
{
buf[i] ^= 0x1F;
}
}
void verify(char *buf)
{
if (!buf)
{
return;
}
for (size_t i = 0; i < strlen(buf); ++i)
{
buf[i] ^= 0x1C;
}
if (!strcmp(buf, g_psz_input))
{
cout << 'o';
cout << 'k';
}
}
int main()
{
cout << "Please Input:";
scanf_s("%s", g_buf, BUF_SIZE);
size_t len = strlen(g_buf);
if (len > BUF_SIZE || len < 10)
{
printf("输入错误;");
exit(0);
}
strcpy_s(g_psz_input, BUF_SIZE, g_buf);
if (g_psz_input[7] != 'A')
{
printf("输入错误;");
exit(0);
}
process(g_psz_input);
}
sn: jmubojgAbqdvnfmw
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
#define BUF_SIZE (30)
static char g_buf[BUF_SIZE];
static char *g_psz_input = new char[BUF_SIZE];
static char g_expected[] = "invalid argument";
class ClsVerify
{
public:
~ClsVerify()
{
void verify(char *buf);
verify(g_expected);
}
};
static ClsVerify g_cls_verify;
void process(char *buf)
{
buf[7] = '#';
for (size_t i = 0; i < strlen(buf); ++i)
{
buf[i] ^= 0x1F;
}
}
void verify(char *buf)
{
if (!buf)
{
return;
}
for (size_t i = 0; i < strlen(buf); ++i)
{
buf[i] ^= 0x1C;
}
if (!strcmp(buf, g_psz_input))
{
cout << 'o';
cout << 'k';
}
}
int main()
{
cout << "Please Input:";
scanf_s("%s", g_buf, BUF_SIZE);
size_t len = strlen(g_buf);
if (len > BUF_SIZE || len < 10)
{
printf("输入错误;");
exit(0);
}
strcpy_s(g_psz_input, BUF_SIZE, g_buf);
if (g_psz_input[7] != 'A')
{
printf("输入错误;");
exit(0);
}
process(g_psz_input);
}
sn: jmubojgAbqdvnfmw
2. Just My Code
最新版的vs加入了/JMC编译选项(Debug默认是开启的), 开启后函数开头会加入__CheckForDebuggerJustMyCode调用
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
最后于 2018-12-4 09:07
被风间仁编辑
,原因: