[原创]dasctf 2023六月挑战赛 二进制专项 re writeup | 宜武汇-ag真人国际厅网站

#include

#include

 

using namespace std;

 

#include

#define delta 0x7937b99e

#define mx (((z>>5^y<<2) (y>>3^z<<4)) ^ ((sum^y) (key[(p&3)^e] ^ z)))

 

void btea(uint32_t* v, int n, uint32_t const key[4]) {

    uint32_t y, z, sum;

    unsigned p, rounds, e;

    if (n > 1) {          /* coding part */

        rounds = /*6 */52 / n;

        sum = 0;

        z = v[n - 1];

        do {

            sum = delta;

            e = (sum >> 2) & 3;

            for (p = 0; p < n - 1; p ) {

                y = v[p 1];

                z = v[p] = mx;

            }

            y = v[0];

            z = v[n - 1] = mx;

        } while (--rounds);

    }

    else if (n < -1) {  /* decoding part */

        n = -n;

        rounds = /*6 */52 / n;

        sum = rounds * delta;

        y = v[0];

        do {

            e = (sum >> 2) & 3;

            for (p = n - 1; p > 0; p--) {

                z = v[p - 1];

                y = v[p] -= mx;

            }

            z = v[n - 1];

            y = v[0] -= mx;

        } while ((sum -= delta) != 0);

    }

 

int main()

    uint32_t const key[4] = { 0x4b5f, 0xdead, 0x11ed, 0xb3cc };

    uint32_t data[11] = { 0xcc45699d, 0x683d5352,0xb8bb71a0,0xd3817ad,0x7547e79e,0x4bdd8c7c,0x95e25a81,0xc4525103,0x7049b46f,0x5417f77c,0x65567138 };

    uint32_t* sent = data;

    //btea(sent, 11, key);

    //printf("coded:%x  %x\n", sent[0], sent[1]);

    btea(sent, -11, key);

    //printf("decoded:%x  %x\n", sent[0], sent[1]);

    for (int i = 0; i < 11; i ) {

        for (int j = 0; j < 4; j )

        {

            printf("%c", sent[i] & 0xff);

            sent[i] >>= 8;

        }

    }

    return 0;

//dasctf{7eb20cb2-deac-11ed-ae42-94085339ce84}

原文链接:https://bbs.kanxue.com/thread-277490.htm

网络摘文,本文作者:15h,如若转载,请注明出处:https://www.15cov.cn/2023/08/27/原创dasctf-2023六月挑战赛-二进制专项-re-writeup/

发表评论

邮箱地址不会被公开。 必填项已用*标注

网站地图