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.
169 lines
8.5 KiB
169 lines
8.5 KiB
#include <vmprofiler.hpp>
|
|
|
|
namespace vm::handler::profile
|
|
{
|
|
vm::handler::profile_t readq = {
|
|
// MOV RAX, [RBP]
|
|
// MOV RAX, [RAX]
|
|
// MOV [RBP], RAX
|
|
"READQ",
|
|
READQ,
|
|
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 RAX, [RAX]
|
|
[]( 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_RAX;
|
|
},
|
|
// MOV [RBP], 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[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_RAX;
|
|
} } } };
|
|
|
|
vm::handler::profile_t readgsq = {
|
|
// MOV RAX, [RBP]
|
|
// MOV RAX, GS:[RAX]
|
|
// MOV [RBP], RAX
|
|
"READGSQ",
|
|
READGSQ,
|
|
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 RAX, GS:[RAX]
|
|
[]( 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.segment == ZYDIS_REGISTER_GS &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RAX;
|
|
},
|
|
// MOV [RBP], 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[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_RAX;
|
|
} } } };
|
|
|
|
vm::handler::profile_t readdw = {
|
|
// ADD RBP, 0x4
|
|
// MOV EAX, [RAX]
|
|
// MOV [RBP], EAX
|
|
"READDW",
|
|
READDW,
|
|
NULL,
|
|
{ { // ADD RBP, 0x4
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_ADD &&
|
|
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 == 0x4;
|
|
},
|
|
// MOV EAX, [RAX]
|
|
[]( 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_RAX;
|
|
},
|
|
// MOV [RBP], 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[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_EAX;
|
|
} } } };
|
|
|
|
vm::handler::profile_t readw = {
|
|
// MOV RAX, [RBP]
|
|
// ADD RBP, 0x6
|
|
// MOV AX, [RAX]
|
|
// MOV [RBP], AX
|
|
"READW",
|
|
READW,
|
|
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;
|
|
},
|
|
// ADD RBP, 0x6
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_ADD &&
|
|
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;
|
|
},
|
|
// MOV AX, [RAX]
|
|
[]( 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_RAX;
|
|
},
|
|
// MOV [RBP], 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[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_AX;
|
|
} } } };
|
|
|
|
vm::handler::profile_t readb = {
|
|
// MOV RDX, [RBP]
|
|
// ADD RBP, 0x6
|
|
// MOV [RBP], AX
|
|
"READB",
|
|
READB,
|
|
NULL,
|
|
{ { // MOV RDX, [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_RDX &&
|
|
instr.operands[ 1 ].type == ZYDIS_OPERAND_TYPE_MEMORY &&
|
|
instr.operands[ 1 ].mem.base == ZYDIS_REGISTER_RBP;
|
|
},
|
|
// ADD RBP, 0x6
|
|
[]( const zydis_decoded_instr_t &instr ) -> bool {
|
|
return instr.mnemonic == ZYDIS_MNEMONIC_ADD &&
|
|
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;
|
|
},
|
|
// MOV [RBP], 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[ 1 ].type == ZYDIS_OPERAND_TYPE_REGISTER &&
|
|
instr.operands[ 1 ].reg.value == ZYDIS_REGISTER_AX;
|
|
} } } };
|
|
} // namespace vm::handler::profile
|