You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
240 lines
13 KiB
240 lines
13 KiB
#include <vmprofiler.hpp>
|
|
|
|
namespace vm::handler::profile
|
|
{
|
|
vm::handler::profile_t shlq = {
|
|
// MOV RAX, [RBP]
|
|
// MOV CL, [RBP+0x8]
|
|
// SUB RBP, 0x6
|
|
// SHL RAX, CL
|
|
// MOV [RBP+0x8], RAX
|
|
// PUSHFQ
|
|
// POP [RBP]
|
|
"SHLQ",
|
|
SHLQ,
|
|
NULL,
|
|
{ { // MOV RAX, [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_RAX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
},
|
|
// MOV CL, [RBP+0x8]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_CL &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP && instr.operands[ 1 ].mem.disp.value == 0x8;
|
|
},
|
|
// SUB RBP, 0x6
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SUB &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
|
instr.operands[ 1 ].imm.value.u == 0x6;
|
|
},
|
|
// SHL RAX, CL
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SHL &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_RAX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_CL;
|
|
},
|
|
// MOV [RBP+0x8], RAX
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 0 ].mem.disp.value == 0x8 &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_RAX;
|
|
},
|
|
// PUSHFQ
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool { return instr.mnemonic == ZYDIS_MNEMONIC_PUSHFQ; },
|
|
// POP [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_POP && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
} } } };
|
|
|
|
vm::handler::profile_t shldw = {
|
|
// MOV EAX, [RBP]
|
|
// MOV CL, [RBP+0x4]
|
|
// SUB RBP, 0x6
|
|
// SHL EAX, CL
|
|
// MOV [RBP+0x8], EAX
|
|
// PUSHFQ
|
|
// POP [RBP]
|
|
"SHLDW",
|
|
SHLDW,
|
|
NULL,
|
|
{ { // MOV EAX, [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_EAX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
},
|
|
// MOV CL, [RBP+0x4]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_CL &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP && instr.operands[ 1 ].mem.disp.value == 0x4;
|
|
},
|
|
// SUB RBP, 0x6
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SUB &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
|
instr.operands[ 1 ].imm.value.u == 0x6;
|
|
},
|
|
// SHL EAX, CL
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SHL &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_EAX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_CL;
|
|
},
|
|
// MOV [RBP+0x8], EAX
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 0 ].mem.disp.value == 0x8 &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_EAX;
|
|
},
|
|
// PUSHFQ
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool { return instr.mnemonic == ZYDIS_MNEMONIC_PUSHFQ; },
|
|
// POP [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_POP && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
} } } };
|
|
|
|
vm::handler::profile_t shlw = {
|
|
// MOV AX, [RBP]
|
|
// MOV CL, [RBP+0x2]
|
|
// SUB RBP, 0x6
|
|
// SHL AX, CL
|
|
// MOV [RBP+0x8], EAX
|
|
// PUSHFQ
|
|
// POP [RBP]
|
|
"SHLW",
|
|
SHLW,
|
|
NULL,
|
|
{ { // MOV AX, [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_AX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
},
|
|
// MOV CL, [RBP+0x4]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_CL &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP && instr.operands[ 1 ].mem.disp.value == 0x2;
|
|
},
|
|
// SUB RBP, 0x6
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SUB &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
|
instr.operands[ 1 ].imm.value.u == 0x6;
|
|
},
|
|
// SHL AX, CL
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SHL &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_AX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_CL;
|
|
},
|
|
// MOV [RBP+0x8], AX
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 0 ].mem.disp.value == 0x8 &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_AX;
|
|
},
|
|
// PUSHFQ
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool { return instr.mnemonic == ZYDIS_MNEMONIC_PUSHFQ; },
|
|
// POP [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_POP && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
} } } };
|
|
|
|
vm::handler::profile_t shlb = {
|
|
// MOV AL, [RBP]
|
|
// MOV CL, [RBP+0x2]
|
|
// SUB RBP, 0x6
|
|
// SHL AL, CL
|
|
// MOV [RBP+0x8], AX
|
|
// PUSHFQ
|
|
// POP [RBP]
|
|
"SHLB",
|
|
SHLB,
|
|
NULL,
|
|
{ { // MOV AL, [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_AL &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
},
|
|
// MOV CL, [RBP+0x4]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_CL &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP && instr.operands[ 1 ].mem.disp.value == 0x2;
|
|
},
|
|
// SUB RBP, 0x6
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SUB &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_IMMEDIATE &&
|
|
instr.operands[ 1 ].imm.value.u == 0x6;
|
|
},
|
|
// SHL AL, CL
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_SHL &&
|
|
instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 0 ].reg.value == ZYDIS_REGISTER_AL &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_CL;
|
|
},
|
|
// MOV [RBP+0x8], AX
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_MOV && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP &&
|
|
instr.operands[ 0 ].mem.disp.value == 0x8 &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_AX;
|
|
},
|
|
// PUSHFQ
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool { return instr.mnemonic == ZYDIS_MNEMONIC_PUSHFQ; },
|
|
// POP [RBP]
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_POP && instr.operands[ 0 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 0 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
} } } };
|
|
} // namespace vm::handler::profile
|