-141 Removals
+600 Additions
# Created by Storm Shadow www.techbliss.org# Created by Storm Shadow www.techbliss.org
print "\n" #getting the box fit
print " ###################################################\n" \
" # Author Storm Shadow # \n" \
" # Hotkeys # \n" \
" # NewFile: Ctrl+N #\n" \
" # OpenFile: Ctrl+O #\n" \
" # SaveFile: Ctrl+S #\n" \
" # RunScript: Ctrl+E #\n" \
" # Undo: Ctrl+Z #\n" \
" # Redo: Ctrl+Y #\n" \
" # SelectALL: Ctrl+A #\n" \
" # Paste: Ctrl+V #\n" \
" # Font: Ctrl+F #\n" \
" # ResetFolding: Ctrl+R #\n" \
" # CircleFolding: Ctrl+C #\n" \
" # PlainFolding: Ctrl+P #\n" \
" # HEX-ray Home: Ctrl+W #\n" \
" # Ida Pro Python SDK Ctrl+I #\n" \
" # IDAPROPythonGit: Ctrl+G #\n" \
" # Author: Ctrl+B #\n" \
" # Enable Reg: Alt+E #\n" \
" # Disable Reg: Alt+D #\n" \
" # Zoom in Ctrl+Shift+ + #\n" \
" # Zoom Out Ctrl+Shift+ - #\n" \
" # Profile Code Ctrl+Shift+ E #\n" \
" ###################################################\n" \
" # IDA PRO python Editor #\n" \
" ###################################################\n"
import os
import sysimport sys
APP_TITLE = "IDA Pro Python Editor"try:
dn = idaapi.idadir("plugins\\Code editor")
except NameError:
dn = os.getcwd()
sys.path.insert(0, dn)
sys.path.insert(0, os.getcwd()+r'\icons')
# print (" %s ".center(len(APP_TITLE) + 3, "#") % APP_TITLE)from PyQt4 import QtCore, QtGui
from PyQt4.Qsci import QsciScintilla, QsciLexerPython
from PyQt4.QtGui import *
from PyQt4.QtCore import QTextStream
from PyQt4.QtCore import qDebug
'''try:
import ico
except ImportError:
import icons.ico
try:
import iconsmore
except ImportError:
import icons.iconsmore
try:
import icons3
except ImportError:
import icons.icons3
try:
import iconf
except ImportError:
import icons.iconf
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
ARROW_MARKER_NUM = 8
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(640, 480)
self.vindu = QtGui.QWidget(MainWindow)
self.vindu.setStyleSheet(_fromUtf8('notusedasyet'))
#MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.filename = ""
self.vindu.closeEvent = self.closeEvent
self.vindu.setObjectName(_fromUtf8("vindu"))
self.verticalLayout = QtGui.QVBoxLayout(self.vindu)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/ico/python.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
MainWindow.setWindowIcon(icon)
self.verticalLayout.setMargin(0)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.codebox = Qsci.QsciScintilla(self.vindu)
self.codebox.setToolTip(_fromUtf8(""))
self.codebox.setWhatsThis(_fromUtf8(""))
self.codebox.setAutoFillBackground(False)
self.codebox.setFrameShape(QtGui.QFrame.NoFrame)
self.codebox.setObjectName(_fromUtf8("codebox"))
self.verticalLayout.addWidget(self.codebox)
MainWindow.setCentralWidget(self.vindu)
self.toolBar = QtGui.QToolBar(MainWindow)
self.toolBar.setAutoFillBackground(False)
self.toolBar.setIconSize(QtCore.QSize(32, 32))
self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.toolBar.setObjectName(_fromUtf8("toolBar"))
MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar)
self.toolBar.addSeparator()
#getting ready for debugger
self.codebox.setMarginSensitivity(1, True)
self.codebox.connect(self.codebox, QtCore.SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'), self.on_margin_clicked)
self.codebox.markerDefine(QsciScintilla.FullRectangle, self.ARROW_MARKER_NUM)
self.codebox.setMarkerBackgroundColor(QColor("#ee1111"), self.ARROW_MARKER_NUM)
#first action Newfile
self.toolBar.newAction = QtGui.QAction(QtGui.QIcon(":/ico/new.png"),"New",self.toolBar)
self.toolBar.newAction.setStatusTip("Clear TextBox or make new document.")
self.toolBar.newAction.setShortcut("Ctrl+N")
self.toolBar.newAction.triggered.connect(self.newfile)
#second Action OpenFile
self.toolBar.secondAction = QtGui.QAction(QtGui.QIcon(":/ico/open.png"),"Open",self.toolBar)
self.toolBar.secondAction.setStatusTip("Create a new document from scratch.")
self.toolBar.secondAction.setShortcut("Ctrl+O")
self.toolBar.secondAction.triggered.connect(self.open)
# action 3 save file
self.toolBar.Action3 = QtGui.QAction(QtGui.QIcon(":/ico/save.png"),"Save",self.toolBar)
self.toolBar.Action3.setStatusTip("Save Your File.")
self.toolBar.Action3.setShortcut("Ctrl+S")
self.toolBar.Action3.triggered.connect(self.savefile)
#action 4 run file
self.toolBar.Action4 = QtGui.QAction(QtGui.QIcon(":/ico/run32.png"),"Run To Debugger",self.toolBar)
self.toolBar.Action4.setStatusTip("Run your file within debugger.")
self.toolBar.Action4.setShortcut("Ctrl+E")
self.toolBar.Action4.triggered.connect(self.runto)
#action 6 undo
self.toolBar.Action6 = QtGui.QAction(QtGui.QIcon(":/ico/undo.png"),"Redo",self.toolBar)
self.toolBar.Action6.setStatusTip("Undo.")
self.toolBar.Action6.setShortcut("Ctrl+Z")
self.toolBar.Action6.triggered.connect(self.codebox.undo)
#action 7 redo
self.toolBar.Action7 = QtGui.QAction(QtGui.QIcon(":/ico/redo.png"),"Redo",self.toolBar)
self.toolBar.Action7.setStatusTip("Redo.")
self.toolBar.Action7.setShortcut("Ctrl+Y")
self.toolBar.Action7.triggered.connect(self.codebox.redo)
#action8 rerset Folding
self.toolBar.Action8 = QtGui.QAction(QtGui.QIcon(":/ico/align-justify.png"),"Reset Folding",self.toolBar)
self.toolBar.Action8.setStatusTip("Reset Folding.")
self.toolBar.Action8.setShortcut("Ctrl+R")
self.toolBar.Action8.triggered.connect(self.nofoldingl)
#actions9 CircledTreeFoldStyle
self.toolBar.Action9 = QtGui.QAction(QtGui.QIcon(":/ico/bullet.png"),"Circled Tree Folding",self.toolBar)
self.toolBar.Action9.setStatusTip("Circled Tree Folding.")
self.toolBar.Action9.setShortcut("Ctrl+C")
self.toolBar.Action9.triggered.connect(self.Circledfold)
#actions10 plainFoldStyle
self.toolBar.Action10 = QtGui.QAction(QtGui.QIcon(":/ico/number.png"),"Plain Folding",self.toolBar)
self.toolBar.Action10.setStatusTip("Plain Folding")
self.toolBar.Action10.setShortcut("Ctrl+P")
self.toolBar.Action10.triggered.connect(self.plainfold)
# fonts
self.toolBar.Action21 = QtGui.QAction(QtGui.QIcon(":/ico4/font.png"), "Fonts", self.toolBar)
self.toolBar.Action21.setStatusTip("Fonts")
self.toolBar.Action21.setShortcut("Ctrl+F")
self.toolBar.Action21.triggered.connect(self.font_choice)
#web baby
self.toolBar.Action11 = QtGui.QAction(QtGui.QIcon(":/ico/web.png"),"Hex-rays Homepage",self.toolBar)
self.toolBar.Action11.setStatusTip("Home of Hex-rays")
self.toolBar.Action11.setShortcut("Ctrl+W")
self.toolBar.Action11.triggered.connect(self.webopen)
#irc
self.toolBar.Action12 = QtGui.QAction(QtGui.QIcon(":/ico3/settings.png"),"Open Ida Pro Python SDK",self.toolBar)
self.toolBar.Action12.setStatusTip("Ida Pro Python SDK")
self.toolBar.Action12.setShortcut("Ctrl+I")
self.toolBar.Action12.triggered.connect(self.sdkopen)
#github Python
self.toolBar.Action14 = QtGui.QAction(QtGui.QIcon(":/ico/github.png"),"Open git python",self.toolBar)
self.toolBar.Action14.setStatusTip("Open git python")
self.toolBar.Action14.setShortcut("Ctrl+G")
self.toolBar.Action14.triggered.connect(self.gitopen)
#auther me :)
self.toolBar.Action15 = QtGui.QAction(QtGui.QIcon(":/ico/auth.png"),"Author",self.toolBar)
self.toolBar.Action15.setStatusTip("Author")
self.toolBar.Action15.setShortcut("Ctrl+B")
self.toolBar.Action15.triggered.connect(self.Author)
#toggle off code regonision
self.toolBar.Action16 = QtGui.QAction(QtGui.QIcon(":/ico2/pythonminus.png"),"Disable Code recognition",self.toolBar)
self.toolBar.Action16.setStatusTip("Disable Code recognition")
self.toolBar.Action16.setShortcut("Alt+D")
self.toolBar.Action16.triggered.connect(self.Diablecode)
#toogle on
self.toolBar.Action17 = QtGui.QAction(QtGui.QIcon(":/ico2/pypluss.png"),"Enable Code recognition",self.toolBar)
self.toolBar.Action17.setStatusTip("Enable Code recognition")
self.toolBar.Action17.setShortcut("Alt+E")
self.toolBar.Action17.triggered.connect(self.Reiablecode)
# zoom in
self.toolBar.Action18 = QtGui.QAction(QtGui.QIcon(":/ico3/in.png"),"Zoom In",self.toolBar)
self.toolBar.Action18.setStatusTip("Zoom In")
self.toolBar.Action18.setShortcut("CTRL+SHIFT++")
self.toolBar.Action18.triggered.connect(self.udder)
#zoom out
self.toolBar.Action19 = QtGui.QAction(QtGui.QIcon(":/ico3/out.png"),"Zoom Out",self.toolBar)
self.toolBar.Action19.setStatusTip("Zoom Out")
self.toolBar.Action19.setShortcut("CTRL+SHIFT+-")
self.toolBar.Action19.triggered.connect(self.odder)
self.toolBar.Action20 = QtGui.QAction(QtGui.QIcon(":/ico3/10.png"),"Profile Code",self.toolBar)
self.toolBar.Action20.setStatusTip("Profile Code")
self.toolBar.Action20.setShortcut("CTRL+SHIFT+E")
self.toolBar.Action20.triggered.connect(self.runtoprob)
#actions
self.toolBar.addAction(self.toolBar.newAction)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.secondAction)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action3)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action4)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action6)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action7)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action8)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action9)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action10)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action21)
self.toolBar.addSeparator()
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action11)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action12)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action14)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action15)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action16)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action17)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action18)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action19)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action20)
#font
self.skrift = QFont()
self.skrift.setFamily('Consolas')
self.skrift.setFixedPitch(True)
self.skrift.setPointSize(12)
self.codebox.setFont(self.skrift)
#python style
self.lexer = QsciLexerPython(self.codebox)
self.lexer.setFont(self.skrift)
self.lexer.setEolFill(True)
#api test not working
api = Qsci.QsciAPIs(self.lexer)
API_FILE = dn+'\\Python.api'
API_FILE2 = dn+'\\idc.api'
API_FILE3 = dn+'\\idaapi.api'
api.load(API_FILE)
api.load(API_FILE2)
api.load(API_FILE3)
api.prepare()
self.codebox.setAutoCompletionThreshold(0)
self.codebox.setAutoCompletionThreshold(6)
self.codebox.setAutoCompletionThreshold(8)
self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
self.lexer.setDefaultFont(self.skrift)
self.codebox.setLexer(self.lexer)
self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Consolas')
#line numbers
fontmetrics = QFontMetrics(self.skrift)
self.codebox.setMarginsFont(self.skrift)
self.codebox.setMarginWidth(0, fontmetrics.width("0000") + 6)
self.codebox.setTabWidth(4)
#brace
self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch)
#auto line tab =4
self.codebox.setAutoIndent(True)
#scroolbar
self.codebox.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.lbl = self.codebox
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "Ida Pro Python Script Editor", None))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))
def udder(self):
self.codebox.zoomIn()
def odder(self):
self.codebox.zoomOut()
def newfile(self):
self.codebox.clear()
def open(self):
self.path = QtCore.QFileInfo(self.filename).path()
# Get filename and show only .writer files
self.filename = QtGui.QFileDialog.getOpenFileName(
self.vindu, 'Open File', self.path, "Python Files (*.py *.pyc *.pyw)",
'')
if self.filename:
with open(self.filename,"r") as self.file:
self.codebox.setText(self.file.read())
os.chdir(str(self.path))
def fontFamily(self,font):
self.text.setCurrentFont(font)
def fontSize(self, fontsize):
self.text.setFontPointSize(int(fontsize))
def fontFamily(self,font):
self.codebox.text.setCurrentFont(font)
def fontSize(self, fontsize):
self.codebox.text.setFontPointSize(int(fontsize))
def savefile(self):
self.path = QtCore.QFileInfo(self.filename).path()
self.filename = QtGui.QFileDialog.getSaveFileName(
self.vindu, "Save as", self.path, "Python Files (*.py *.pyc *.pyw)",
)
if self.filename:
self.savetext(self.filename)
os.chdir(str(self.path))
def savetext(self, fileName):
textout = self.codebox.text()
file = QtCore.QFile(fileName)
if file.open(QtCore.QIODevice.WriteOnly):
QtCore.QTextStream(file) << textout
else:
QtGui.QMessageBox.information(self.vindu, "Unable to open file",
file.errorString())
os.chdir(str(self.path))
def runto(self):
try:
self.path = QtCore.QFileInfo(self.filename).path()
except AttributeError:
pass
g = globals()
os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
script = str(self.codebox.text())
try:
exec (script, g)
QtGui.QCloseEvent()
except ImportError:
os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
sys.path.append(str(self.path))
exec (script, g)
QtGui.QCloseEvent()
if TypeError (QTextStream):
g = globals()
os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
sys.path.insert(0, str(self.path))
exec int(script)
QtGui.QCloseEvent()
def runtoprob(self):
try:
self.path = QtCore.QFileInfo(self.filename).path()
except AttributeError:
pass
self.path = QtCore.QFileInfo(self.filename).path()
g = globals()
os.chdir(str(self.path))
script = str(self.codebox.text())
import cProfile
cProfile.run(script)
def Diablecode(self):
self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsNone)
def Reiablecode(self):
self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
def nofoldingl(self):
self.codebox.setFolding(QsciScintilla.NoFoldStyle)
def Circledfold(self):
self.codebox.setFolding(QsciScintilla.CircledTreeFoldStyle)
def plainfold(self):
self.codebox.setFolding(QsciScintilla.PlainFoldStyle)
def webopen(self):
import webbrowser
webbrowser.open('https://www.hex-rays.com/')
def sdkopen(self):
import webbrowser
webbrowser.open('https://www.hex-rays.com/products/ida/support/idapython_docs/')
def gitopen(self):
import webbrowser
webbrowser.open('https://github.com/idapython/src/tree/build-1.7.2')
def Author(self):
import webbrowser
webbrowser.open('https://github.com/techbliss')
def closeEvent(self, event):
print("event")
reply = QtGui.QMessageBox.question(self, 'Message',
"Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
def font_choice(self):
self.lbl = self.lexer
font, ok = QtGui.QFontDialog.getFont()
if ok:
self.lbl.setFont(font)
def on_margin_clicked(self, nmargin, nline, modifiers):
# Toggle marker for the line the margin was clicked on
if self.codebox.markersAtLine(nline) != 0:
self.codebox.markerDelete(nline, self.ARROW_MARKER_NUM)
else:
self.codebox.markerAdd(nline, self.ARROW_MARKER_NUM)
from PyQt4 import Qsci
if __name__ == "__main__":
import sys
app = QtGui.QApplication.instance() # We add this so we can use editor outside Ida
if not app:
app = QtGui.QApplication([])
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
MainWindow.resize(1000, 600)
if app.exec_():
os.chdir(dn)# Created by Storm Shadow www.techbliss.org
# Created by Storm Shadow www.techbliss.org
print "\n" #getting the box fitprint "\n" #getting the box fit
print " ###################################################\n" \print " ###################################################\n" \
" # Author Storm Shadow # \n" \ " # Author Storm Shadow # \n" \
" # Hotkeys # \n" \ " # Hotkeys # \n" \
" # NewFile: Ctrl+N #\n" \ " # NewFile: Ctrl+N #\n" \
" # OpenFile: Ctrl+O #\n" \ " # OpenFile: Ctrl+O #\n" \
" # SaveFile: Ctrl+S #\n" \ " # SaveFile: Ctrl+S #\n" \
" # RunScript: Ctrl+E #\n" \ " # RunScript: Ctrl+E #\n" \
" # Undo: Ctrl+Z #\n" \ " # Undo: Ctrl+Z #\n" \
" # Redo: Ctrl+Y #\n" \ " # Redo: Ctrl+Y #\n" \
" # SelectALL: Ctrl+A #\n" \ " # SelectALL: Ctrl+A #\n" \
" # Paste: Ctrl+V #\n" \ " # Paste: Ctrl+V #\n" \
" # Font: Ctrl+F #\n" \
" # ResetFolding: Ctrl+R #\n" \ " # ResetFolding: Ctrl+R #\n" \
" # CircleFolding: Ctrl+C #\n" \ " # CircleFolding: Ctrl+C #\n" \
" # PlainFolding: Ctrl+P #\n" \ " # PlainFolding: Ctrl+P #\n" \
" # HEX-ray Home: Ctrl+W #\n" \ " # HEX-ray Home: Ctrl+W #\n" \
" # IDA Pro Python SDK Ctrl+I #\n" \ " # Ida Pro Python SDK Ctrl+I #\n" \
" # IDAPROPythonGit: Ctrl+G #\n" \ " # IDAPROPythonGit: Ctrl+G #\n" \
" # Author: Ctrl+B #\n" \ " # Author: Ctrl+B #\n" \
" # Enable Reg: Alt+E #\n" \ " # Enable Reg: Alt+E #\n" \
" # Disable Reg: Alt+D #\n" \ " # Disable Reg: Alt+D #\n" \
" # Zoom in Ctrl+Shift+ + #\n" \ " # Zoom in Ctrl+Shift+ + #\n" \
" # Zoom Out Ctrl+Shift+ - #\n" \ " # Zoom Out Ctrl+Shift+ - #\n" \
" # Profile Code Ctrl+Shift+ E #\n" \ " # Profile Code Ctrl+Shift+ E #\n" \
" ###################################################\n" \ " ###################################################\n" \
" # IDA Pro python Editor #\n" \ " # IDA PRO python Editor #\n" \
" ###################################################\n" " ###################################################\n"
'''
import osimport os
import sysimport sys
try:try:
dn = idaapi.idadir("plugins\\Code editor") dn = idaapi.idadir("plugins\\Code editor")
except NameError:except NameError:
dn = os.getcwd() dn = os.getcwd()
sys.path.insert(0, dn)sys.path.insert(0, dn)
sys.path.insert(0, os.getcwd()+r'\icons')sys.path.insert(0, os.getcwd()+r'\icons')
from PyQt4 import QtCore, QtGuifrom PyQt4 import QtCore, QtGui
from PyQt4.Qsci import QsciScintilla, QsciLexerPythonfrom PyQt4.Qsci import QsciScintilla, QsciLexerPython
from PyQt4.QtGui import *from PyQt4.QtGui import *
from PyQt4.QtCore import QTextStreamfrom PyQt4.QtCore import QTextStream
from PyQt4.QtCore import qDebugfrom PyQt4.QtCore import qDebug
try:try:
import ico import ico
except ImportError:except ImportError:
import icons.ico import icons.ico
try:try:
import iconsmore import iconsmore
except ImportError:except ImportError:
import icons.iconsmore import icons.iconsmore
try:try:
import icons3 import icons3
except ImportError:except ImportError:
import icons.icons3 import icons.icons3
try:try:
import iconf
except ImportError:
import icons.iconf
try:
_fromUtf8 = QtCore.QString.fromUtf8 _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:except AttributeError:
def _fromUtf8(s): def _fromUtf8(s):
return s return s
try:try:
_encoding = QtGui.QApplication.UnicodeUTF8 _encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig): def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding) return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:except AttributeError:
def _translate(context, text, disambig): def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig) return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):class Ui_MainWindow(object):
def __init__(self): ARROW_MARKER_NUM = 8
self.icon = None
self.filename = ""
self.prev_textout = ""
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(640, 480) MainWindow.resize(640, 480)
self.vindu = QtGui.QWidget(MainWindow) self.vindu = QtGui.QWidget(MainWindow)
self.vindu.setStyleSheet(_fromUtf8('notusedasyet')) self.vindu.setStyleSheet(_fromUtf8('notusedasyet'))
#MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) #MainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.filename = "" self.filename = ""
self.vindu.closeEvent = self.closeEvent
self.vindu.setObjectName(_fromUtf8("vindu")) self.vindu.setObjectName(_fromUtf8("vindu"))
self.verticalLayout = QtGui.QVBoxLayout(self.vindu) self.verticalLayout = QtGui.QVBoxLayout(self.vindu)
icon = QtGui.QIcon()
self.icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/ico/python.png")), QtGui.QIcon.Normal, QtGui.QIcon.On)
self.icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/ico/python.png")), QtGui.QIcon.Normal, QtGui.QIcon.On) MainWindow.setWindowIcon(icon)
MainWindow.setWindowIcon(self.icon)
self.verticalLayout.setMargin(0) self.verticalLayout.setMargin(0)
self.verticalLayout.setSpacing(0) self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.codebox = Qsci.QsciScintilla(self.vindu) self.codebox = Qsci.QsciScintilla(self.vindu)
self.codebox.setToolTip(_fromUtf8("")) self.codebox.setToolTip(_fromUtf8(""))
self.codebox.setWhatsThis(_fromUtf8("")) self.codebox.setWhatsThis(_fromUtf8(""))
self.codebox.setAutoFillBackground(False) self.codebox.setAutoFillBackground(False)
self.codebox.setFrameShape(QtGui.QFrame.NoFrame) self.codebox.setFrameShape(QtGui.QFrame.NoFrame)
self.codebox.setObjectName(_fromUtf8("codebox")) self.codebox.setObjectName(_fromUtf8("codebox"))
self.verticalLayout.addWidget(self.codebox) self.verticalLayout.addWidget(self.codebox)
MainWindow.setCentralWidget(self.vindu) MainWindow.setCentralWidget(self.vindu)
self.toolBar = QtGui.QToolBar(MainWindow) self.toolBar = QtGui.QToolBar(MainWindow)
self.toolBar.setAutoFillBackground(False) self.toolBar.setAutoFillBackground(False)
self.toolBar.setIconSize(QtCore.QSize(32, 32)) self.toolBar.setIconSize(QtCore.QSize(32, 32))
self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly) self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
self.toolBar.setObjectName(_fromUtf8("toolBar")) self.toolBar.setObjectName(_fromUtf8("toolBar"))
MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar) MainWindow.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolBar)
self.toolBar.addSeparator() self.toolBar.addSeparator()
#getting ready for debugger
self.codebox.setMarginSensitivity(1, True)
self.codebox.connect(self.codebox, QtCore.SIGNAL('marginClicked(int, int, Qt::KeyboardModifiers)'), self.on_margin_clicked)
self.codebox.markerDefine(QsciScintilla.FullRectangle, self.ARROW_MARKER_NUM)
self.codebox.setMarkerBackgroundColor(QColor("#ee1111"), self.ARROW_MARKER_NUM)
#first action Newfile #first action Newfile
self.toolBar.newAction = QtGui.QAction(QtGui.QIcon(":/ico/new.png"),"New",self.toolBar) self.toolBar.newAction = QtGui.QAction(QtGui.QIcon(":/ico/new.png"),"New",self.toolBar)
self.toolBar.newAction.setStatusTip("Clear TextBox or make new document.") self.toolBar.newAction.setStatusTip("Clear TextBox or make new document.")
#self.toolBar.newAction.setShortcut("Ctrl+N") self.toolBar.newAction.setShortcut("Ctrl+N")
self.toolBar.newAction.triggered.connect(self.newfile) self.toolBar.newAction.triggered.connect(self.newfile)
#second Action OpenFile #second Action OpenFile
self.toolBar.secondAction = QtGui.QAction(QtGui.QIcon(":/ico/open.png"),"Open",self.toolBar) self.toolBar.secondAction = QtGui.QAction(QtGui.QIcon(":/ico/open.png"),"Open",self.toolBar)
self.toolBar.secondAction.setStatusTip("Create a new document from scratch.") self.toolBar.secondAction.setStatusTip("Create a new document from scratch.")
#self.toolBar.secondAction.setShortcut("Ctrl+O") self.toolBar.secondAction.setShortcut("Ctrl+O")
self.toolBar.secondAction.triggered.connect(self.open) self.toolBar.secondAction.triggered.connect(self.open)
# action 3 save file # action 3 save file
self.toolBar.Action3 = QtGui.QAction(QtGui.QIcon(":/ico/save.png"),"Save",self.toolBar) self.toolBar.Action3 = QtGui.QAction(QtGui.QIcon(":/ico/save.png"),"Save",self.toolBar)
self.toolBar.Action3.setStatusTip("Save Your File.") self.toolBar.Action3.setStatusTip("Save Your File.")
#self.toolBar.Action3.setShortcut("Ctrl+S") self.toolBar.Action3.setShortcut("Ctrl+S")
self.toolBar.Action3.triggered.connect(self.savefile) self.toolBar.Action3.triggered.connect(self.savefile)
#action 4 run file #action 4 run file
self.toolBar.Action4 = QtGui.QAction(QtGui.QIcon(":/ico/run32.png"),"Run To Debugger",self.toolBar) self.toolBar.Action4 = QtGui.QAction(QtGui.QIcon(":/ico/run32.png"),"Run To Debugger",self.toolBar)
self.toolBar.Action4.setStatusTip("Run your file within debugger.") self.toolBar.Action4.setStatusTip("Run your file within debugger.")
#self.toolBar.Action4.setShortcut("Ctrl+E") self.toolBar.Action4.setShortcut("Ctrl+E")
self.toolBar.Action4.triggered.connect(self.runto) self.toolBar.Action4.triggered.connect(self.runto)
#action 6 undo #action 6 undo
self.toolBar.Action6 = QtGui.QAction(QtGui.QIcon(":/ico/undo.png"),"Redo",self.toolBar) self.toolBar.Action6 = QtGui.QAction(QtGui.QIcon(":/ico/undo.png"),"Redo",self.toolBar)
self.toolBar.Action6.setStatusTip("Undo.") self.toolBar.Action6.setStatusTip("Undo.")
#self.toolBar.Action6.setShortcut("Ctrl+Z") self.toolBar.Action6.setShortcut("Ctrl+Z")
self.toolBar.Action6.triggered.connect(self.codebox.undo) self.toolBar.Action6.triggered.connect(self.codebox.undo)
#action 7 redo #action 7 redo
self.toolBar.Action7 = QtGui.QAction(QtGui.QIcon(":/ico/redo.png"),"Redo",self.toolBar) self.toolBar.Action7 = QtGui.QAction(QtGui.QIcon(":/ico/redo.png"),"Redo",self.toolBar)
self.toolBar.Action7.setStatusTip("Redo.") self.toolBar.Action7.setStatusTip("Redo.")
#self.toolBar.Action7.setShortcut("Ctrl+Y") self.toolBar.Action7.setShortcut("Ctrl+Y")
self.toolBar.Action7.triggered.connect(self.codebox.redo) self.toolBar.Action7.triggered.connect(self.codebox.redo)
#action8 rerset Folding #action8 rerset Folding
self.toolBar.Action8 = QtGui.QAction(QtGui.QIcon(":/ico/align-justify.png"),"Reset Folding",self.toolBar) self.toolBar.Action8 = QtGui.QAction(QtGui.QIcon(":/ico/align-justify.png"),"Reset Folding",self.toolBar)
self.toolBar.Action8.setStatusTip("Reset Folding.") self.toolBar.Action8.setStatusTip("Reset Folding.")
#self.toolBar.Action8.setShortcut("Ctrl+R") self.toolBar.Action8.setShortcut("Ctrl+R")
self.toolBar.Action8.triggered.connect(self.nofoldingl) self.toolBar.Action8.triggered.connect(self.nofoldingl)
#actions9 CircledTreeFoldStyle #actions9 CircledTreeFoldStyle
self.toolBar.Action9 = QtGui.QAction(QtGui.QIcon(":/ico/bullet.png"),"Circled Tree Folding",self.toolBar) self.toolBar.Action9 = QtGui.QAction(QtGui.QIcon(":/ico/bullet.png"),"Circled Tree Folding",self.toolBar)
self.toolBar.Action9.setStatusTip("Circled Tree Folding.") self.toolBar.Action9.setStatusTip("Circled Tree Folding.")
#self.toolBar.Action9.setShortcut("Ctrl+C") self.toolBar.Action9.setShortcut("Ctrl+C")
self.toolBar.Action9.triggered.connect(self.Circledfold) self.toolBar.Action9.triggered.connect(self.Circledfold)
#actions10 plainFoldStyle #actions10 plainFoldStyle
self.toolBar.Action10 = QtGui.QAction(QtGui.QIcon(":/ico/number.png"),"Plain Folding",self.toolBar) self.toolBar.Action10 = QtGui.QAction(QtGui.QIcon(":/ico/number.png"),"Plain Folding",self.toolBar)
self.toolBar.Action10.setStatusTip("Plain Folding") self.toolBar.Action10.setStatusTip("Plain Folding")
#self.toolBar.Action10.setShortcut("Ctrl+P") self.toolBar.Action10.setShortcut("Ctrl+P")
self.toolBar.Action10.triggered.connect(self.plainfold) self.toolBar.Action10.triggered.connect(self.plainfold)
# fonts
self.toolBar.Action21 = QtGui.QAction(QtGui.QIcon(":/ico4/font.png"), "Fonts", self.toolBar)
self.toolBar.Action21.setStatusTip("Fonts")
self.toolBar.Action21.setShortcut("Ctrl+F")
self.toolBar.Action21.triggered.connect(self.font_choice)
#web baby #web baby
self.toolBar.Action11 = QtGui.QAction(QtGui.QIcon(":/ico/web.png"),"Hex-rays Homepage",self.toolBar) self.toolBar.Action11 = QtGui.QAction(QtGui.QIcon(":/ico/web.png"),"Hex-rays Homepage",self.toolBar)
self.toolBar.Action11.setStatusTip("Home of Hex-rays") self.toolBar.Action11.setStatusTip("Home of Hex-rays")
#self.toolBar.Action11.setShortcut("Ctrl+W") self.toolBar.Action11.setShortcut("Ctrl+W")
self.toolBar.Action11.triggered.connect(self.webopen) self.toolBar.Action11.triggered.connect(self.webopen)
#irc #irc
self.toolBar.Action12 = QtGui.QAction(QtGui.QIcon(":/ico3/settings.png"),"Open IDA Pro Python SDK",self.toolBar) self.toolBar.Action12 = QtGui.QAction(QtGui.QIcon(":/ico3/settings.png"),"Open Ida Pro Python SDK",self.toolBar)
self.toolBar.Action12.setStatusTip("IDA Pro Python SDK") self.toolBar.Action12.setStatusTip("Ida Pro Python SDK")
#self.toolBar.Action12.setShortcut("Ctrl+I") self.toolBar.Action12.setShortcut("Ctrl+I")
self.toolBar.Action12.triggered.connect(self.sdkopen) self.toolBar.Action12.triggered.connect(self.sdkopen)
#github Python #github Python
self.toolBar.Action14 = QtGui.QAction(QtGui.QIcon(":/ico/github.png"),"Open git python",self.toolBar) self.toolBar.Action14 = QtGui.QAction(QtGui.QIcon(":/ico/github.png"),"Open git python",self.toolBar)
self.toolBar.Action14.setStatusTip("Open git python") self.toolBar.Action14.setStatusTip("Open git python")
#self.toolBar.Action14.setShortcut("Ctrl+G") self.toolBar.Action14.setShortcut("Ctrl+G")
self.toolBar.Action14.triggered.connect(self.gitopen) self.toolBar.Action14.triggered.connect(self.gitopen)
#auther me :) #auther me :)
self.toolBar.Action15 = QtGui.QAction(QtGui.QIcon(":/ico/auth.png"),"Author",self.toolBar) self.toolBar.Action15 = QtGui.QAction(QtGui.QIcon(":/ico/auth.png"),"Author",self.toolBar)
self.toolBar.Action15.setStatusTip("Author") self.toolBar.Action15.setStatusTip("Author")
#self.toolBar.Action15.setShortcut("Ctrl+B") self.toolBar.Action15.setShortcut("Ctrl+B")
self.toolBar.Action15.triggered.connect(self.Author) self.toolBar.Action15.triggered.connect(self.Author)
#toggle off code regonision #toggle off code regonision
self.toolBar.Action16 = QtGui.QAction(QtGui.QIcon(":/ico2/pythonminus.png"),"Disable Code recognition",self.toolBar) self.toolBar.Action16 = QtGui.QAction(QtGui.QIcon(":/ico2/pythonminus.png"),"Disable Code recognition",self.toolBar)
self.toolBar.Action16.setStatusTip("Disable Code recognition") self.toolBar.Action16.setStatusTip("Disable Code recognition")
#self.toolBar.Action16.setShortcut("Alt+D") self.toolBar.Action16.setShortcut("Alt+D")
self.toolBar.Action16.triggered.connect(self.Diablecode) self.toolBar.Action16.triggered.connect(self.Diablecode)
#toogle on #toogle on
self.toolBar.Action17 = QtGui.QAction(QtGui.QIcon(":/ico2/pypluss.png"),"Enable Code recognition",self.toolBar) self.toolBar.Action17 = QtGui.QAction(QtGui.QIcon(":/ico2/pypluss.png"),"Enable Code recognition",self.toolBar)
self.toolBar.Action17.setStatusTip("Enable Code recognition") self.toolBar.Action17.setStatusTip("Enable Code recognition")
#self.toolBar.Action17.setShortcut("Alt+E") self.toolBar.Action17.setShortcut("Alt+E")
self.toolBar.Action17.triggered.connect(self.Reiablecode) self.toolBar.Action17.triggered.connect(self.Reiablecode)
# zoom in # zoom in
self.toolBar.Action18 = QtGui.QAction(QtGui.QIcon(":/ico3/in.png"),"Zoom In",self.toolBar) self.toolBar.Action18 = QtGui.QAction(QtGui.QIcon(":/ico3/in.png"),"Zoom In",self.toolBar)
self.toolBar.Action18.setStatusTip("Zoom In") self.toolBar.Action18.setStatusTip("Zoom In")
#self.toolBar.Action18.setShortcut("CTRL+SHIFT++") self.toolBar.Action18.setShortcut("CTRL+SHIFT++")
self.toolBar.Action18.triggered.connect(self.udder) self.toolBar.Action18.triggered.connect(self.udder)
#zoom out #zoom out
self.toolBar.Action19 = QtGui.QAction(QtGui.QIcon(":/ico3/out.png"),"Zoom Out",self.toolBar) self.toolBar.Action19 = QtGui.QAction(QtGui.QIcon(":/ico3/out.png"),"Zoom Out",self.toolBar)
self.toolBar.Action19.setStatusTip("Zoom Out") self.toolBar.Action19.setStatusTip("Zoom Out")
#self.toolBar.Action19.setShortcut("CTRL+SHIFT+-") self.toolBar.Action19.setShortcut("CTRL+SHIFT+-")
self.toolBar.Action19.triggered.connect(self.odder) self.toolBar.Action19.triggered.connect(self.odder)
self.toolBar.Action20 = QtGui.QAction(QtGui.QIcon(":/ico3/10.png"),"Profile Code",self.toolBar) self.toolBar.Action20 = QtGui.QAction(QtGui.QIcon(":/ico3/10.png"),"Profile Code",self.toolBar)
self.toolBar.Action20.setStatusTip("Profile Code") self.toolBar.Action20.setStatusTip("Profile Code")
#self.toolBar.Action20.setShortcut("CTRL+SHIFT+E") self.toolBar.Action20.setShortcut("CTRL+SHIFT+E")
self.toolBar.Action20.triggered.connect(self.runtoprob) self.toolBar.Action20.triggered.connect(self.runtoprob)
#actions #actions
self.toolBar.addAction(self.toolBar.newAction) self.toolBar.addAction(self.toolBar.newAction)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.secondAction) self.toolBar.addAction(self.toolBar.secondAction)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action3) self.toolBar.addAction(self.toolBar.Action3)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action4) self.toolBar.addAction(self.toolBar.Action4)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action6) self.toolBar.addAction(self.toolBar.Action6)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action7) self.toolBar.addAction(self.toolBar.Action7)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action8) self.toolBar.addAction(self.toolBar.Action8)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action9) self.toolBar.addAction(self.toolBar.Action9)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action10) self.toolBar.addAction(self.toolBar.Action10)
self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action21)
self.toolBar.addSeparator()
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action11) self.toolBar.addAction(self.toolBar.Action11)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action12) self.toolBar.addAction(self.toolBar.Action12)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action14) self.toolBar.addAction(self.toolBar.Action14)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action15) self.toolBar.addAction(self.toolBar.Action15)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action16) self.toolBar.addAction(self.toolBar.Action16)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action17) self.toolBar.addAction(self.toolBar.Action17)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action18) self.toolBar.addAction(self.toolBar.Action18)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action19) self.toolBar.addAction(self.toolBar.Action19)
self.toolBar.addSeparator() self.toolBar.addSeparator()
self.toolBar.addAction(self.toolBar.Action20) self.toolBar.addAction(self.toolBar.Action20)
# font #font
skrift = QFont() self.skrift = QFont()
skrift.setFamily("Courier New") self.skrift.setFamily('Consolas')
skrift.setFixedPitch(True) self.skrift.setFixedPitch(True)
skrift.setPointSize(9) self.skrift.setPointSize(12)
self.codebox.setFont(skrift) self.codebox.setFont(self.skrift)
#skrift = QtGui.QFont("Courier New", 9, QtGui.QFont.Bold)
#python style #python style
lexer = QsciLexerPython(self.codebox) self.lexer = QsciLexerPython(self.codebox)
lexer.setFont(skrift) self.lexer.setFont(self.skrift)
lexer.setEolFill(True) self.lexer.setEolFill(True)
#api test not working #api test not working
api = Qsci.QsciAPIs(lexer) api = Qsci.QsciAPIs(self.lexer)
API_FILE = dn+'\\Python.api' API_FILE = dn+'\\Python.api'
API_FILE2 = dn+'\\idc.api' API_FILE2 = dn+'\\idc.api'
API_FILE3 = dn+'\\idaapi.api' API_FILE3 = dn+'\\idaapi.api'
api.load(API_FILE) api.load(API_FILE)
api.load(API_FILE2) api.load(API_FILE2)
api.load(API_FILE3) api.load(API_FILE3)
api.prepare() api.prepare()
self.codebox.setAutoCompletionThreshold(0) self.codebox.setAutoCompletionThreshold(0)
self.codebox.setAutoCompletionThreshold(6) self.codebox.setAutoCompletionThreshold(6)
self.codebox.setAutoCompletionThreshold(8) self.codebox.setAutoCompletionThreshold(8)
self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs) self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
lexer.setDefaultFont(skrift) self.lexer.setDefaultFont(self.skrift)
self.codebox.setLexer(lexer) self.codebox.setLexer(self.lexer)
self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, "Courier New") self.codebox.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Consolas')
#line numbers #line numbers
fontmetrics = QFontMetrics(skrift) fontmetrics = QFontMetrics(self.skrift)
self.codebox.setMarginsFont(skrift) self.codebox.setMarginsFont(self.skrift)
self.codebox.setMarginWidth(0, fontmetrics.width("0000") + 6) self.codebox.setMarginWidth(0, fontmetrics.width("0000") + 6)
self.codebox.setTabWidth(4) self.codebox.setTabWidth(4)
#brace #brace
self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.codebox.setBraceMatching(QsciScintilla.SloppyBraceMatch)
#auto line tab = 4 #auto line tab =4
self.codebox.setAutoIndent(True) self.codebox.setAutoIndent(True)
#scroolbar #scroolbar
self.codebox.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1) self.codebox.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 1)
self.retranslateUi(MainWindow) self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.lbl = self.codebox
def retranslateUi(self, MainWindow): def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", APP_TITLE, None)) MainWindow.setWindowTitle(_translate("MainWindow", "Ida Pro Python Script Editor", None))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))
def udder(self): def udder(self):
self.codebox.zoomIn() self.codebox.zoomIn()
def odder(self): def odder(self):
self.codebox.zoomOut() self.codebox.zoomOut()
def confirmMessageBox(self, caption, text):
msg_box = QMessageBox()
msg_box.setWindowIcon(self.icon)
msg_box.setWindowTitle(caption)
msg_box.setText(text)
msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
msg_box.setDefaultButton(QMessageBox.No)
return msg_box.exec_()
def newfile(self): def newfile(self):
textout = self.codebox.text()
if (len(textout) > 0 and len(self.filename) == 0) or (textout != self.prev_textout):
reply = self.confirmMessageBox("Ask for saving", "Something's changed. Create new without saving?")
if reply != QtGui.QMessageBox.Yes: return
self.codebox.clear() self.codebox.clear()
self.prev_textout = ""
self.filename = ""
MainWindow.setWindowTitle(_translate("MainWindow", "%s *" % APP_TITLE, None))
print "%s -> New File" % APP_TITLE
def open(self): def open(self):
textout = self.codebox.text()
if (len(textout) > 0 and len(self.filename) == 0) or (textout != self.prev_textout):
reply = self.confirmMessageBox("Ask for saving", "Something's changed. Open another file without saving?")
if reply != QtGui.QMessageBox.Yes: return
self.path = QtCore.QFileInfo(self.filename).path() self.path = QtCore.QFileInfo(self.filename).path()
# Get filename and show only .writer files # Get filename and show only .writer files
#self.filename = QtGui.QFileDialog.getOpenFileName(self.vindu, 'Open File', self.path, "Python Files (*.py *.pyc *.pyw)", '') self.filename = QtGui.QFileDialog.getOpenFileName(
selected = False self.vindu, 'Open File', self.path, "Python Files (*.py *.pyc *.pyw)",
open_dialog = QtGui.QFileDialog(self.vindu) '')
open_dialog.setWindowTitle("Open File")
open_dialog.setNameFilter("Python Files (*.py *.pyc *.pyw)")
open_dialog.setFileMode(QtGui.QFileDialog.ExistingFile)
open_dialog.setAcceptMode(QtGui.QFileDialog.AcceptOpen)
if open_dialog.exec_() == QtGui.QDialog.Accepted:
self.filename = open_dialog.selectedFiles()[0]
selected = True
if selected and os.path.exists(self.filename): if self.filename:
with open(self.filename,"r") as self.file: with open(self.filename,"r") as self.file:
self.codebox.setText(self.file.read()) self.codebox.setText(self.file.read())
self.prev_textout = self.codebox.text()
MainWindow.setWindowTitle(_translate("MainWindow", "%s [%s]" % (APP_TITLE, self.filename), None))
print "%s -> Opened File" % APP_TITLE
os.chdir(str(self.path)) os.chdir(str(self.path))
def fontFamily(self,font): def fontFamily(self,font):
self.text.setCurrentFont(font) self.text.setCurrentFont(font)
def fontSize(self, fontsize): def fontSize(self, fontsize):
self.text.setFontPointSize(int(fontsize)) self.text.setFontPointSize(int(fontsize))
def fontFamily(self,font): def fontFamily(self,font):
self.codebox.text.setCurrentFont(font) self.codebox.text.setCurrentFont(font)
def fontSize(self, fontsize): def fontSize(self, fontsize):
self.codebox.text.setFontPointSize(int(fontsize)) self.codebox.text.setFontPointSize(int(fontsize))
def savefile(self): def savefile(self):
saved, selected = False, False self.path = QtCore.QFileInfo(self.filename).path()
if len(self.filename) == 0 or not os.path.exists(self.filename): self.filename = QtGui.QFileDialog.getSaveFileName(
self.path = QtCore.QFileInfo(self.filename).path() self.vindu, "Save as", self.path, "Python Files (*.py *.pyc *.pyw)",
save_dialog = QtGui.QFileDialog(self.vindu) )
save_dialog.setWindowTitle("Open File") if self.filename:
save_dialog.setNameFilter("Python Files (*.py *.pyc *.pyw)")
save_dialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
if save_dialog.exec_() == QtGui.QDialog.Accepted:
self.filename = save_dialog.selectedFiles()[0]
selected = True
if selected and self.filename:
self.savetext(self.filename)
saved = True
os.chdir(str(self.path))
else:
self.savetext(self.filename) self.savetext(self.filename)
saved = True os.chdir(str(self.path))
if saved:
self.prev_textout = self.codebox.text()
print "%s -> Saved File" % APP_TITLE
def savetext(self, fileName): def savetext(self, fileName):
textout = self.codebox.text() textout = self.codebox.text()
file = QtCore.QFile(fileName) file = QtCore.QFile(fileName)
if file.open(QtCore.QIODevice.WriteOnly): QtCore.QTextStream(file) << textout if file.open(QtCore.QIODevice.WriteOnly):
else: QtGui.QMessageBox.information(self.vindu, "Unable to open file", file.errorString()) QtCore.QTextStream(file) << textout
else:
QtGui.QMessageBox.information(self.vindu, "Unable to open file",
file.errorString())
os.chdir(str(self.path)) os.chdir(str(self.path))
def close(self, event):
textout = self.codebox.text()
if (len(textout) > 0 and len(self.filename) == 0) or (textout != self.prev_textout):
reply = self.confirmMessageBox("Ask for saving", "Something's changed. Quit without saving?")
if reply != QtGui.QMessageBox.Yes: event.ignore()
def runto(self): def runto(self):
try: try:
self.path = QtCore.QFileInfo(self.filename).path() self.path = QtCore.QFileInfo(self.filename).path()
except AttributeError: except AttributeError:
pass pass
g = globals() g = globals()
os.chdir(str(self.path)) os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path))) os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
script = str(self.codebox.text()) script = str(self.codebox.text())
try: try:
exec (script, g) exec (script, g)
QtGui.QCloseEvent() QtGui.QCloseEvent()
except ImportError: except ImportError:
os.chdir(str(self.path)) os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path))) os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
sys.path.append(str(self.path)) sys.path.append(str(self.path))
exec (script, g) exec (script, g)
QtGui.QCloseEvent() QtGui.QCloseEvent()
if TypeError (QTextStream): if TypeError (QTextStream):
g = globals() g = globals()
os.chdir(str(self.path)) os.chdir(str(self.path))
os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path))) os.path.join(os.path.expanduser('~'), os.path.expandvars(str(self.path)))
sys.path.insert(0, str(self.path)) sys.path.insert(0, str(self.path))
exec int(script) exec int(script)
QtGui.QCloseEvent() QtGui.QCloseEvent()
def runtoprob(self): def runtoprob(self):
try: try:
self.path = QtCore.QFileInfo(self.filename).path() self.path = QtCore.QFileInfo(self.filename).path()
except AttributeError: except AttributeError:
pass pass
self.path = QtCore.QFileInfo(self.filename).path() self.path = QtCore.QFileInfo(self.filename).path()
g = globals() g = globals()
os.chdir(str(self.path)) os.chdir(str(self.path))
script = str(self.codebox.text()) script = str(self.codebox.text())
import cProfile import cProfile
cProfile.run(script) cProfile.run(script)
def Diablecode(self): def Diablecode(self):
self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsNone) self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsNone)
def Reiablecode(self): def Reiablecode(self):
self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs) self.codebox.setAutoCompletionSource(Qsci.QsciScintilla.AcsAPIs)
def nofoldingl(self): def nofoldingl(self):
self.codebox.setFolding(QsciScintilla.NoFoldStyle) self.codebox.setFolding(QsciScintilla.NoFoldStyle)
def Circledfold(self): def Circledfold(self):
self.codebox.setFolding(QsciScintilla.CircledTreeFoldStyle) self.codebox.setFolding(QsciScintilla.CircledTreeFoldStyle)
def plainfold(self): def plainfold(self):
self.codebox.setFolding(QsciScintilla.PlainFoldStyle) self.codebox.setFolding(QsciScintilla.PlainFoldStyle)
def webopen(self): def webopen(self):
import webbrowser import webbrowser
webbrowser.open('https://www.hex-rays.com/') webbrowser.open('https://www.hex-rays.com/')
def sdkopen(self): def sdkopen(self):
import webbrowser import webbrowser
webbrowser.open('https://www.hex-rays.com/products/ida/support/idapython_docs/') webbrowser.open('https://www.hex-rays.com/products/ida/support/idapython_docs/')
def gitopen(self): def gitopen(self):
import webbrowser import webbrowser
webbrowser.open('https://github.com/idapython/src/tree/build-1.7.2') webbrowser.open('https://github.com/idapython/src/tree/build-1.7.2')
def Author(self): def Author(self):
import webbrowser import webbrowser
webbrowser.open('https://github.com/techbliss') webbrowser.open('https://github.com/techbliss')
def closeEvent(self, event):
print("event")
reply = QtGui.QMessageBox.question(self, 'Message',
"Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
def font_choice(self):
self.lbl = self.lexer
font, ok = QtGui.QFontDialog.getFont()
if ok:
self.lbl.setFont(font)
def on_margin_clicked(self, nmargin, nline, modifiers):
# Toggle marker for the line the margin was clicked on
if self.codebox.markersAtLine(nline) != 0:
self.codebox.markerDelete(nline, self.ARROW_MARKER_NUM)
else:
self.codebox.markerAdd(nline, self.ARROW_MARKER_NUM)
from PyQt4 import Qscifrom PyQt4 import Qsci
if __name__ == "__main__":if __name__ == "__main__":
app = QtGui.QApplication.instance() # We add this so we can use editor outside Ida import sys
if not app: app = QtGui.QApplication([]) #app = QtGui.QApplication.instance() # We add this so we can use editor outside Ida
#if not app:
# app = QtGui.QApplication([])
MainWindow = QtGui.QMainWindow() MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow() ui = Ui_MainWindow()
ui.setupUi(MainWindow) ui.setupUi(MainWindow)
ui.Circledfold()
MainWindow.show() MainWindow.show()
MainWindow.resize(1000, 600) MainWindow.resize(1000, 600)
MainWindow.closeEvent = ui.close #if app.exec_():
if app.exec_(): os.chdir(dn) #os.chdir(dn)
Editor
Original Text
Changed Text