Home | Trees | Indices | Help |
---|
|
1 #!/usr/bin/python 2 ######################################################################## 3 # Copyright (c) 2012 4 # Daniel Plohmann <daniel.plohmann<at>gmail<dot>com> 5 # Alexander Hanel <alexander.hanel<at>gmail<dot>com> 6 # All rights reserved. 7 ######################################################################## 8 # 9 # This file is part of IDAscope 10 # 11 # IDAscope is free software: you can redistribute it and/or modify it 12 # under the terms of the GNU General Public License as published by 13 # the Free Software Foundation, either version 3 of the License, or 14 # (at your option) any later version. 15 # 16 # This program is distributed in the hope that it will be useful, but 17 # WITHOUT ANY WARRANTY; without even the implied warranty of 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 # General Public License for more details. 20 # 21 # You should have received a copy of the GNU General Public License 22 # along with this program. If not, see 23 # <http://www.gnu.org/licenses/>. 24 # 25 ######################################################################## 26 27 import os 28 import time 29 30 import idaapi 31 from idaapi import PluginForm, plugin_t 32 from PySide import QtGui 33 from PySide.QtGui import QIcon 34 35 from idascope.core.structures.IDAscopeConfiguration import IDAscopeConfiguration 36 from idascope.core.SemanticIdentifier import SemanticIdentifier 37 from idascope.core.DocumentationHelper import DocumentationHelper 38 from idascope.core.WinApiProvider import WinApiProvider 39 from idascope.core.CryptoIdentifier import CryptoIdentifier 40 from idascope.core.IdaProxy import IdaProxy 41 from idascope.widgets.FunctionInspectionWidget import FunctionInspectionWidget 42 from idascope.widgets.WinApiWidget import WinApiWidget 43 from idascope.widgets.CryptoIdentificationWidget import CryptoIdentificationWidget 44 45 ################################################################################ 46 # Core of the IDAscope GUI. 47 ################################################################################ 48 49 HOTKEYS = None 50 IDASCOPE = None 51 NAME = "simpliFiRE.IDAscope v1.0" 52 5355 """ 56 This class contains the main window of IDAscope 57 Setup of core modules and widgets is performed in here. 58 """ 59161 162 ################################################################################ 163 # Usage as plugin 164 ################################################################################ 165 16661 super(IDAscopeForm, self).__init__() 62 global HOTKEYS 63 HOTKEYS = [] 64 self.idascope_widgets = [] 65 self.root_file_path = \ 66 os.path.realpath(__file__)[:os.path.realpath(__file__).rfind(os.sep) + 1] 67 self.config = IDAscopeConfiguration(self.root_file_path + os.sep + "config.json") 68 self.icon = QIcon(self.config.icon_file_path + "idascope.png")69 8385 """ 86 Setup IDAscope widgets. 87 """ 88 time_before = time.time() 89 print ("setting up widgets...") 90 self.idascope_widgets.append(FunctionInspectionWidget(self)) 91 self.idascope_widgets.append(WinApiWidget(self)) 92 self.idascope_widgets.append(CryptoIdentificationWidget(self)) 93 self.setup_IDAscope_form() 94 print ("this took %3.2f seconds." % (time.time() - time_before))9597 """ 98 Orchestrate the already initialized widgets in tabs on the main window. 99 """ 100 self.tabs = QtGui.QTabWidget() 101 self.tabs.setTabsClosable(False) 102 for widget in self.idascope_widgets: 103 self.tabs.addTab(widget, widget.icon, widget.name) 104 layout = QtGui.QVBoxLayout() 105 layout.addWidget(self.tabs) 106 self.parent.setLayout(layout)107109 """ 110 When creating the form, setup the shared modules and widgets 111 """ 112 self.parent = self.FormToPySideWidget(form) 113 self.parent.setWindowIcon(self.icon) 114 self.setup_shared_modules() 115 self.setup_widgets()116 123125 return PluginForm.Show(self, 126 NAME, 127 options=(PluginForm.FORM_CLOSE_LATER | PluginForm.FORM_RESTORE | PluginForm.FORM_SAVE))128 129 ################################################################################ 130 # functionality offered to IDAscope's widgets 131 ################################################################################ 132134 """ 135 Can be used by IDAscope widgets to set focus to a widget, identified by name. 136 @param widget_name: A widget name 137 @type widget_name: str 138 """ 139 for widget in self.idascope_widgets: 140 if widget.name == widget_name: 141 tab_index = self.tabs.indexOf(widget) 142 self.tabs.setCurrentIndex(tab_index) 143 return144146 """ 147 Can be used by IDAscope widgets to register hotkeys. 148 Uses a global list HOTKEYS of function pointers that link to the desired functionality. 149 Right now, linked functions cannot take parameters and should scrape all information they need by themselves. 150 @param shortcut: A string describing a shortcut, e.g. "ctrl+F3" 151 @type shortcut: str 152 @param py_function_pointer: a python function that shall be called when the shortcut is triggered. 153 @type py_function_pointer: a pointer to a python function 154 """ 155 global HOTKEYS 156 hotkey_index = len(HOTKEYS) 157 hotkey_name = "idascope_HOTKEY_%d" % hotkey_index 158 HOTKEYS.append(py_function_pointer) 159 self.ida_proxy.CompileLine('static %s() { RunPythonStatement("HOTKEYS[%d]()"); }' % (hotkey_name, hotkey_index)) 160 self.ida_proxy.AddHotkey(shortcut, hotkey_name)168 """ 169 Plugin version of IDAscope. Use this to deploy IDAscope via IDA plugins folder. 170 """ 171 flags = idaapi.PLUGIN_UNL 172 comment = NAME 173 help = "A plugin to help to identify the relevant parts" 174 wanted_name = "IDAscope" 175 wanted_hotkey = "Ctrl-F4" 176 181197 198183 # Create form 184 f = IDAscopeForm() 185 186 # Show the form 187 exit_code = f.Show() 188 if exit_code == 0: 189 f.Free() 190 return 191 192 f.Free() 193 return194200 return IDAscopePlugin()201 202 ################################################################################ 203 # Usage as script 204 ################################################################################ 205 206 221 222 223 if __name__ == "__main__": 224 main() 225
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Sep 17 13:18:34 2012 | http://epydoc.sourceforge.net |