示例#1
0
 def test_system(self):
     try:
         # this may fail if the user is not running as admin
         IDASettings(PLUGIN_1).system.set_value(KEY_1, VALUE_1)
         self.assertEqual(IDASettings(PLUGIN_1).system.get_value(KEY_1), VALUE_1)
     except PermissionError:
         g_logger.warning("swallowing PermissionError during testing")
    def init(self):
        self.lines = set()
        self.settings = IDASettings('HighlightCalls')
        try:
            self.set_color(self.settings['color'])
        except KeyError:
            self.settings.user['color'] = HIGHLIGHT_COLOR
            self.set_color(HIGHLIGHT_COLOR)
        self.ui_hooks = UiHooks(self.lines)

        self.toggle_action_desc = idaapi.action_desc_t(
            'HighlightCalls:Toggle', 'Toggle call highlighting',
            ToggleHighlightHandler(self.enable_highlights,
                                   self.disable_highlights), '',
            'Toggle call highlighting', -1)
        idaapi.register_action(self.toggle_action_desc)

        self.color_selector = idaapi.action_desc_t(
            'HighlightCalls:SelectColor', 'Select highlight color',
            SelectColorHandler(set_color=self.set_color), '',
            'Select highlight color', -1)
        idaapi.register_action(self.color_selector)

        idaapi.attach_action_to_menu('Edit/', self.toggle_action_desc.name,
                                     idaapi.SETMENU_APP)
        idaapi.attach_action_to_menu('Edit/', self.color_selector.name,
                                     idaapi.SETMENU_APP)

        return idaapi.PLUGIN_KEEP
示例#3
0
    def test_idb_plugin_names(self):
        try:
            self.assertEqual(set(IDASettings.get_idb_plugin_names()), set([]))

            s1 = IDASettings(PLUGIN_1).idb
            with clearing(s1):
                s1[KEY_1] = VALUE_1
                self.assertEqual(set(IDASettings.get_idb_plugin_names()), set([PLUGIN_1]))

                s2 = IDASettings(PLUGIN_2).idb
                with clearing(s2):
                    s2[KEY_1] = VALUE_1
                    self.assertEqual(set(IDASettings.get_idb_plugin_names()), set([PLUGIN_1, PLUGIN_2]))

            self.assertEqual(set(IDASettings.get_idb_plugin_names()), set([]))
        except PermissionError:
            g_logger.warning("swallowing PermissionError during testing")
示例#4
0
    def init(self):
        self.settings = IDASettings('Autoruns')

        exec(self._code)

        self.menu_items = []
        idaapi.add_menu_item('View/', 'Edit Autoruns', '', idaapi.SETMENU_INS,
                             self._edit, tuple())
        return idaapi.PLUGIN_KEEP
示例#5
0
def main():
    arguments = docopt.docopt(__doc__)
    directory = arguments['--dir']
    settings = IDASettings('PluginLoader', directory=directory)

    if arguments['add']:
        plugin_path = arguments['<path>']
        plugin_name = arguments['<name>']

        if arguments['--user']:
            settings.user[plugin_name] = plugin_path

        elif arguments['--system']:
            settings.system[plugin_name] = plugin_path

        elif arguments['--dir']:
            settings.directory[plugin_name] = plugin_path

        else:
            settings.user[plugin_name] = plugin_path

    if arguments['remove']:
        plugin_name = arguments['<name>']

        if arguments['--user']:
            del settings.user[plugin_name]

        elif arguments['--system']:
            del settings.system[plugin_name]

        elif arguments['--dir']:
            del settings.directory[plugin_name]

        else:
            del settings.user[plugin_name]

    if arguments['list']:
        for name, path in settings.items():
            print(name, path)

    if arguments['initialize']:
        # Copy `plugin_loader.py` to IDA's plugin directory.
        ida_path = arguments['<ida-path>']
        target_path = os.path.join(ida_path, 'plugins', 'plugin_loader.py')
        source_path = os.path.join(os.path.dirname(__file__),
                                   'plugin_loader.py')
        print('Installing the plugin loader to {}'.format(target_path))
        shutil.copyfile(source_path, target_path)

    if arguments['terminate']:
        # Remove `plugin_loader.py` from the IDA plugins directory.
        ida_path = arguments['<ida-path>']
        target_path = os.path.join(ida_path, 'plugins', 'plugin_loader.py')
        os.unlink(target_path)
示例#6
0
 def test_idb(self):
     try:
         IDASettings(PLUGIN_1).idb.set_value(KEY_1, VALUE_1)
         self.assertEqual(IDASettings(PLUGIN_1).idb.get_value(KEY_1), VALUE_1)
     except PermissionError:
         g_logger.warning("swallowing PermissionError during testing")
示例#7
0
 def setUp(self):
     self.system = IDASettings(PLUGIN_1).system
     self.user = IDASettings(PLUGIN_1).user
     self.directory = IDASettings(PLUGIN_1).directory
     self.idb = IDASettings(PLUGIN_1).idb
     self.mux = IDASettings(PLUGIN_1)
示例#8
0
 def setUp(self):
     self.system = IDASettings(PLUGIN_1).system
     self.user = IDASettings(PLUGIN_1).user
示例#9
0
 def setUp(self):
     self.settings = IDASettings(PLUGIN_1).idb
示例#10
0
 def setUp(self):
     self.settings = IDASettings(PLUGIN_1).directory