コード例 #1
0
ファイル: __init__.py プロジェクト: Averroes/mhn
def create_clean_db():
    """
    Use from a python shell to create a fresh database.
    """
    with mhn.test_request_context():
        db.create_all()
        # Creating superuser entry.
        superuser = user_datastore.create_user(
                email=mhn.config.get('SUPERUSER_EMAIL'),
                password=encrypt(mhn.config.get('SUPERUSER_PASSWORD')))
        adminrole = user_datastore.create_role(name='admin', description='')
        user_datastore.add_role_to_user(superuser, adminrole)
        user_datastore.create_role(name='user', description='')
        db.session.flush()

        apikey = ApiKey(user_id=superuser.id, api_key=str(uuid.uuid4()).replace("-", ""))
        db.session.add(apikey)
        db.session.flush()

        from os import path

        from mhn.api.models import DeployScript, RuleSource
        from mhn.tasks.rules import fetch_sources
        # Creating a initial deploy scripts.
        # Reading initial deploy script should be: ../../scripts/
        #|-- deploy_conpot.sh
        #|-- deploy_dionaea.sh
        #|-- deploy_snort.sh
        #|-- deploy_kippo.sh
        deployscripts = {
            'Ubuntu - Conpot': path.abspath('../scripts/deploy_conpot.sh'),
            'Ubuntu - Dionaea': path.abspath('../scripts/deploy_dionaea.sh'),
            'Ubuntu - Snort': path.abspath('../scripts/deploy_snort.sh'),
            'Ubuntu - Kippo': path.abspath('../scripts/deploy_kippo.sh'),
            'Ubuntu - Amun': path.abspath('../scripts/deploy_amun.sh'),
            'Ubuntu - Glastopf': path.abspath('../scripts/deploy_glastopf.sh'),
            'Ubuntu - Wordpot': path.abspath('../scripts/deploy_wordpot.sh'),
            'Ubuntu - Shockpot': path.abspath('../scripts/deploy_shockpot.sh'),
            'Raspberry Pi - Dionaea': path.abspath('../scripts/deploy_raspberrypi.sh'),
        }
        for honeypot, deploypath in deployscripts.iteritems():

            with open(deploypath, 'r') as deployfile:
                initdeploy = DeployScript()
                initdeploy.script = deployfile.read()
                initdeploy.notes = 'Initial deploy script for {}'.format(honeypot)
                initdeploy.user = superuser
                initdeploy.name = honeypot
                db.session.add(initdeploy)

        # Creating an initial rule source.
        rules_source = mhn.config.get('SNORT_RULES_SOURCE')
        if not mhn.config.get('TESTING'):
            rulesrc = RuleSource()
            rulesrc.name = rules_source['name']
            rulesrc.uri = rules_source['uri']
            rulesrc.name = 'Default rules source'
            db.session.add(rulesrc)
            db.session.commit()
            fetch_sources()
コード例 #2
0
ファイル: __init__.py プロジェクト: Cyberwatch/mhn
def create_clean_db():
    """
    Use from a python shell to create a fresh database.
    """
    with mhn.test_request_context():
        db.create_all()
        # Creating superuser entry.
        superuser = user_datastore.create_user(
                email=mhn.config.get('SUPERUSER_EMAIL'),
                password=encrypt(mhn.config.get('SUPERUSER_PASSWORD')))
        adminrole = user_datastore.create_role(name='admin', description='')
        user_datastore.add_role_to_user(superuser, adminrole)
        user_datastore.create_role(name='user', description='')

        from os import path

        from mhn.api.models import DeployScript, RuleSource
        from mhn.tasks.rules import fetch_sources
        # Creating a initial deploy scripts.
        # Reading initial deploy script should be: ../../scripts/
        #|-- deploy_conpot.sh
        #|-- deploy_dionaea.sh
        #|-- deploy_snort.sh
        deployscripts = {
            'Conpot': path.abspath('../scripts/deploy_conpot.sh'),
            'Dionaea': path.abspath('../scripts/deploy_dionaea.sh'),
            'Snort': path.abspath('../scripts/deploy_snort.sh'),
        }
        for honeypot, deploypath in deployscripts.iteritems():

            with open(deploypath, 'r') as deployfile:
                initdeploy = DeployScript()
                initdeploy.script = deployfile.read()
                initdeploy.notes = 'Initial deploy script for {}'.format(honeypot)
                initdeploy.user = superuser
                initdeploy.name = 'Ubuntu 12.04 {}'.format(honeypot)
                db.session.add(initdeploy)

        # Creating an initial rule source.
        rules_source = mhn.config.get('SNORT_RULES_SOURCE')
        if not mhn.config.get('TESTING'):
            rulesrc = RuleSource()
            rulesrc.name = rules_source['name']
            rulesrc.uri = rules_source['uri']
            rulesrc.name = 'Default rules source'
            db.session.add(rulesrc)
            db.session.commit()
            fetch_sources()
コード例 #3
0
def create_clean_db():
    """
    Use from a python shell to create a fresh database.
    """
    with mhn.test_request_context():
        db.create_all()
        # Creating superuser entry.
        superuser = user_datastore.create_user(
            email=mhn.config.get('SUPERUSER_EMAIL'),
            password=encrypt(mhn.config.get('SUPERUSER_PASSWORD')))
        adminrole = user_datastore.create_role(name='admin', description='')
        user_datastore.add_role_to_user(superuser, adminrole)
        user_datastore.create_role(name='user', description='')
        db.session.flush()

        apikey = ApiKey(user_id=superuser.id,
                        api_key=str(uuid.uuid4()).replace("-", ""))
        db.session.add(apikey)
        db.session.flush()

        from os import path

        from mhn.api.models import DeployScript, RuleSource
        from mhn.tasks.rules import fetch_sources
        # Creating a initial deploy scripts.
        # Reading initial deploy script should be: ../../scripts/
        #|-- deploy_conpot.sh
        #|-- deploy_dionaea.sh
        #|-- deploy_snort.sh
        #|-- deploy_kippo.sh
        deployscripts = {
            'Ubuntu - Conpot':
            path.abspath('../scripts/deploy_conpot.sh'),
            'Ubuntu - Dionaea':
            path.abspath('../scripts/deploy_dionaea.sh'),
            'Ubuntu - Snort':
            path.abspath('../scripts/deploy_snort.sh'),
            'Ubuntu - Kippo':
            path.abspath('../scripts/deploy_kippo.sh'),
            'Ubuntu - Amun':
            path.abspath('../scripts/deploy_amun.sh'),
            'Ubuntu - Glastopf':
            path.abspath('../scripts/deploy_glastopf.sh'),
            'Ubuntu - Wordpot':
            path.abspath('../scripts/deploy_wordpot.sh'),
            'Ubuntu - Shockpot':
            path.abspath('../scripts/deploy_shockpot.sh'),
            'Ubuntu - p0f':
            path.abspath('../scripts/deploy_p0f.sh'),
            'Raspberry Pi - Dionaea':
            path.abspath('../scripts/deploy_raspberrypi.sh'),
        }
        for honeypot, deploypath in deployscripts.iteritems():

            with open(deploypath, 'r') as deployfile:
                initdeploy = DeployScript()
                initdeploy.script = deployfile.read()
                initdeploy.notes = 'Initial deploy script for {}'.format(
                    honeypot)
                initdeploy.user = superuser
                initdeploy.name = honeypot
                db.session.add(initdeploy)

        # Creating an initial rule source.
        rules_source = mhn.config.get('SNORT_RULES_SOURCE')
        if not mhn.config.get('TESTING'):
            rulesrc = RuleSource()
            rulesrc.name = rules_source['name']
            rulesrc.uri = rules_source['uri']
            rulesrc.name = 'Default rules source'
            db.session.add(rulesrc)
            db.session.commit()
            fetch_sources()
コード例 #4
0
ファイル: manage.py プロジェクト: robinlennox/CHN-Server
 def fetch_rules():
     fetch_sources()
コード例 #5
0
ファイル: manage.py プロジェクト: Adaptivestack/mhn
 def fetch_rules():
     fetch_sources()