>lhzctf

Upxxor

1.用ida打开文件

发现需要脱壳 用upx直接脱壳

2.打开脱壳文件

读main函数 并生成伪代码

const char *key  = "upx_k3y";                                  // 0x18340, 7 字节
const char *blob = "25332C191046090D2F4C310F6C0B451C146E0554260D400A22"; // 0x18348

int main(void) {
    uint8_t target[25];
    bool ok = true;

    for (int i = 0; i < 25; i++)                    // 0x10A5 循环
        target[i] = (hex2int(blob[2*i]) << 4) | hex2int(blob[2*i + 1]);

    puts("== UPX && XOR ==\n");
    printf("What is the flag?\n> ");

    char buf[0x80];
    if (!fgets(buf, 0x80, stdin)) return 1;
    strtok(buf, "\r\n");

    if (strlen(buf) != 25) ok = false;              // 0x1194
    for (int i = 0; i < 25 && ok; i++)              // 0x11B8 循环
        if ((uint8_t)(buf[i] ^ key[i % 7]) != target[i])   // 0x11F0
            ok = false;

    puts(ok ? "Correct! You unpacked the shell and broke the XOR :)"
            : "Wrong. Something is packed, and something is scrambled.");
    return 0;
}

运行脚本

ct  = bytes.fromhex("25332C191046090D2F4C310F6C0B451C146E0554260D400A22")
key = b"upx_k3y"
flag = bytes(c ^ key[i % len(key)] for i, c in enumerate(ct))
print(flag.decode())   

得到flag

OSINT