代码虚拟机入口、出口、handler(共有8个)分析
被虚拟化的两个关键函数的PCODE分析
Func_Check(int nPassword)(Virtualization)
VM_GetReg(ESP)
VM_SetReg(EAX)
VM_GetReg(EAX)
VM_GetData(0xC) //Get const
VM_Add(nil)
VM_AddEbp(0x4)
VM_GetSs(nil)//Get nPassword
VM_Not(nil)
VM_GetData(0xFE34FC32) //Get const
VM_Sub(nil)
VM_SetReg(EAX)
VM_SetReg(EBX)//Set $Result2
VM_GetReg(EAX)
VM_GetData(0x00333333)//Get const
VM_Sub(nil)
VM_SetReg(EAX)
VM_SetReg(EAX)//Set $Result1
Func_GetAnotherKey() (Virtualization)
VM_GetReg(ECX) //Get $Result1
VM_SetReg(EAX)
VM_GetReg(EAX)
VM_GetData(0x00333333) //Get const
VM_Add(nil)
VM_SetReg(EAX)
VM_SetReg(EAX)
VM_GetReg(EAX)
VM_GetData(0x28999529) //Get const VM_Add(nil)
VM_AddEbp(nil)
VM_GetData(0x00993221) //Get const
VM_Add(nil)
VM_AddEbp(nil)
VM_SetReg(EAX)//Set $AnotherKey
上面两个关键函数连起来,分析还原,得到以下等价伪代码
$Result2 = NOT($nPassword) - 0xFE34FC32
$Result1 = $(EFLAGS of$Result2) - 0x00333333
$AnotherKey = $Result1 +0x00333333 + 0x28999529 + 0x00993221
根据cmp esi,dword ptr ss:[ebp-0x1C]以及下面的je不成立执行Func_PrintWrong
推测出正确Key对应的$Result2应该被置为0
反推出
$nPassword = 30081997(0x01CB03CD)
$Result1 = 0x246 - 0x00333333 = 0xFFCCCF13
$AnotherKey = 0x2932C990