首页
社区
课程
招聘
[原创]KCTF2021-秋 第二题 迷失丛林 writeup
发表于: 2021-11-18 11:20 18849

[原创]KCTF2021-秋 第二题 迷失丛林 writeup

2021-11-18 11:20
18849

输入32位{0-9,A-F},每两位组成1byte,处理成16bytes。Serial前8bytes填充到.data:00404000映射表。

根据映射表,生成二叉树,共生成0x100棵树。_404100作为树每层的长度,通过左右节点生成下一层的节点。

每棵树最后一层长度为0x100,标记最后一层出现过的值,最后统计0x100棵树中每个值被标记多少次(最多0x100次)。
需要满足sumctMp[0] == 0xA9 && sumctMp[0xE] == 0xAC && sumctMp[0x28] == 0xA7 && sumctMp[0x4F] > 0xC8
根据这个条件来确定Serial前8bytes,算法不会逆,只能靠猜:.data:00404000映射表初始值都是非0唯一的,先找到缺失的8字节的值:

验证时,把这8字节排列组合,过了条件的只有这一组

继续往下走,就是纯暴力了。
图片描述
先对映射表进行处理,之后Serial后8bytes的解就按照字节单独暴力解就行。

输出后8bytes值

Serial: B4D682C8BF2DE13AD9B6AEF24A80CB22

{
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x9B, 0xF4, 0xDF, 0xAC, 0x7C, 0xA1, 0xC6,
    0x16, 0xD0, 0x0F, 0xDD, 0xDC, 0x73, 0xC5, 0x6B, 0xD1, 0x96, 0x47, 0xC2, 0x26, 0x67, 0x4E, 0x41,
    0x82, 0x20, 0x56, 0x9A, 0x6E, 0x33, 0x92, 0x88, 0x29, 0xB5, 0xB4, 0x71, 0xA9, 0xCE, 0xC3, 0x34,
    0x50, 0x59, 0xBF, 0x2D, 0x57, 0x22, 0xA6, 0x30, 0x04, 0xB2, 0xCD, 0x36, 0xD5, 0x68, 0x4D, 0x5B,
    0x45, 0x9E, 0x85, 0xCF, 0x9D, 0xCC, 0x61, 0x78, 0x32, 0x76, 0x31, 0xE3, 0x80, 0xAD, 0x39, 0x4F,
    0xFA, 0x72, 0x83, 0x4C, 0x86, 0x60, 0xB7, 0xD7, 0x63, 0x0C, 0x44, 0x35, 0xB3, 0x7B, 0x19, 0xD4,
    0x69, 0x08, 0x0B, 0x1F, 0x3D, 0x11, 0x79, 0xD3, 0xEE, 0x93, 0x42, 0xDE, 0x23, 0x3B, 0x5D, 0x8D,
    0xA5, 0x77, 0x5F, 0x58, 0xDB, 0x97, 0xF6, 0x7A, 0x18, 0x52, 0x15, 0x74, 0x25, 0x62, 0x2C, 0x05,
    0xE8, 0x0D, 0x98, 0x2A, 0x43, 0xE2, 0xEF, 0x48, 0x87, 0x49, 0x1C, 0xCA, 0x2B, 0xA7, 0x8A, 0x09,
    0x81, 0xE7, 0x53, 0xAA, 0xFF, 0x6F, 0x8E, 0x91, 0xF1, 0xF0, 0xA4, 0x46, 0x3A, 0x7D, 0x54, 0xEB,
    0x2F, 0xC1, 0xC0, 0x0E, 0xBD, 0xE1, 0x6C, 0x64, 0xBE, 0xE4, 0x02, 0x3C, 0x5A, 0xA8, 0x9F, 0x37,
    0xAF, 0xA0, 0x13, 0xED, 0x1B, 0xEC, 0x8B, 0x3E, 0x7E, 0x27, 0x99, 0x75, 0xAB, 0xFE, 0xD9, 0x3F,
    0xF3, 0xEA, 0x70, 0xF7, 0x95, 0xBA, 0x1D, 0x40, 0xB0, 0xF9, 0xE5, 0xF8, 0x06, 0xBC, 0xB6, 0x03,
    0xC9, 0x10, 0x9C, 0x2E, 0x89, 0x5C, 0x7F, 0xB1, 0x1A, 0xD6, 0x90, 0xAE, 0xDA, 0xE6, 0x5E, 0xB9,
    0x84, 0xE9, 0x55, 0xBB, 0xC7, 0x0A, 0xE0, 0x66, 0xF2, 0xD8, 0xCB, 0x00, 0x12, 0xB8, 0x17, 0x94,
    0x6A, 0x4A, 0x01, 0x24, 0x14, 0x51, 0x07, 0x65, 0x21, 0xC8, 0x38, 0xFD, 0x8F, 0xC4, 0xF5, 0xFC}
{
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x9B, 0xF4, 0xDF, 0xAC, 0x7C, 0xA1, 0xC6,
    0x16, 0xD0, 0x0F, 0xDD, 0xDC, 0x73, 0xC5, 0x6B, 0xD1, 0x96, 0x47, 0xC2, 0x26, 0x67, 0x4E, 0x41,
    0x82, 0x20, 0x56, 0x9A, 0x6E, 0x33, 0x92, 0x88, 0x29, 0xB5, 0xB4, 0x71, 0xA9, 0xCE, 0xC3, 0x34,
    0x50, 0x59, 0xBF, 0x2D, 0x57, 0x22, 0xA6, 0x30, 0x04, 0xB2, 0xCD, 0x36, 0xD5, 0x68, 0x4D, 0x5B,
    0x45, 0x9E, 0x85, 0xCF, 0x9D, 0xCC, 0x61, 0x78, 0x32, 0x76, 0x31, 0xE3, 0x80, 0xAD, 0x39, 0x4F,
    0xFA, 0x72, 0x83, 0x4C, 0x86, 0x60, 0xB7, 0xD7, 0x63, 0x0C, 0x44, 0x35, 0xB3, 0x7B, 0x19, 0xD4,
    0x69, 0x08, 0x0B, 0x1F, 0x3D, 0x11, 0x79, 0xD3, 0xEE, 0x93, 0x42, 0xDE, 0x23, 0x3B, 0x5D, 0x8D,
    0xA5, 0x77, 0x5F, 0x58, 0xDB, 0x97, 0xF6, 0x7A, 0x18, 0x52, 0x15, 0x74, 0x25, 0x62, 0x2C, 0x05,
    0xE8, 0x0D, 0x98, 0x2A, 0x43, 0xE2, 0xEF, 0x48, 0x87, 0x49, 0x1C, 0xCA, 0x2B, 0xA7, 0x8A, 0x09,
    0x81, 0xE7, 0x53, 0xAA, 0xFF, 0x6F, 0x8E, 0x91, 0xF1, 0xF0, 0xA4, 0x46, 0x3A, 0x7D, 0x54, 0xEB,
    0x2F, 0xC1, 0xC0, 0x0E, 0xBD, 0xE1, 0x6C, 0x64, 0xBE, 0xE4, 0x02, 0x3C, 0x5A, 0xA8, 0x9F, 0x37,
    0xAF, 0xA0, 0x13, 0xED, 0x1B, 0xEC, 0x8B, 0x3E, 0x7E, 0x27, 0x99, 0x75, 0xAB, 0xFE, 0xD9, 0x3F,
    0xF3, 0xEA, 0x70, 0xF7, 0x95, 0xBA, 0x1D, 0x40, 0xB0, 0xF9, 0xE5, 0xF8, 0x06, 0xBC, 0xB6, 0x03,
    0xC9, 0x10, 0x9C, 0x2E, 0x89, 0x5C, 0x7F, 0xB1, 0x1A, 0xD6, 0x90, 0xAE, 0xDA, 0xE6, 0x5E, 0xB9,
    0x84, 0xE9, 0x55, 0xBB, 0xC7, 0x0A, 0xE0, 0x66, 0xF2, 0xD8, 0xCB, 0x00, 0x12, 0xB8, 0x17, 0x94,
    0x6A, 0x4A, 0x01, 0x24, 0x14, 0x51, 0x07, 0x65, 0x21, 0xC8, 0x38, 0xFD, 0x8F, 0xC4, 0xF5, 0xFC}
_404100    dd 2, 4, 8, 10h, 20h, 40h, 80h
_404100    dd 2, 4, 8, 10h, 20h, 40h, 80h
// 生成第d棵树(0<=d<0x100
void genTree(int d)
{
    genMp[0] = Mp400[d];
    genMp[1] = d + 1;
    int p = 0;
    for (int i = 0; i < sizeof(mi) / sizeof(int); i++)
    {
        for (int j = 0; j < mi[i]; j++)
        {
            uint8_t pm = genMp[p];
            p++;
            genMp[p * 2] = Mp400[pm];
            genMp[p * 2 + 1] = pm + 1;
        }
    }
}
// 生成第d棵树(0<=d<0x100
void genTree(int d)
{
    genMp[0] = Mp400[d];
    genMp[1] = d + 1;
    int p = 0;
    for (int i = 0; i < sizeof(mi) / sizeof(int); i++)
    {
        for (int j = 0; j < mi[i]; j++)
        {
            uint8_t pm = genMp[p];
            p++;
            genMp[p * 2] = Mp400[pm];
            genMp[p * 2 + 1] = pm + 1;
        }
    }
}
{0x1e, 0x28, 0x4b, 0x6d, 0x8c, 0xa3, 0xd2, 0xfb}
{0x1e, 0x28, 0x4b, 0x6d, 0x8c, 0xa3, 0xd2, 0xfb}
{0x4b, 0x6d, 0x28, 0x8c, 0xfb, 0xd2, 0x1e, 0xa3}
{0x4b, 0x6d, 0x28, 0x8c, 0xfb, 0xd2, 0x1e, 0xa3}
uint8_t keyC[]{0x4b, 0x6d, 0x28, 0x8c, 0xfb, 0xd2, 0x1e, 0xa3};
    memcpy(Mp400, keyC, 8);
    isOk();
    uint8_t sgs[8];
    uint8_t input2[8];
    char *out = "GoodJob~";
    for (int it = 0; it < 8; it++)
    {
        int w = 0;
        memcpy(sgs, Mp400, 8);
        while (0x100 != w)
        {
            input2[it] = w;
            int v17 = 0;
            do
            {
                for (int i = 0; i < 8; ++i)
                {
                    if (v17 >= 8)
                    {
                        if (!i || i == 7)
                            sgs[i]--;
                    }
                    else
                    {
                        uint8_t v19;
                        if (input2[i] & 1)
                            v19 = sgs[i] + 1;
                        else
                            v19 = Mp400[sgs[i]];
                        sgs[i] = v19;
                        input2[i] >>= 1;
                    }
                }
                ++v17;
            } while (v17 < 9);
            if ((uint8_t)out[it] == sgs[it])
                break;
            memcpy(sgs, Mp400, 8);
            w++;
        }
        printf("%02x ", w);
    }
    printf("\n");
uint8_t keyC[]{0x4b, 0x6d, 0x28, 0x8c, 0xfb, 0xd2, 0x1e, 0xa3};
    memcpy(Mp400, keyC, 8);

[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!

收藏
免费 2
支持
分享
最新回复 (1)
雪    币: 614
活跃值: (455)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
厉害了
2021-11-19 09:44
0
游客
登录 | 注册 方可回帖
返回
//