Esempio n. 1
0
    def start(self):
        self.channel = CONFIG.get('output_hpfeed',
                                  'channel',
                                  fallback='elasticpot')

        if CONFIG.has_option('output_hpfeed', 'endpoint'):
            endpoint = CONFIG.get('output_hpfeed', 'endpoint')
        else:
            server = CONFIG.get('output_hpfeed', 'server')
            port = CONFIG.getint('output_hpfeed', 'port')

            if CONFIG.has_option('output_hpfeed', 'tlscert'):
                with open(CONFIG.get('output_hpfeed', 'tlscert')) as fp:
                    authority = ssl.Certificate.loadPEM(fp.read())
                options = ssl.optionsForClientTLS(server, authority)
                endpoint = endpoints.SSL4ClientEndpoint(
                    reactor, server, port, options)
            else:
                endpoint = endpoints.HostnameEndpoint(reactor, server, port)

        try:
            self.tags = [
                tag.strip()
                for tag in CONFIG.get('output_hpfeed', 'tags').split(',')
            ]
        except Exception as e:
            self.tags = []

        ident = CONFIG.get('output_hpfeed', 'identifier')
        secret = CONFIG.get('output_hpfeed', 'secret')

        reported_ip = CONFIG.get('output_hpfeed', 'reported_ip')
        if reported_ip and reported_ip != '':
            self.reported_ip = reported_ip
        else:
            self.reported_ip = None

        self.client = ClientSessionService(endpoint, ident, secret)
        self.client.startService()
Esempio n. 2
0
from core.ui import UI
from core.mysqlquery import MySQLQuery

if __name__ == "__main__":
    UI.banner()

    if len(sys.argv) < 3:
        UI.error(
            "Missing configuration file path or username\n\nUsage: %s config username (optional -nohttpd)"
            % sys.argv[0], True)

    config = CONFIG(sys.argv[1])
    if config.reload_config():
        config = CONFIG(sys.argv[1])

    profile = config.get("http-profile")
    if not profile == "":
        Utils.file_exists(profile, True)
        profile = CONFIG(profile)
        config.set("profile", profile)

    uid = Utils.guid()
    config.set("uid", uid)
    config.set("username", "(CLI)%s" % sys.argv[2])
    db = RedisQuery(config)
    sql = MySQLQuery(config)
    sql.install_db().init_uid()

    config.set("redis", db)
    config.set("mysql", sql)
Esempio n. 3
0
from core.httpd import init_httpd_thread
from core.gui import init_gui_thread
from core.cli import Cli

if __name__ == '__main__':

    if len(sys.argv) < 3:
        UI.error(
            '''Missing configuration file path or username\n\n Usage: %s config username (optional -nohttpd, -nogui)'''
            % sys.argv[0], True)

    config = CONFIG(sys.argv[1])
    if config.reload_config():
        config = CONFIG(sys.argv[1])

    profile = config.get('http-profile')
    if not profile == '':
        Utils.file_exists(profile, True)
        profile = CONFIG(profile)
        config.set('profile', profile)

    uid = Utils.guid()
    config.set('uid', uid)
    config.set('username', '%s' % sys.argv[2])
    db = RedisQuery(config)

    config.set('redis', db)

    UI.warn('Current Active CLI session UUID is %s' % config.get('uid'))

    cli = Cli(config)
Esempio n. 4
0
from core.gui import init_gui_thread
from core.cli import Cli
from core.mysqlquery import MySQLQuery

if __name__ == '__main__':

    if len(sys.argv) < 3:
        UI.error(
            '''Missing configuration file path or username\n\n Usage: %s config username (optional -nohttpd, -gui)'''
            % sys.argv[0], True)

    config = CONFIG(sys.argv[1])
    if config.reload_config():
        config = CONFIG(sys.argv[1])

    profile = config.get('http-profile')
    if not profile == '':
        Utils.file_exists(profile, True)
        profile = CONFIG(profile)
        config.set('profile', profile)

    uid = Utils.guid()
    config.set('uid', uid)
    config.set('username', '(CLI)%s' % sys.argv[2])
    db = RedisQuery(config)
    sql = MySQLQuery(config)
    sql.install_db().init_uid()

    config.set('redis', db)
    config.set('mysql', sql)