简体   繁体   English

我需要反转功能的帮助

[英]I need help reversing what a function does

So i have got this function. 所以我有这个功能。

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);
}

I need to make a function that actually decrypts this and gets the instruction from the result using a key so it would be like. 我需要制作一个实际上将其解密并使用键从结果中获取指令的函数,就像这样。

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

Basically i want it to reverse the whole process of the encrypt so it decrypts it and gets me the instruction. 基本上,我希望它可以逆转加密的整个过程,因此它可以解密并获得指令。

They are used in this function 它们用于此功能

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;
}

You may use: 您可以使用:

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;
}

And then you have 然后你有

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

Demo 演示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM