Coder Social home page Coder Social logo

xx_tvm's Introduction

还原例子:

总所周知 ACE-BASE.sys 的DriverUnload函数是被vm了的,那么我们就用它来看看还原效果:

5

不错,很符合我对DriverUnload的想象。

左边 命名为 icxxx 的函数均为还原成功的函数。

deTvm.py脚本玩法

请先给你的idapython安装以下的库:

import capstone
import keystone
import copy

main0是对全部ida识别的函数进行特征分析,如果符合tvm函数特征,就对它进行还原。

可以算是一键还原全部tvm函数了,有可能有些tvm函数不符合特征,你也可以手动添加还原函数。

例如:

你知道一个函数0x140001250它是被vm的,那么你这么写,脚本就会自动特征识别V_RIP。

testTrace = traceTask(0x140001250,tvm0base)  	#tvm0base是tvm0段的起始地址
testTrace.track(0)								#开始跟踪 得到traceCode
testTrace.traceOut()							#输出原始traceCode

如果你这个被vm的函数不符合我写的特征,但它确实是tvm的函数,那么可以这么写,自己设置V_RIP:

#上一个例子的 函数 0x140001250 它的 V_RIP 就是 0x140059dc2
testTrace = traceTask(0,tvm0base)
testTrace.VStart = 0x140059dc2		#自己找这个vm函数的起始地址 例如V_RIP = 0x140059dc2 
testTrace.track(0)					#开始跟踪 得到traceCode
testTrace.traceOut()				#输出原始traceCode

traceOut(0)输出的结果如下:( 基本没做处理)

0

如果想看 对标记working的traceCode进行变量溯源的结果,你可以这么写:

testTrace = traceTask(0x140001250,tvm0base)  	#tvm0base是tvm0段的起始地址
testTrace.track(0)								#开始跟踪 得到traceCode
testTrace.VRegRecord(True)						#如果是False就是不使用标记(上文说过)
testTrace.tvmToAsmAll.printAll()				#输出

输出:

1

如果想进一步的进行变量传播优化还有 push、pop 优化,可以这么写:

testTrace = traceTask(0x140001250,tvm0base)  	#tvm0base是tvm0段的起始地址
testTrace.track(0)								#开始跟踪 得到traceCode
testTrace.VRegRecord(True)						#如果是False就是不使用标记(上文说过)
testTrace.tvmToAsmAll.optimizeAll()				#变量传播优化,push、pop优化
testTrace.tvmToAsmAll.printAll()				#输出

输出:

2

如果想看还原成 ASM是什么样的,可以这样写:

testTrace = traceTask(0x140001250,tvm0base)  	#tvm0base是tvm0段的起始地址
testTrace.track(0)								#开始跟踪 得到traceCode
testTrace.VRegRecord(True)						#如果是False就是不使用标记(上文说过)
testTrace.tvmToAsmAll.optimizeAll()				#变量传播优化,push、pop优化
testTrace.tvmToAsmAll.AllTvmAsmToAsm() 			#转换成ASM  注意,一定要VRegRecord + optimizeAll 后才可以调用
testTrace.tvmToAsmAll.printAsmAll()				#输出ASM

输出:

3

如果想看 tvmToAsm和Asm对应起来的输出,可以这样写:

testTrace = traceTask(0x140001250,tvm0base)  	#tvm0base是tvm0段的起始地址
testTrace.track(0)								#开始跟踪 得到traceCode
testTrace.VRegRecord(True)						#如果是False就是不使用标记(上文说过)
testTrace.tvmToAsmAll.optimizeAll()				#变量传播优化,push、pop优化
testTrace.tvmToAsmAll.AllTvmAsmToAsm() 			#转换成ASM

tvmToAsm_P = testTrace.tvmToAsmAll.tvmToAsmHead #结构为tvmToAsm
while (tvmToAsm_P != None):
    tvmToAsm_P.printAsm()                       #输出Asm
    tvmToAsm_P.print()                          #输出traceCodeAll
    print("")                                   #隔开
    tvmToAsm_P = tvmToAsm_P.BLink               #下一个

输出:

4

TVMHandleTrace.py

去混淆跟踪 tvm函数入口到出口,未对输入函数做处理。所以跟踪有调用输入表函数的tvm函数会出错。

TVMHandleOut.py

导出全部handle。

xx_tvm's People

Contributors

icey-999 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.