Example #1
0
 def init(self):
     idaapi.add_hotkey("j", JumpToBottom)
     idaapi.add_hotkey("i", JumpToTop)
     self.hook = IdpHooker()
     self.hook.hook()
     print "%s initialized" % (GLB_PluginName)
     return idaapi.PLUGIN_KEEP
Example #2
0
def start_up():
    print "CopyEA Start_up is started..."
    COPYHOTKEY = 'z'

    print "Press '%s' to copy location of effective address to clipboard()" % COPYHOTKEY
    idaapi.CompileLine('static _copy_ea() { RunPythonStatement("CopyEA()"); }')
    idaapi.add_hotkey(COPYHOTKEY, CopyEA)
Example #3
0
 def init(self):
     self.hook = IdpHooker()
     self.hook.hook()
     print "%s initialized" % (GLB_PluginName)
     idaapi.add_hotkey("i", self.hook.toggle_hider)
     idaapi.add_hotkey("j", JumpToTop)
     return idaapi.PLUGIN_KEEP
Example #4
0
 def init(self):
     self.hook = IdpHooker()
     self.hook.hook()
     print "%s initialized" % (GLB_PluginName)
     idaapi.add_hotkey("i", self.hook.toggle_hider)
     idaapi.add_hotkey("j", JumpToTop)
     return idaapi.PLUGIN_KEEP
Example #5
0
 def init(self):
     self.hotkeys = []
     self.hotkeys.append(
         idaapi.add_hotkey("Alt+9", show_current_function_strings))
     self.hotkeys.append(
         idaapi.add_hotkey("Ctrl+Alt+9", show_highlighted_function_strings))
     return idaapi.PLUGIN_KEEP
Example #6
0
def start_up():
  print "CopyEA Start_up is started..."
  COPYHOTKEY = 'z'

  print "Press '%s' to copy location of effective address to clipboard()"%COPYHOTKEY
  idaapi.CompileLine('static _copy_ea() { RunPythonStatement("CopyEA()"); }')
  idaapi.add_hotkey(COPYHOTKEY,CopyEA)
Example #7
0
    def __init__(self, funcCallbacks):
        """
        This is the start of the debugger.
        """
        import os

        from dispatcher.core.Util import ConfigReader, unique_file_name
        from dispatcher.core.structures.Tracer.Config.config import ConfigFile as ConfigFile

        #Get the root IDA directory in order to locate the config.xml file
        root_dir = os.path.join(idc.GetIdaDirectory(), "plugins")
        ini_path = os.path.join(root_dir, "settings.ini")

        configReader = ConfigReader()
        configReader.Read(ini_path)

        # self.removeBreakpoints()

        self.windowsFileIO = funcCallbacks['windowsFileIO']
        self.windowsNetworkIO = funcCallbacks['windowsNetworkIO']
        self.linuxFileIO = funcCallbacks['linuxFileIO']
        self.interactivemodeCallback = funcCallbacks['interactivemodeCallback']

        #register the hotkey for marking the starting point for taint tracking
        taintStart_ctx = idaapi.add_hotkey("Shift-A", self.taintStart)
        self.taintStart = None
        #register the hotkey for marking the stopping point for taint tracking
        taintStop_ctx = idaapi.add_hotkey("Shift-Z", self.taintStop)
        self.taintStop = None

        configFile = configReader.configFile

        #Print( configFile )
        #Call ConfigFile to grab all configuration information from the config.xml file
        self.config = ConfigFile(configFile)

        (processName, osType, osArch) = self.getProcessInfo()

        self.processConfig = self.createProcessConfig(processName, osType,
                                                      osArch)

        filePath = os.path.splitext(configReader.traceFile)
        processBasename = os.path.splitext(processName)

        self.tracefile = filePath[0] + "_" + processBasename[0] + filePath[1]
        self.tracefile = unique_file_name(self.tracefile)
        Print(self.tracefile)

        traceFileName = os.path.splitext(self.tracefile)
        self.treeTracefile = traceFileName[0] + ".idb"

        self.logger = None
        logfile = traceFileName[0] + ".log"

        self.initLogging(logfile, configReader.logging, configReader.debugging)

        print "IDATrace init called."
Example #8
0
    def __init__(self,funcCallbacks):
        """
        This is the start of the debugger.
        """
        import os
        
        from dispatcher.core.Util import ConfigReader, unique_file_name
        from dispatcher.core.structures.Tracer.Config.config import ConfigFile as ConfigFile
        
        #Get the root IDA directory in order to locate the config.xml file
        root_dir = os.path.join( idc.GetIdaDirectory() ,"plugins")
        ini_path = os.path.join(root_dir,"settings.ini")

        configReader = ConfigReader()
        configReader.Read(ini_path)
        
       # self.removeBreakpoints()

        self.windowsFileIO       = funcCallbacks['windowsFileIO']
        self.windowsNetworkIO    = funcCallbacks['windowsNetworkIO']
        self.linuxFileIO         = funcCallbacks['linuxFileIO'] 
        self.interactivemodeCallback  = funcCallbacks['interactivemodeCallback']
                
        #register the hotkey for marking the starting point for taint tracking
        taintStart_ctx = idaapi.add_hotkey("Shift-A", self.taintStart)
        self.taintStart = None
        #register the hotkey for marking the stopping point for taint tracking
        taintStop_ctx = idaapi.add_hotkey("Shift-Z", self.taintStop)
        self.taintStop = None

        configFile = configReader.configFile
        
        #Print( configFile )
        #Call ConfigFile to grab all configuration information from the config.xml file
        self.config = ConfigFile(configFile)
        
        (processName, osType, osArch) = self.getProcessInfo()

        self.processConfig = self.createProcessConfig(processName, osType, osArch)

        filePath = os.path.splitext(configReader.traceFile)
        processBasename = os.path.splitext(processName)
        
        self.tracefile = filePath[0] + "_" + processBasename[0] + filePath[1]
        self.tracefile = unique_file_name(self.tracefile)
        Print(self.tracefile)
        
        traceFileName = os.path.splitext(self.tracefile)
        self.treeTracefile = traceFileName[0] + ".idb"
        
        self.logger = None
        logfile = traceFileName[0] + ".log"
        
        self.initLogging(logfile,configReader.logging,configReader.debugging)
 
        print "IDATrace init called."    
    def init(self):
        self.clear_search_handler = self._get_clear_search_handler()
        self.add_to_search_handler = self._get_add_to_search_handler()
        self.add_to_search_handler.register()
        self.clear_search_handler.register()

        self.hooks = self._get_hooks()()
        self.hooks.hook()

        self.hotkeys = []
        self.hotkeys.append(idaapi.add_hotkey("Ctrl+Alt+6", self._show))
        self.hotkeys.append(idaapi.add_hotkey("Ctrl+Alt+5", self._print))
        return idaapi.PLUGIN_KEEP
Example #10
0
def ida_main():
    # Create form
    global f
    idaapi.add_hotkey("Shift-S", GO_Utils.GoStrings.stringify)
    f = MyForm()

    # Compile (in order to populate the controls)
    f.Compile()

    # Execute the form
    ok = f.Execute()

    # Dispose the form
    f.Free()
Example #11
0
    def init(brutal_self):
        idaapi.unregister_action('Undo')
        idaapi.unregister_action('Redo')

        brutal_self.brutal_action_handler = BrutalActionHandler()
        brutal_action_desc = idaapi.action_desc_t(
            'BRUTAL', 'BRUTAL IDA', brutal_self.brutal_action_handler, '',
            'IDA', BRUTAL6_ICON)
        idaapi.register_action(brutal_action_desc)
        idaapi.create_toolbar('BRUTAL IDA', 'BRUTAL IDA')

        brutal_self.brutal_letter_handlers = []

        for brutal_letter in 'BRUTAL':
            brutal_letter_handler = BrutalLetterHandler()
            brutal_self.brutal_letter_handlers.append(brutal_letter_handler)

            brutal_label = 'BRUTAL {}'.format(brutal_letter)
            brutal_letter_desc = idaapi.action_desc_t(
                brutal_label, brutal_label, brutal_letter_handler, '',
                brutal_letter, BRUTAL_LETTERS[brutal_letter])
            idaapi.register_action(brutal_letter_desc)
            idaapi.attach_action_to_toolbar('BRUTAL IDA', brutal_label)

        idaapi.attach_action_to_toolbar('BRUTAL IDA', 'BRUTAL')

        brutal_self.brutal_hotkey = idaapi.add_hotkey(
            'Ctrl+Z', brutal_self.dispatch_brutality)

        return idaapi.PLUGIN_KEEP
Example #12
0
 def init_single_hotkey(self, key, fnCb):
     ctx = idaapi.add_hotkey(key, fnCb)
     if ctx is None:
         print ("[sync] failed to register hotkey %s", key)
         del ctx
     else:
         self.hotkeys_ctx.append(ctx)
Example #13
0
 def init_single_hotkey(self, key, fnCb):
     ctx = idaapi.add_hotkey(key, fnCb)
     if ctx is None:
         print("[sync] failed to register hotkey %s", key)
         del ctx
     else:
         self.hotkeys_ctx.append(ctx)
Example #14
0
File: pyida.py Project: Asi81/PyIDA
def add_hotkey(hotkey, func):
    hotkey_ctx = idaapi.add_hotkey(hotkey, func)
    if hotkey_ctx is None:
        print "Failed to register hotkey %s for launching %s!" % (
            hotkey, func.__name__)
        del hotkey_ctx
    else:
        print "Hotkey %s registered for %s" % (hotkey, func.__name__)
Example #15
0
 def add(self, hotkey, func):
     hk = idaapi.add_hotkey(hotkey, func)
     if hk is None:
         debugline("hot key %s load fail" % hotkey)
         del hk
         return False
     else:
         self.keys.append((hotkey, func,))
         return True
Example #16
0
 def init(self):
     print('CGC Helper ({}) plugin has been loaded.'.format(utils.dump_version(version)))
     hotkey_ctx = idaapi.add_hotkey('Shift-R', CGCHelper.revise_syscall)
     if hotkey_ctx:
         print(self.help)
         return idaapi.PLUGIN_KEEP
     else:
         print('Failed to register CGCHelper hotkey!')
         del hotkey_ctx
         return idaapi.PLUGIN_SKIP
Example #17
0
    def init_single_hotkey(self, key, fnCb, conflict=None):
        # 'mute' existing action shortcut if present
        if conflict:
            ida_kernwin.update_action_shortcut(conflict, None)

        ctx = idaapi.add_hotkey(key, fnCb)
        if ctx is None:
            print("[sync] failed to register hotkey %s" % key)
            del ctx
        else:
            self.hotkeys_ctx.append((ctx, key, conflict))
Example #18
0
def load_hotkeys():
    ENABLED_HOTKEYS = [("Ctrl-Alt-D", make_dwords),
                       ("Ctrl-Alt-A", make_cstrings),
                       ("Ctrl-Alt-O", make_offset)]

    for func in ENABLED_HOTKEYS:
        func_name = inspect.getmembers(func[1])[-1][1]
        if idaapi.add_hotkey(func[0], func[1]):
            print "[+] Bound %s to %s" % (func_name, func[0])
        else:
            print "[-] Error: Unable to bind %s to %s" % (func_name, func[0])
Example #19
0
    def map(cls, key, callable):
        '''Map a specific `key` to a python `callable`.'''

        # check to see if the key is stored within our cache and remove it if so
        if key in cls.hotkey:
            idaapi.del_hotkey(cls.hotkey[key])

        # now we can add the hotkey and stash it in our cache
        # XXX: I'm not sure if the key needs to be utf8 encoded or not
        cls.hotkey[key] = res = idaapi.add_hotkey(key, callable)
        return res
Example #20
0
 def init(self):
     print('CGC Helper ({}) plugin has been loaded.'.format(
         utils.dump_version(version)))
     hotkey_ctx = idaapi.add_hotkey('Shift-R', CGCHelper.revise_syscall)
     if hotkey_ctx:
         print(self.help)
         return idaapi.PLUGIN_KEEP
     else:
         print('Failed to register CGCHelper hotkey!')
         del hotkey_ctx
         return idaapi.PLUGIN_SKIP
Example #21
0
    def map(cls, key, callable):
        '''Map a specific `key` to a python `callable`.'''

        # check to see if the key is stored within our cache and remove it if so
        if key in cls.hotkey:
            idaapi.del_hotkey(cls.hotkey[key])

        # now we can add the hotkey and stash it in our cache
        # XXX: I'm not sure if the key needs to be utf8 encoded or not
        cls.hotkey[key] = res = idaapi.add_hotkey(key, callable)
        return res
Example #22
0
    def ui_init(self):
        """Initializes the plugins interface extensions."""
        # Register menu entry. 
        # @HR: I really preferred the pre-6.5 mechanic.
        zelf = self
        class MenuEntry(idaapi.action_handler_t):
            def activate(self, ctx):
                zelf.open_proj_creation_dialog()
                return 1

            def update(self, ctx):
                return idaapi.AST_ENABLE_ALWAYS

        action = idaapi.action_desc_t(
            'continuum_new_project',
            "New continuum project...",
            MenuEntry(),
        )
        idaapi.register_action(action)
        idaapi.attach_action_to_menu("File/Open...", 'continuum_new_project', 0)    

        # Alright, is an IDB loaded? Pretend IDB open event as we miss the callback
        # when it was loaded before our plugin was staged.
        if GetIdbPath():
            self.core.handle_open_idb(None, None)

        # Register hotkeys.
        idaapi.add_hotkey('Shift+F', self.core.follow_extern)

        # Sign up for events.
        self.core.project_opened.connect(self.create_proj_explorer)
        self.core.project_closing.connect(self.close_proj_explorer)
        self.core.client_created.connect(self.subscribe_client_events)

        # Project / client already open? Fake events.
        if self.core.project:
            self.create_proj_explorer(self.core.project)
        if self.core.client:
            self.subscribe_client_events(self.core.client)
Example #23
0
def add_hotkey(hotkey, func):
    """
    Assign hotkey to run func.

    If a pre-existing action for the hotkey exists, then this function will
    remove that action and replace it with func.

    Arguments:
        - hotkey : string (for example 'Ctrl-Shift-A')
        - func : unit function (neither accepts arguments, nor returns values)
    """
    hotkey_ctx = idaapi.add_hotkey(hotkey, func)
    if hotkey_ctx is None:
        print("Failed to register {} for {}".format(hotkey, func))
    else:
        print("Registered {} for {}".format(hotkey, func))
Example #24
0
def add_hotkey(hotkey, func):
    """
    Assign hotkey to run func.

    If a pre-existing action for the hotkey exists, then this function will
    remove that action and replace it with func.

    Arguments:
        - hotkey : string (for example 'Ctrl-Shift-A')
        - func : unit function (neither accepts arguments, nor returns values)
    """
    hotkey_ctx = idaapi.add_hotkey(hotkey, func)
    if hotkey_ctx is None:
        print("Failed to register {} for {}".format(hotkey, func))
    else:
        print("Registered {} for {}".format(hotkey, func))
Example #25
0
    def init_single_hotkey(self, key, fnCb, conflict=None):
        if conflict:
            if self.cmd_hooks.minver74sp1():
                # 'hook' existing action shortcut when possible
                self.cmd_hooks.add_hook(conflict, fnCb)
                return
            else:
                # 'mute' existing action shortcut
                ida_kernwin.update_action_shortcut(conflict, None)

        ctx = idaapi.add_hotkey(key, fnCb)
        if ctx is None:
            rs_log("failed to register hotkey %s" % key)
            del ctx
        else:
            self.hotkeys_ctx.append((ctx, key, conflict))
Example #26
0
def main():
  global hotkey_ctx
  try:
    hotkey_ctx
    if idaapi.del_hotkey(hotkey_ctx):
      print "Hotkey unregistered!"
      del hotkey_ctx
    else:
      print "Failed to delete hotkey!"
  except:
      pass
  hotkey_ctx = idaapi.add_hotkey("F5", show_decompiler)
  if hotkey_ctx is None:
    print "Failed to register hotkey!"
    del hotkey_ctx
  else:
    print "Press F5 to decompile a function."
Example #27
0
def main():
  global hotkey_ctx
  try:
    hotkey_ctx
    if idaapi.del_hotkey(hotkey_ctx):
      print("Hotkey unregistered!")
      del hotkey_ctx
    else:
      print("Failed to delete hotkey!")
  except:
      pass
  hotkey_ctx = idaapi.add_hotkey("F5", show_decompiler)
  if hotkey_ctx is None:
    print("Failed to register hotkey!")
    del hotkey_ctx
  else:
    print("Press F5 to decompile a function.")
    def init(self):
        """Initialize the plugin."""
        # Set debugging flag during development
        self.debug = True

        self.print_banner()
        try:
            #
            # Initializing decompiler in order to know if the current
            # architecture is supported or not.
            #
            self.decompiler = PointSource()

            #
            # Registering shortcuts.
            #
            new_menu = idaapi.add_menu_item("Edit/Plugins", "-", None, 0,
                                            self.do_nothing, ())
            if not new_menu:
                #print "[-] Unable to add menu separator."
                del new_menu
            new_menu = idaapi.add_menu_item(
                "Edit/Plugins", "PointSource : Decompile function",
                self.DECOMPILE_HOTKEY, 0, self.decompile_function, ())
            if not new_menu:
                #print "[-] Unable to add menu item."
                del new_menu

            new_hotkey = idaapi.add_hotkey(self.DECOMPILE_HOTKEY,
                                           self.decompile_function)
            if not new_hotkey:
                #print "[-] Unable to add hotkey."
                del new_hotkey

            # Remain in memory because this is a supported architecture and
            # we'll get some work to do.
            return idaapi.PLUGIN_KEEP

        except PointSourceException, err:
            print "[-] Unable to initialize decompiler : %s" % err
Example #29
0
def main(signatures_root, project_name, symbols_file=None):
    global fa_instance

    IdaLoader.log('''
    ---------------------------------
    FA Loaded successfully

    Quick usage:
    fa_instance.set_project(project_name) # select project name
    print(fa_instance.list_projects()) # prints available projects
    print(fa_instance.find(symbol_name)) # searches for the specific symbol
    fa_instance.get_python_symbols(filename=None) # run project's python
                                                    scripts (all or single)
    fa_instance.symbols() # searches for the symbols in the current project

    HotKeys:
    Ctrl-6: Set current project
    Ctrl-7: Search project symbols
    Ctrl-8: Create temporary signature
    Ctrl-Shift-8: Create temporary signature and open an editor
    Ctrl-9: Find temporary signature
    Ctrl-0: Prompt for adding the temporary signature as permanent
    ---------------------------------''')
    fa_instance = IdaLoader()
    fa_instance.set_input('ida')
    fa_instance.set_project(project_name)

    idaapi.add_hotkey('Ctrl-6', fa_instance.interactive_set_project)
    idaapi.add_hotkey('Ctrl-7', fa_instance.symbols)
    idaapi.add_hotkey('Ctrl-8', fa_instance.create_symbol)
    idaapi.add_hotkey('Ctrl-Shift-8', fa_instance.extended_create_symbol)
    idaapi.add_hotkey('Ctrl-9', fa_instance.find_symbol)
    idaapi.add_hotkey('Ctrl-0', fa_instance.prompt_save_signature)

    if symbols_file is not None:
        fa_instance.set_signatures_root(signatures_root)
        fa_instance.symbols(symbols_file)
        ida_pro.qexit(0)
Example #30
0
 def add(cls, key, fn):
     """map a key to a python function"""
     if key in cls.hotkey:
         idaapi.del_hotkey(cls.hotkey[key])
     cls.hotkey[key] = res = idaapi.add_hotkey(key, fn)
     return res
Example #31
0
import os
import idaapi
import idautils
import clipboard


def copy_windbg_bp():
    bp = 'bu @!"{}"+0x{:X}'.format(
        os.path.splitext(idaapi.get_root_filename())[0],
        idaapi.get_screen_ea() - idautils.peutils_t().imagebase)
    clipboard.copy(bp)


idaapi.add_hotkey('3', copy_windbg_bp)
Example #32
0
    ('Replace with nops', True , ['Alt', 'N'], 'nopout.png', nopout),
    ('Nops all Xrefs'   , True , ['Alt', 'X'], 'nopxrefs.png', nopxrefs),
    ('Assemble'         , True , ['Alt', 'P'], 'assemble.png', assemble),
    ('Toggle jump'      , True , ['Alt', 'J'], 'togglejump.png', togglejump),
    ('Force jump'       , True , ['Ctrl', 'Alt', 'F'], 'uncondjump.png', uncondjump),
    ('Undo Patch'       , False, ['Alt', 'Z'], None, undo),
    ('Redo Patch'       , False, ['Alt', 'Y'], None, redo),
    ('Save File'        , False, ['Alt', 'S'], None, savefile),
    ('Find Code Caves'  , False, ['Alt', 'C'], None, openspelunky),
    ('Neuter Binary'    , False, ['Ctrl', 'Alt', 'N'], None, neuter)
]


#Register hotkeys
for name, in_menu, keys, icon, func in hotkeys:
    idaapi.add_hotkey('-'.join(keys), func)


#Register menu items
if QtCore:
    qta = QtCore.QCoreApplication.instance()

    qdata = []
    for name, in_menu, keys, icon, func in (i for i in hotkeys if i[1]):
        qact = QtGui.QAction(QtGui.QIcon(os.path.join(ftl_path, 'icons', icon)), name, qta)
        qact.triggered.connect(func)

        qks = QtGui.QKeySequence('+'.join(keys))
        qact.setShortcut(qks)
        qdata.append(qact)
    fl = FlossLib()
    decryptV.Show()
    time.sleep(1)
    print "[+] Load Floss Module"
    decryptlist = fl.do_floss()
    for de in decryptlist:
        try:
            addr = de.decoded_at_va
        except:
            continue
        tmp = "DecryptEA: 0x%x | DecryptString: %s" % (de.decoded_at_va,
                                                       de.s.encode())
        decryptV.AddLine(tmp)
    decryptV.Refresh()


#---------------------------------------------------------------------
if __name__ == "__main__":
    # Global Variable - BackTrace
    PluginActiveFlag = False
    backtraceV = idaapi.simplecustviewer_t()
    backtraceV.Create("BackTrace")
    backtracef_hook = None
    backtracef_hook = TraceFunctionHook()

    decryptV = idaapi.simplecustviewer_t()
    decryptV.Create("DecryptList")
    # Create HotKey
    idaapi.add_hotkey("F3", ChangePluginStatus)
    idaapi.add_hotkey("F4", Floss)
Example #34
0
 def init(self):
     self.hotkeys = []
     self.hotkeys.append(idaapi.add_hotkey("Ctrl+Alt+C", copy_current_address))
     self.hotkeys.append(idaapi.add_hotkey("Ctrl+Shift+C", copy_current_selection))
     return idaapi.PLUGIN_KEEP
Example #35
0
import idc
import idautils
import idaapi


def test():
    print('test')


#idc.AddHotkey('z', 'test')

hotkey_ctx = idaapi.add_hotkey('z', test)
if hotkey_ctx is None:
    print('Failed to register hotkey!')
    del hotkey_ctx
else:
    print('Hotkey registered!')
Example #36
0
import idaapi
Example #37
0
 def map(cls, key, callable):
     '''Map a specific `key` to a python `callable`.'''
     if key in cls.hotkey:
         idaapi.del_hotkey(cls.hotkey[key])
     cls.hotkey[key] = res = idaapi.add_hotkey(key, callable)
     return res
Example #38
0
    ("Replace with nops", True, ["Alt", "N"], "nopout.png", nopout),
    ("Nops all Xrefs", True, ["Alt", "X"], "nopxrefs.png", nopxrefs),
    ("Assemble", True, ["Alt", "P"], "assemble.png", assemble),
    ("Toggle jump", True, ["Alt", "J"], "togglejump.png", togglejump),
    ("Force jump", True, ["Ctrl", "Alt", "F"], "uncondjump.png", uncondjump),
    ("Undo Patch", False, ["Alt", "Z"], None, undo),
    ("Redo Patch", False, ["Alt", "Y"], None, redo),
    ("Save File", False, ["Alt", "S"], None, savefile),
    ("Find Code Caves", False, ["Alt", "C"], None, openspelunky),
    ("Neuter Binary", False, ["Ctrl", "Alt", "N"], None, neuter),
]


# Register hotkeys
for name, in_menu, keys, icon, func in hotkeys:
    idaapi.add_hotkey("-".join(keys), func)


# Register menu items
if QtCore:
    qta = QtCore.QCoreApplication.instance()

    qdata = []
    for name, in_menu, keys, icon, func in (i for i in hotkeys if i[1]):
        qact = QtGui.QAction(QtGui.QIcon(os.path.join(ftl_path, "icons", icon)), name, qta)
        qact.triggered.connect(func)

        qks = QtGui.QKeySequence("+".join(keys))
        qact.setShortcut(qks)
        qdata.append(qact)
Example #39
0
    # a search index ("simhash.index"), a metadata file ("simhash.meta"), and
    # optionally a feature weights file ("simhash.weights").
    data_directory = AskStr(
        "/var/tmp/",
        "Please enter a data directory. If no index is found, it will be created."
    )
    while not os.path.exists(data_directory):
        data_directory = AskStr("/var/tmp/",
                                "Please enter an EXISTING data directory.")

    index_file = os.path.join(data_directory, "simhash.index")
    metadata_file = os.path.join(data_directory, "simhash.meta")
    weights_file = os.path.join(data_directory, "simhash.weights")

    # Register the hotkeys for the plugin.
    hotkey_context_S = idaapi.add_hotkey("Shift-S", save_function)
    hotkey_context_L = idaapi.add_hotkey("Shift-L", load_function)
    hotkey_context_H = idaapi.add_hotkey("Shift-H", print_hash)
    hotkey_context_A = idaapi.add_hotkey("Shift-A", save_all_functions)
    hotkey_context_M = idaapi.add_hotkey("Shift-M", match_all_functions)
    if None in [
            hotkey_context_S, hotkey_context_L, hotkey_context_H,
            hotkey_context_A, hotkey_context_M
    ]:
        print("FunctionSimSearch: Failed to register hotkeys.")
        del hotkey_context_S
        del hotkey_context_L
        del hotkey_context_H
        del hotkey_context_A
        del hotkey_context_M
    else:
Example #40
0
                                    stream=True,
                                    verify=False)

                # handle the response
                try:
                    if resp.status_code is not 200:
                        Warning(
                            "Server did not respond with status 200. Message:\n"
                            + data)
                    else:
                        with open(local_path, "wb") as f:
                            f.write(resp.raw.read())
                except:
                    Warning("Error!")

    Message("Done. Files saved to folder {}".format(libpath))


if __name__ == "__main__":
    # we try to setup a hotkey to make re-running the script easier
    if add_hotkey("Ctrl-Shift-B", main) is None:
        Message(
            "Failed to set hotkey, please re-run this script to download other IDBs"
        )
    else:
        Message(
            "Hotkey registered, press Ctrl-Shift-B to download another library"
        )

    main()
        print("FunctionSimSearch: Hotkey S unregistered.")
        del hotkey_context_S
    else:
        print("FunctionSimSearch: Failed to unregister hotkey S.")
    hotkey_context_L
    if idaapi.del_hotkey(hotkey_context_L):
        print("FunctionSimSearch: Hotkey L unregistered.")
        del hotkey_context_L
    else:
        print("FunctionSimSearch: Failed to unregister hotkey L.")
    search_index
    sim_hasher
    del search_index
    del sim_hasher
except:
    hotkey_context_S = idaapi.add_hotkey("Shift-S", save_function)
    hotkey_context_L = idaapi.add_hotkey("Shift-L", load_function)
    if hotkey_context_S is None or hotkey_context_L is None:
        print("FunctionSimSearch: Failed to register hotkeys.")
        del hotkey_context_S
        del hotkey_context_L
    else:
        print("FunctionSimSearch: Hotkeys registered.")
    create_index = True
    if os.path.isfile('/tmp/example.simhash'):
        create_index = False
    if os.path.isfile('/tmp/example.simhash.meta'):
        print("Parsing meta_data")
        meta_data = parse_function_meta_data('/tmp/example.simhash.meta')
        print("Parsed meta_data")
        for i in meta_data.keys()[0:10]:
Example #42
0
 def init(self):
     self.hotkeys = []
     self.hotkeys.append(idaapi.add_hotkey("Alt+0", show_current_function_meaningful))
     self.hotkeys.append(idaapi.add_hotkey("Ctrl+Alt+0", show_highlighted_function_meaningful))
     return idaapi.PLUGIN_KEEP
Example #43
0
		ea = ea + len
	
	return curSig
 
def hotkey_pressed():
	CreatePattern()

try:
	hotkey_ctx
	if idaapi.del_hotkey(hotkey_ctx):
		print("CreateSignature hotkey unregistered!")
		del hotkey_ctx
	else:
		print("Failed to delete CreateSignature hotkey!")
except:
	hotkey_ctx = idaapi.add_hotkey("Ctrl+Shift+Alt+S", hotkey_pressed)
	if hotkey_ctx is None:
		print("Failed to register CreateSignature hotkey!")
		del hotkey_ctx
	else:
		print("CreateSignature hotkey registered to Ctrl+Shift+Alt+S!")
		
try:
	hotkey_scs
	if idaapi.del_hotkey(hotkey_scs):
		print("SearchSignature hotkey unregistered!")
		del hotkey_scs
	else:
		print("Failed to delete SearchSignature hotkey!")
except:
	hotkey_scs = idaapi.add_hotkey("Ctrl+Shift+Alt+D", SignatureSearch)
Example #44
0
from __future__ import print_function
#---------------------------------------------------------------------
# This script demonstrates the usage of hotkeys.
#
#
# Author: IDAPython team
#---------------------------------------------------------------------
import idaapi

def hotkey_pressed():
    print("hotkey pressed!")

try:
    hotkey_ctx
    if idaapi.del_hotkey(hotkey_ctx):
        print("Hotkey unregistered!")
        del hotkey_ctx
    else:
        print("Failed to delete hotkey!")
except:
    hotkey_ctx = idaapi.add_hotkey("Shift-A", hotkey_pressed)
    if hotkey_ctx is None:
        print("Failed to register hotkey!")
        del hotkey_ctx
    else:
        print("Hotkey registered!")
Example #45
0
#Hotkey definitions
hotkeys = [('Replace with nops', True, ['Alt', 'N'], 'nopout.png', nopout),
           ('Nops all Xrefs', True, ['Alt', 'X'], 'nopxrefs.png', nopxrefs),
           ('Assemble', True, ['Alt', 'P'], 'assemble.png', assemble),
           ('Toggle jump', True, ['Alt', 'J'], 'togglejump.png', togglejump),
           ('Force jump', True, ['Ctrl', 'Alt',
                                 'F'], 'uncondjump.png', uncondjump),
           ('Undo Patch', False, ['Alt', 'Z'], None, undo),
           ('Redo Patch', False, ['Alt', 'Y'], None, redo),
           ('Save File', False, ['Alt', 'S'], None, savefile),
           ('Find Code Caves', False, ['Alt', 'C'], None, openspelunky),
           ('Neuter Binary', False, ['Ctrl', 'Alt', 'N'], None, neuter)]

#Register hotkeys
for name, in_menu, keys, icon, func in hotkeys:
    idaapi.add_hotkey('-'.join(keys), func)

#Register menu items
if QtCore:
    qta = QtCore.QCoreApplication.instance()

    qdata = []
    for name, in_menu, keys, icon, func in (i for i in hotkeys if i[1]):
        qact = QtGui.QAction(
            QtGui.QIcon(os.path.join(ftl_path, 'icons', icon)), name, qta)
        qact.triggered.connect(func)

        qks = QtGui.QKeySequence('+'.join(keys))
        qact.setShortcut(qks)
        qdata.append(qact)