Beispiel #1
0
    def init(self):
        info = idaapi.get_inf_structure()
        # IDA 6/7 compat
        procname = info.procname if hasattr(
            info, 'procname') else info.get_proc_name()[0]
        if procname != 'metapc' and procname != 'ARM' and procname != 'PPC':
            bc_log.info("CPU '%s' is not supported, not loading BinCAT",
                        procname)
            return idaapi.PLUGIN_SKIP
        try:
            from pybincat import cfa as cfa_module
            global cfa_module
        except:
            bc_log.warning("Failed to load 'pybincat.cfa' python module\n%s",
                           repr(sys.exc_info()))
            return idaapi.PLUGIN_SKIP
        PluginOptions.init()

        # add plugin's 'bin' dir to PATH
        userdir = idaapi.get_user_idadir()
        bin_path = os.path.join(userdir, "plugins", "idabincat", "bin")
        if os.path.isdir(bin_path):
            path_env_sep = ';' if os.name == 'nt' else ':'
            os.environ['PATH'] += path_env_sep + bin_path
        if no_spawn:
            bc_exe = None
        else:
            # Check if bincat is available
            bc_exe = distutils.spawn.find_executable('bincat')
        if bc_exe is None:
            if no_spawn:
                bc_exe = os.path.join(bin_path, "bincat")
            else:
                bc_exe = distutils.spawn.find_executable('bincat')
        if bc_exe is None and no_spawn is False:
            bc_log.warning(
                'Could not find bincat binary, will not be able to run local analysis'
            )

        if PluginOptions.get("autostart") != "True":
            # will initialize later
            return idaapi.PLUGIN_OK

        bc_log.info("Autostarting")

        self.state = State()
        self.initialized = True
        bc_log.info("IDABinCAT ready.")
        return idaapi.PLUGIN_KEEP
Beispiel #2
0
    def init(self):
        procname = idaapi.get_inf_structure().get_proc_name()
        if procname[0] != 'metapc':
            bc_log.info("Not on x86, not loading BinCAT")
            return idaapi.PLUGIN_SKIP
        try:
            from pybincat import cfa as cfa_module
            global cfa_module
        except:
            bc_log.warning("Failed to load 'pybincat.cfa' python module\n%s",
                           repr(sys.exc_info()))
            return idaapi.PLUGIN_SKIP
        PluginOptions.init()

        if no_spawn:
            bc_exe = None
        else:
            # Check if bincat_native is available
            bc_exe = distutils.spawn.find_executable('bincat_native')
        if bc_exe is None and os.name == 'nt':
            # add to PATH
            userdir = idaapi.get_user_idadir()
            bin_path = os.path.join(userdir, "plugins", "idabincat", "bin")
            if os.path.isdir(bin_path):
                os.environ['PATH'] += ";" + bin_path
            if no_spawn:
                bc_exe = os.path.join(bin_path, "bincat_native.exe")
            else:
                bc_exe = distutils.spawn.find_executable('bincat_native')
        if bc_exe is None and no_spawn is False:
            bc_log.warning(
                'Could not find bincat_native binary, will not be able to run analysis'
            )

        if PluginOptions.get("autostart") != "True":
            # will initialize later
            return idaapi.PLUGIN_OK

        bc_log.info("Autostarting")

        self.state = State()
        self.initialized = True
        bc_log.info("IDABinCAT ready.")
        return idaapi.PLUGIN_KEEP
Beispiel #3
0
    def init(self):
        procname = idaapi.get_inf_structure().get_proc_name()
        if procname[0] != 'metapc':
            bc_log.info("Not on x86, not loading BinCAT")
            return idaapi.PLUGIN_SKIP
        try:
            from pybincat import cfa as cfa_module
            global cfa_module
        except:
            bc_log.warning("Failed to load 'pybincat.cfa' python module\n%s",
                           repr(sys.exc_info()))
            return idaapi.PLUGIN_SKIP
        PluginOptions.init()
        if PluginOptions.get("autostart") != "True":
            # will initialize later
            return idaapi.PLUGIN_OK

        bc_log.info("Autostarting")

        self.state = State()
        self.initialized = True
        bc_log.info("IDABinCAT ready.")
        return idaapi.PLUGIN_KEEP