forked from 88d52bdba0366127fffca9dfa93895/cuckoomx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cuckoomx.py
executable file
·74 lines (60 loc) · 2.38 KB
/
cuckoomx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# Copyright (C) 2010-2015 Cuckoo Foundation.
# This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org
# See the file 'docs/LICENSE' for copying permission.
import os
import sys
import logging
import argparse
from multiprocessing import Process
from lib.cuckoomx.common.exceptions import CuckooCriticalError
from lib.cuckoomx.common.exceptions import CuckooDependencyError
from lib.cuckoomx.common.config import Config
from lib.cuckoomx.common.constants import CUCKOOMX_VERSION
from lib.cuckoomx.core.offside import offside
from lib.cuckoomx.core.checking import checking
from lib.cuckoomx.core.startup import check_configs
from lib.cuckoomx.core.startup import init_logging
from lib.cuckoomx.core.startup import init_database
from lib.cuckoomx.core.startup import create_structure
from lib.cuckoomx.core.startup import cuckoomx_clean
log = logging.getLogger()
def cuckoomx_init(quiet=False, debug=False):
check_configs()
create_structure()
init_logging()
init_database()
if quiet:
log.setLevel(logging.WARN)
elif debug:
log.setLevel(logging.DEBUG)
def cuckoomx_main():
try:
thread_offside = Process(target=offside)
thread_offside.start()
thread_checking = Process(target=checking)
thread_checking.start()
thread_offside.join()
thread_checking.join()
except Exception as e:
log.error("Fail to run CuckooMX: %s", e)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-q", "--quiet", help="Display only error messages", action="store_true", required=False)
parser.add_argument("-d", "--debug", help="Display debug messages", action="store_true", required=False)
parser.add_argument("-v", "--version", action="version", version="You are running CuckooMX {0}".format(CUCKOOMX_VERSION))
parser.add_argument("--clean", help="Remove database and log of CuckooMX", action='store_true', required=False)
args = parser.parse_args()
if args.clean:
cuckoomx_clean()
sys.exit(0)
try:
cuckoomx_init(quiet=args.quiet, debug=args.debug)
cuckoomx_main()
except CuckooCriticalError as e:
message = "{0}: {1}".format(e.__class__.__name__, e)
if len(log.handlers):
log.critical(message)
else:
sys.stderr.write("{0}\n".format(message))
sys.exit(1)