From 30fa9b84c25483983420a3126eaa02431dad0139 Mon Sep 17 00:00:00 2001 From: _xeroxz Date: Mon, 31 May 2021 18:37:35 -0700 Subject: [PATCH] added writeq, writedw, and readq --- include/vmprofiler.hpp | 150 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) diff --git a/include/vmprofiler.hpp b/include/vmprofiler.hpp index 927809d..bdcd65f 100644 --- a/include/vmprofiler.hpp +++ b/include/vmprofiler.hpp @@ -33,11 +33,18 @@ namespace vm WRITEDW, WRITEW, + READQ, + READDW, + READW, + PUSHVSP, ADDQ, ADDDW, + MULQ, + DIVQ, + NANDQ, JMP, @@ -702,6 +709,145 @@ namespace vm } }; + inline vm::handler::profile_t writeq = + { + // MOV RAX, [RBP] + // MOV RDX, [RBP+0x8] + // ADD RBP, 0x10 + // MOV [RAX], RDX + "WRITEQ", WRITEQ, 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 RDX, [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_RDX && + instr.operands[1].type == ZYDIS_OPERAND_TYPE_MEMORY && + instr.operands[1].mem.base == ZYDIS_REGISTER_RBP && + instr.operands[1].mem.index == 0x8; + }, + // ADD RBP, 0x10 + [](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 == 0x10; + }, + // MOV [RAX], RDX + [](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_RAX && + instr.operands[1].type == ZYDIS_OPERAND_TYPE_REGISTER && + instr.operands[1].reg.value == ZYDIS_REGISTER_RDX; + } + } + } + }; + + inline vm::handler::profile_t writedw = + { + // MOV RAX, [RBP] + // MOV EDX, [RBP+0x8] + // ADD RBP, 0xC + // MOV [RAX], EDX + "WRITEDW", WRITEDW, 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 EDX, [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_EDX && + instr.operands[1].type == ZYDIS_OPERAND_TYPE_MEMORY && + instr.operands[1].mem.base == ZYDIS_REGISTER_RBP && + instr.operands[1].mem.index == 0x8; + }, + // ADD RBP, 0xC + [](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 == 0xC; + }, + // MOV [RAX], EDX + [](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_RAX && + instr.operands[1].type == ZYDIS_OPERAND_TYPE_REGISTER && + instr.operands[1].reg.value == ZYDIS_REGISTER_EDX; + } + } + } + }; + + inline 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; + } + } + } + }; + inline vm::handler::profile_t vmexit = { // MOV RAX, RBP @@ -741,6 +887,10 @@ namespace vm &addq, &adddw, + &writeq, &writedw, + + &readq, + &nandq, &jmp,