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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.