def upload_error(self, log): if constant.RELEASE: Kthreads().apply_async(self.run_mod, (log, )) print(log) self.logger.error(log)
def python_main(child_end): try: common.set_work_dir() common.setdefaultencoding("utf8") Kevent().init_signal() if not Kevent().do_initializing(): sys.exit(1) if child_end: Kthreads().apply_async(KPipe().start, (child_end, )) Kthreads().apply_async(Kevent().do_start, ()) Kthreads().join() except Exception as e: traceback.print_exc(file=sys.stdout)
def do_start(self, *args, **kwargs): Kthreads().set_name("Network-thread") for target in self.members: if hasattr(target, "on_start"): target.on_start(*args, **kwargs)
def signal_term_handler(signal, frame): print('signal terminate receive! I am {}'.format(Kthreads().get_name())) Klogger().info("terminate receive pid:{}".format(os.getpid())) Kevent().set_terminate() sys.exit(1)
def signal_int_handler(signal, frame): print('You pressed Ctrl+C! I am {}'.format(Kthreads().get_name())) Klogger().info("INT receive pid:{}".format(os.getpid())) Kevent().set_terminate() sys.exit(2)
def init_config(): common.setdefaultencoding("utf8") common.set_work_dir() common.add_module_path("lib") if not Kconfig().init(): sys.exit(1) Klogger().init() Ksecurity().init() Kmodules().init() def init_network(): Klauncher().set_launcher(LAUNCHER) if __name__ == '__main__': try: init_config() init_network() Kthreads().apply_async(Klauncher().start, ()) Kthreads().join() except Exception as e: traceback.print_exc() Klogger().error(str(e))
def on_start(self, *args, **kwargs): Kthreads().apply_async(self.run_mod, (self.check_loop, ))
def run_mod(self, mod_run): try: Kthreads().set_name("module-{}".format(mod_run.__module__)) mod_run() except Exception as e: Klogger().exception()
def start(self): for c in self.collectors: if c.init(): Kthreads().apply_async(run_collector, (c.do, c.name)) else: Klogger().error("UEBA - {} init failed".format(c.name))
def run_collector(collector_do, name): try: Kthreads().set_name("UEBA-{}".format(name)) collector_do() except Exception as e: Klogger().exception()
def upload_virus(self, pathname, oldname, block = False): if not block: Kthreads().apply_async(self.do_upload_virus, (pathname, oldname)) else: self.do_upload_virus(pathname, oldname)
def on_start(self, *args, **kwargs): Kthreads().apply_async(self.run_mod, (self.runScannerCron, ))
def run_thread(start_func, name): try: Kthreads().set_name("History-{}".format(name)) start_func() except: Klogger().exception()
def on_start(self, *args, **kwargs): for module in self.modules: if module.init(): Kthreads().apply_async(module.start, module.name) else: Klogger().error("History-{} init failed".format(module.name))