Beispiel #1
0
 def new_analyzer(self, *args, **kwargs):
     """
     returns current Analyzer class (web or local)
     """
     if (PluginOptions.get("web_analyzer") == "True"
             and PluginOptions.get("server_url") != ""):
         return WebAnalyzer(*args, **kwargs)
     else:
         return LocalAnalyzer(*args, **kwargs)
Beispiel #2
0
 def new_analyzer(self, *args, **kwargs):
     """
     returns current Analyzer class (web or local)
     """
     if (PluginOptions.get("web_analyzer") == "True" and
             PluginOptions.get("server_url") != ""):
         if 'requests' not in sys.modules:
             bc_log.error("Trying to launch a remote analysis without the 'requests' module !")
             raise AnalyzerUnavailable()
         return WebAnalyzer(*args, **kwargs)
     else:
         return LocalAnalyzer(*args, **kwargs)
Beispiel #3
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 #4
0
    def __init__(self):
        self.current_ea = None
        self.cfa = None
        self.current_state = None
        self.current_node_ids = []
        #: last run config
        self.current_config = None
        #: config to be edited
        self.edit_config = None
        #: Analyzer instance - protects against merciless garbage collector
        self.analyzer = None
        self.hooks = None
        self.netnode = idabincat.netnode.Netnode("$ com.bincat.bcplugin")
        #: acts as a List of ("eip", "register name", "taint mask")
        #: XXX store in IDB?
        self.overrides = CallbackWrappedList()
        #: list of (name, config)
        self.configurations = AnalyzerConfigurations(self)
        # XXX store in idb after encoding?
        self.last_cfaout_marshal = None
        #: filepath to last dumped remapped binary
        self.remapped_bin_path = None
        self.remap_binary = True
        # for debugging purposes, to interact with this object from the console
        global bc_state
        bc_state = self

        self.gui = GUI(self)
        if PluginOptions.get("load_from_idb") == "True":
            self.load_from_idb()
Beispiel #5
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 #6
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
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     Analyzer.__init__(self, *args, **kwargs)
     self.server_url = PluginOptions.get("server_url").rstrip("/")
     self.reachable_server = False
     self.check_version()  # raises exception if server is unreachable
     self.reachable_server = True