首页
社区
课程
招聘
1
【原创】第六题 WP
发表于: 2019-6-27 19:00 5857

【原创】第六题 WP

2019-6-27 19:00
5857

F5  直接拉起

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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;
}

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 1
支持
分享
赞赏记录
参与人
雪币
留言
时间
PLEBFE
为你点赞~
2023-1-25 00:05
最新回复 (0)
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册