簡體   English   中英

我需要反轉功能的幫助

[英]I need help reversing what a function does

所以我有這個功能。

UINT32 Encrypt(UINT32 instruction, int increment)
{
    UINT32 linstruction = _rotl(instruction, 7);
    UINT32 rinstruction = _rotr(instruction, 3);

    UINT32 key = (0x1F3D8AF * increment) ^ (rinstruction ^ linstruction);
    return (key ^ instruction);
}

我需要制作一個實際上將其解密並使用鍵從結果中獲取指令的函數,就像這樣。

t = encrypt(t, i);
t = decrypt(t, key);

基本上,我希望它可以逆轉加密的整個過程,因此它可以解密並獲得指令。

它們用於此功能

int RbxOpEncoder::encode(Instruction op, int i, int key) {
    int orig = ConvertInstruction(op);
    int t = orig;
    switch (GET_OPCODE(op)) {
    case OP_JMP:
        t = ((Encrypt(t, i) & 0x3FFFFFF) | ((orig >> 26 & MASK1(6, 0)) << 0x1A));
    break;
    case OP_CALL:
    case OP_TAILCALL:
    case OP_CLOSURE:
    case OP_RETURN:
        t = ((Calldecrypt(t, i) & 0x3FFFFFF) | ((orig >> 26 & MASK1(6, 0)) << 0x1A));
        break;  
    }
    t = EncryptOpcode(t, key);
    return t;
}

您可以使用:

std::uint32_t decrypt(std::uint32_t instruction, int increment)
{
    instruction = instruction ^ (0x1F3D8AF * increment);

    for (int i = 0; i != 15; ++i) {
        instruction = Encrypt(instruction, 0);
    }
    return instruction;
}

然后你有

decrypt(Encrypt(value, increment), increment) == value

演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM