原文链接:http://bbs.pediy.com/showthread.php?t=137265

【详细过程】
   1.VM的解密算法
    一般情况下Code Virtualizer的解密有三个运算:add,sub,xor,有如下计算;
      loads/b/w/d
      operand eax/ax/al ebx/bx/bl         //与key进行计算
      operand eax/ax/al imm32/imm16/imm8  
      operand eax/ax/al imm32/imm16/imm8
      operand ebx/bx/bl eax/ax/al         //更新key
    其中esi指向pcode的数据,ebx为解码key,也就是进入虚拟机前压入堆栈的值:
      push xxxxxxxx      //解码key,正常等于esi
      jmp  VMStart
   2.方法
    让VM代码在emulator中执行,记录寄存器和堆栈状态,并HOOK相应的操作,应该可以得到pcode的id
   3.x86 emulator
    应该有好多,本次采用的是PyEmu,并结合IDA和IDAPython
   4.明文pcode的获取
   设置emulator初始环境,设置EIP,指向虚拟机取指令处,为了使emulator顺利执行,安装异常处理函数,当发现异常时记录异常状态,重设EIP,指向下一指令(有问题??),并在更新key处监视eax/ax/al的值,这就是明文pcode,对python不熟悉(缩进实在无语,有可能是我的编辑器有问题),这个emulator BUG多多,不可能完整跑下来,修改了几处,以dump_wmimmc.sys为例,简单测试了取指令:

代码:
import sys
sys.path.append(r'D:\reverse\IDA\python\pyemu')
sys.path.append(r'D:\reverse\IDA\python\pyemu\lib')
from PyEmu import *
emu = IDAPyEmu()
#debug=0,1,2,>2
emu.debug(0)
vlizer_start = SegByName(".reloc")
vlizer_end   = SegEnd( vlizer_start )
#load vlizer section
for i in range(vlizer_start,vlizer_end,4):
emu.set_memory(i,Dword(i))
print "[*] Finished loading vlizer section into memory,Start at %x,End at %x,size:%x"%(vlizer_start,vlizer_end,vlizer_end-vlizer_start)
flag=1
instack=0
#eip=fetchcode
emu.set_register("eip",0x10013bd6)
#ebx=key
emu.set_register("ebx",0x10018cca)
#esi=ebx+delta
emu.set_register("esi",0x10018cca)
#edi=vmctx+delta
emu.set_register("edi",0x10013880)
while True:
eip=emu.get_register("eip")
mnemonic=GetMnem(eip)
op1=GetOpnd(eip,0)
op2=GetOpnd(eip,1)
#push eax,ax
if mnemonic=="push":
if GetOpType(eip,0)==1 and GetOperandValue(eip,0)==0:
instack=1
#pop eax,ax
elif mnemonic=="pop":
if GetOpType(eip,0)==1 and GetOperandValue(eip,0)==0:
instack=0
#push eax,ax
#pop eax,ax
elif mnemonic=="mov":
if op1=="[esp]":
if GetOpType(eip,1)==1 and GetOperandValue(eip,1)==0:
instack=1
elif op2=="[esp]":
if GetOpType(eip,0)==1 and GetOperandValue(eip,0)==0:
instack=0
elif mnemonic=="add" or mnemonic=="sub" or mnemonic=="xor":
if  GetOpType(eip,0)==1 and (GetOperandValue(eip,0)==0 or GetOperandValue(eip,0)==0x10):
#operand eax/ax/al ebx/bx/bl
if GetOpType(eip,1)==1 and (GetOperandValue(eip,1)==3 or GetOperandValue(eip,1)==0x13) and flag:
print "%s %s,%s"%(mnemonic,op1,op2)
flag=0
#operand eax/ax/al imm32/imm16/imm8
else:
if not instack:
if GetOpType(eip,1)==1:
print "%s %s,%x"%(mnemonic,op1,emu.get_register(op2))
elif GetOpType(eip,1)==5:
print "%s %s,%x"%(mnemonic,op1,GetOperandValue(eip,1))
#operand ebx/bx/bl eax/ax/al
if (GetOpType(eip,0)==1 and (GetOperandValue(eip,0)==3 or GetOperandValue(eip,0)==0x13)) and (GetOpType(eip,1)==1 and (GetOperandValue(eip,1)==0 or GetOperandValue(eip,1)==0x10)):
print "%s %s,%s"%(mnemonic,op1,op2)
print "handleindex:%x"%emu.get_register("eax")
break
emu.execute()

输出:
    sub al,e9
    add al,bl
    add al,e9
    xor al,d2
    sub al,f1
    add bl,al
    handleindex:2d
 最后清理后的取指令为:
    loadsb
    add al,bl
    xor al,d2
    sub al,f1
    add bl,al
    movzx eax,al
    jmp dword ptr [edi+eax*4]
  测试可行,起个抛砖引玉的作用。

关于Code Virtualizer pcode解密的一种方法相关推荐

  1. python字符串解密代码,python字符串加密解密的三种方法分享(base64 win32com)

    1. 最简单的方法是用base64: import base64 s1 = base64.encodestring('hello world') s2 = base64.decodestring(s1 ...

  2. Base64加密与解密的三种方法

    前言: 加密与解密一直是程序猿经常需要面对的东东,下面了解一下常见的base64的三种加密与解密的方法. public static final String str="zhangtao&q ...

  3. web.config/app.config敏感数据加/解密的二种方法

    一.利用代码加解密 using System.Web.Configuration;      //加密web.Config中的指定节     private void ProtectSection(s ...

  4. visual studio code无法连接网络,五种方法

    1:visual s studio code现在无法连接到扩展商店,请稍后再试 2:visual s studio code无法连接网络 解决方法一: 1:设置代理 代理1:自己的局域网代理ip,需要 ...

  5. python隐藏手机号码程序_Python网站手机号码解密的一种方法

    黄页88网站反爬措施对手机号进行了一些加密处理.这里介绍一下怎么解密手机号码的方法. 首先,我们看一下网站显示的手机号是这样的: 显示的手机号 使用ctrl c复制粘贴后变成了这样: 复制后的手机号码 ...

  6. 再谈web.config/app.config敏感数据加/解密的二种方法

      转载请注明来自"菩提树下的杨过"-http://www.cnblogs.com/yjmyzz/archive/2008/08/22/1274395.html 1.利用代码加解密 ...

  7. java map初始化方式_java中Map和List初始化的两种方法

    第一种方法(常用方法): //初始化List List list = new ArrayList(); list.add("string1"); list.add("st ...

  8. swoolephp加密_PHP中给源代码加密的几种方法

    商业使用推荐 Swoole Compiler 代码加密 以下是如何通过PHP的自定义函数来加密我们的PHP源代码 方法一 function encode_file_contents($filename ...

  9. JavaScript加密解密7种方法!

    本文一共介绍了七种JAVASCRIPT加密方法: 在做网页时(其实是网页木马呵呵),最让人烦恼的是自己辛辛苦苦写出来的客户端IE运行的JAVASCRIPT代码常常被别人轻易的拷贝,实在让自己的心里有点 ...

最新文章

  1. Linux 网络编程—— libpcap 详解
  2. UNIX环境高级编程 第12章 线程控制
  3. JavaScript的Cookie操作
  4. 文本编辑器中替换对话框的设计与实现
  5. Vue 动态路由的实现以及 Springsecurity 按钮级别的权限控制
  6. crontab 详细用法 定时任务
  7. Linux glibc内存管理:用户态内存分配器——ptmalloc实现原理
  8. 学习笔记(21):Python网络编程并发编程-队列的使用
  9. 【渝粤教育】国家开放大学2018年春季 7397-21T家庭教育咨询与辅导 参考试题
  10. Bitmap尺度变换
  11. 520送你一份WebStorm的主题包,附带使用图文教程
  12. 演义群侠传(五)【素材方式MC or SpriteSheet】
  13. mysql 运维常见操作
  14. SAP License:SAP实施应该建立扁平化组织结构
  15. JFlash 对Flash内容读取
  16. Scrapy 链家网爬取(存储到MySQL、json、xlsx)
  17. 笔记本开机循环显示:this product is covered by one or more of the following patents 解决办法
  18. html左右箭头翻页代码,左右箭头图片_js实现图片上显示左右箭头类似翻页效果的代码...
  19. L2-036 网红点打卡攻略
  20. 连续时间 Markov 链从某一状态 i 转移到其他状态之前在 i 逗留的时间服从指数分布

热门文章

  1. 如何用一个makefile编译多个目标
  2. 让进度条颜色渐变的shader
  3. 从零到一学习计算机视觉:朋友圈爆款背后的计算机视觉技术与应用 | 公开课笔记...
  4. mysql 1033 Incorrect information in file 错误
  5. 这些独家记忆串成我们的2022
  6. Context-free grammar 与 BNF,ASN.1
  7. 线性回归,逻辑回归个人总结
  8. 教妹学Java(十四):switch 语句详解
  9. Midjourney 文本转图片接口请求参数
  10. ccf 3. 缺席考试的是谁?(难度3)