-
-
[原创][原创]基于QT的IDA python插件
-
发表于:
2015-12-4 21:18
6076
-
[原创][原创]基于QT的IDA python插件
工作之后鲜有时间空余,上论坛且是奢侈,遑论发贴。
那么直入主题,这是一个辅助建立结构体的小插件,近来用得较多,有此一闲便分享出来,以飨看官。
注:请自备PySide
代码
import sys
import traceback
import idc
from PySide import QtGui
from PySide import QtCore
from PySide.QtCore import Qt
def addstruc(name,size):
id=AddStrucEx(-1,name,0)
AddStrucMember(id,"vtbl",0,0x20000400,-1,4)
i=4
length=size-1
for i in range(length):
AddStrucMember(id,"field_"+str(hex(i))[2:].upper(),i,FF_DWRD,-1,4)
print "Done"
class MakeUserStruct(QtGui.QDialog):
def on_ok_button(self):
self.done(QtGui.QDialog.Accepted)
name=self.nameText.text()
size=self.sizeText.text()
addstruc(name.encode("ascii"),int(size.encode("ascii")))
idaapi.set_script_timeout(0)
def populate_form(self):
layout=QtGui.QVBoxLayout()
strinfo="this plugin will help you create a struct"
layout.addWidget(QtGui.QLabel(strinfo))
# struct
stlayout=QtGui.QHBoxLayout()
self.nameText=QtGui.QLineEdit()
self.nameText.setReadOnly(False)
stlayout.addWidget(self.nameText)
self.sizeText=QtGui.QLineEdit()
self.sizeText.setReadOnly(False)
stlayout.addWidget(self.sizeText)
groupBox=QtGui.QGroupBox("please input name && size")
groupBox.setLayout(stlayout)
layout.addWidget(groupBox)
# button
buttonOk=QtGui.QPushButton("&OK")
buttonOk.setDefault(True)
buttonOk.clicked.connect(self.on_ok_button)
layout.addWidget(buttonOk)
buttonCel=QtGui.QPushButton("&Cancel")
buttonCel.clicked.connect(self.on_ok_button)
layout.addWidget(buttonCel)
# setup
hlayout=QtGui.QHBoxLayout()
hlayout.addLayout(layout)
self.setLayout(hlayout)
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
self.setWindowTitle("Make User Struct")
self.populate_form()
if __name__ == '__main__':
dlg = MakeUserStruct()
t = idaapi.set_script_timeout(0)
dlg.exec_()
idaapi.set_script_timeout(t)
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!