IDA批量模式 Python Script[fix]

#########################################
#Ida batch mode test code by obaby
#2012.03.13
#Mars Security
#http://www.h4ck.org.cn
#Email:root@h4ck.ws
#########################################
import sys
import os
import subprocess
 
# Fill these feilds with ur own ida file path and the idc file u want to execute!
idcScriptFileName = "batchmode.idc"
ida32qFilePath = '"F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\idaq.exe"'
ida64qFilePath = "F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\idaq64.exe"
ida32wFilePath ='"F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\idaw.exe"'
ida64wFilePath = "F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\idaw64.exe"
#The binary file list text 
TargetList = "F:/Python 2.6/_eric4project/idabatchmode/list.txt"
 
TargetFile_object = open(TargetList, "r").readlines()
for eachline in TargetFile_object:
    #print eachline, 
    #print eachline
    eachline = eachline.replace('\n','').replace('\r', '')
    if os.path.exists(eachline):
        tmpExecStr =  ida32wFilePath +" -A -c -S"+idcScriptFileName +" " + '"'+eachline+'"' #fixup the space in the file path
        print tmpExecStr, 
        #os.system(tmpExecStr) #singl process with cmdwindow
        #os.popen(tmpExecStr)  singl process without cmdwindow
        subprocess.Popen(tmpExecStr) #mulity process with cmd window
 
print ("All Process have been started!")

修正文件路径包含空格时找不到文件的问题,这个如果自己写的话应该是可以避免的。发现一个比较奇怪的问题,在win7下subprocess.Popen竟然不显示cmd窗口,但是在xp下显示。这是为什么? :8

IDA批量模式

整体说来ida的批量模式并不能算是真正的批量模式,只是可以通过各种手段来执行多个ida进行分析。众所周知ida是不支持多线程的,并且按照官方的说明看来在将来也不准备支持多线程。那么要想进行批量处理就只能使用自己的一些办法,自己去写个程序用命令来调用ida进行处理。

对于其他平台下的ida的批量模式这里并不准备介绍,简单的说一下Windows下的批量模式。如果用过ida的话应该比较清楚ida其实是提供了两种不同的界面,基于Gui的和基于Console的。两者都支持参数调用,但是命令行下的程序可以节省更多的资源,并且有更快的运行效率,如果同时运行数个ida那么建议使用命令行下的版本。

命令参数如下:

idag -A -Smyscript.idc input_file

官方的原始的idc脚本的内容是下面的样子:

static main()

{

RunPlugin("myplugin", 0); // run myplugin with argument 0

}

在执行脚本中调用了一个自定义的插件,那么其实这里也可以全部用脚本实现想要的功能。如果没有其他的要求可以把执行脚本锁定为analysis.idc,这个脚本会在文件分析完毕之后生成idb的数据库,并且生成相关的asm代码。需要注意的是这里的S和脚本之间没有空格,并且脚本的搜索目录为ida的安装目录下的idc文件夹,所以最好把自己的脚本放入这个文件夹下。

Continue Reading

Windows 7 Eric4 PySide环境配置

详细的配置看这里,配置好后主要是编写的ide看起来比较舒服一些。其余的没发现什么用处。而至于pyside的问题,还是和上一篇文章中提到的一样。只能在ida中使用,这个也是目前看起来比较糟糕的地方,但是比较幸运的是如果在eric中使用可以使用pyqt代替。 smile
Hello world:

import  sys  
from PyQt4.QtCore import *  
from PyQt4.QtGui import  *  
app = QApplication(sys.argv)  
label = QLabel("Hello World From PyQt4")  
label.show()  
app.exec_()  
sys.exit()  

IDA python.plw: can’t load file

完整的错误提示是下面的样子:


LoadLibrary(F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\plugins\python.plw) error: 找不到指定的模块。

F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\plugins\python.plw: can't load file

00:12:07 zynamics BinDiff 4.0.1 15146 (Dec 21 2011) - (c)2004-2011 Google Inc.

00:12:07 zynamics BinExport 5 15136 (Dec 21 2011) - (c)2004-2011 Google Inc.

LoadLibrary(F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\plugins\python.plw) error: 找不到指定的模块。

F:\Crackl@b\Hex-Rays.IDA.Pro.Advanced.v6.1\ida61\plugins\python.plw: can't load file
Continue Reading