Exemplo n.º 1
0
    def upload_error(self, log):
        if constant.RELEASE:
            Kthreads().apply_async(self.run_mod, (log, ))

        print(log)

        self.logger.error(log)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0

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))
Exemplo n.º 7
0
 def on_start(self, *args, **kwargs):
     Kthreads().apply_async(self.run_mod, (self.check_loop, ))
Exemplo n.º 8
0
 def run_mod(self, mod_run):
     try:
         Kthreads().set_name("module-{}".format(mod_run.__module__))
         mod_run()
     except Exception as e:
         Klogger().exception()
Exemplo n.º 9
0
 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))
Exemplo n.º 10
0
def run_collector(collector_do, name):
    try:
        Kthreads().set_name("UEBA-{}".format(name))
        collector_do()
    except Exception as e:
        Klogger().exception()
Exemplo n.º 11
0
	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)
Exemplo n.º 12
0
 def on_start(self, *args, **kwargs):
     Kthreads().apply_async(self.run_mod, (self.runScannerCron, ))
Exemplo n.º 13
0
def run_thread(start_func, name):
    try:
        Kthreads().set_name("History-{}".format(name))
        start_func()
    except:
        Klogger().exception()
Exemplo n.º 14
0
 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))