示例#1
0
文件: fuzzer.py 项目: xct/pathfinder
 def __init__(self):
     self.cores = multiprocessing.cpu_count()
     self.warmup = 20
     self.parse_arguments()
     self.parse_config()
     self.p = angr.Project(
         self.args[0],
         exclude_sim_procedures_list=self.exclude_sim_procedures_list,
         load_options={'auto_load_libs': self.simlibs})
     self.drun = self.drun.replace("@", str(self.p.arch.bits))
     self.dtrace = self.dtrace.replace("@", str(self.p.arch.bits))
     self.sym_file_name = "symbolic_file"
     self.map = dict()  # mapping addr to random values to encode edges
     self.bitmap = dict()  # map of all encoded edges (of multiple inputs)
     # same as bitmap but for edges that are never explored (artifacts from
     # concrete trace)
     self.blacklist = []
     self.setup_directories()
     self.new = utils.Cache("new", self.temp_dir)
     self.delayed = utils.Cache("delayed", self.temp_dir)
     txt = "Fuzzing " + self.cmd + "\n"
     txt += "Hybrid: " + str(self.hybrid)
     utils.write_file(self.temp_dir + "stats", txt, "w")
     print("[+] Setup complete\n[+] Identified " + \
         str(self.cores) + " usable cores")
     print("[!] Please use echo core > /proc/sys/kernel/core_pattern before using this program")
     self.simfiles = []
     if self.verbose:
         self.msg = utils.msg
     else:
         self.msg = utils.dummy
示例#2
0
 def shutdown(self):
     """Stop components"""
     for component in utils.Cache().get('components').keys():
         if utils.Cache().get([component,
                               'type']) == utils.Constants.PROCESS:
             self.stop_process(component)
     self.logging.info('All done, bye')
示例#3
0
    def stop_process(self, process_name):
        """"""

        proc = utils.Cache().get(['components', process_name])
        if proc:
            if proc['process'].is_alive():
                proc['process'].join()
                self.logging.info('Component {} stopped'.format(process_name))
                utils.Cache().delete(['components', process_name])
        else:
            self.logging.info('Unknown process {}'.format(process_name))
示例#4
0
 def __init__(self):
     """"""
     utils.parse_config()
     self.logging = getLogger(ContextManager.__class__.__name__)
     self.manager_loop = lambda: self.__isrunning
     utils.Cache(components={})
     utils.Cache(storage={})
     BackendServerMQ.__init__(
         self,
         **utils.Cache().get('config.core.backend.kwargs'))
     self.logging.info('IoT Manager started at pid: {}'.format(os.getpid()))
     self.logging.info('Starting components...')
     self.start_framework()
     threading.Thread.__init__(self)
示例#5
0
    def start_framework(self):
        """Start all registered / non - started workers.

        Check core.util.COMPONENTS to add new components.
        """
        try:
            self.listen()
        except zmq.ZMQError as e:
            self.logging.warning('Error registering channel: {} - {}' \
                .format(self.mq_uri, e))

        for component in utils.Cache().get('config.components').keys():
            if utils.Cache().get(['config', 'components', component, 'type']) \
            == utils.Constants.PROCESS:
                self.start_process(component)
示例#6
0
    def start_process(self, component_name):
        """Starts a child process component and update component mapping object."""
        comp = utils.Cache().get(['config', 'components', component_name])
        method = comp.get('start')
        kwargs = comp.get('kwargs')
        path = comp.get('path')

        try:
            imp = importlib.import_module(path)
            proc = multiprocessing.Process(target=getattr(imp, method),
                                           kwargs=kwargs)
            proc.start()
        except (ImportError, multiprocessing.ProcessError) as err:
            self.logging.critical('Error starting {}: {}'.format(
                component_name, err))
        else:
            self.logging.info('{} started with pid: {} (child)'.format(
                component_name, proc.pid))
            self.components[component_name] = utils.Cache().set(['components', component_name], \
                                                                {'pid': proc.pid, 'process': proc, 'type': utils.Constants.PROCESS})
示例#7
0
 def __init__(self, settings={}):
     self.settings = settings
     self.lkf_api = utils.Cache(settings)
示例#8
0
                error,
            (
                commands.InvalidEndOfQuotedStringError,
                commands.ExpectedClosingQuoteError,
                commands.UnexpectedQuoteError,
            ),
        ):
            await ctx.message.channel.send(
                "Quotes must go around the arguments you want to provide to the command,"
                " recheck where your quotes are")
        else:
            await utils.log_error(error, ctx.bot, ctx)
    except discord.HTTPException:
        pass


if __name__ == "__main__":
    bot.remove_command("help")
    # Setup our bot vars, db and cache
    bot.db = utils.DB()
    bot.cache = utils.Cache(bot.db)
    bot.error_channel = utils.error_channel
    # Start our startup task (cache sets up the database, so just this)
    bot.loop.create_task(bot.cache.setup())
    for e in utils.extensions:
        bot.load_extension(e)

    bot.uptime = pendulum.now(tz="UTC")
    bot.chunked_guild_locks = {}
    bot.run(utils.bot_token)