def create_app(config): #create_structure() # Define the WSGI application object app = Flask(__name__) app.config['MAX_CONTENT_LENGTH'] = 200 * 1024 * 1024 # 200MB # Configurations app.config.from_object(settings[config]) settings[config].init_app(app) if not app.testing: logo() check_version() check_configs() if app.testing: init_logging('info') else: init_logging('debug') #log.setLevel(logging.DEBUG) init_modules() # Init All Flask Add-ons bootstrap.init_app(app) #pagedown.init_app(app) db.init_app(app) mail.init_app(app) if app.config['USE_LDAP'] == 'yes': # LDAP Login # TODO : Test out LDAP app.add_url_rule('/login', 'login', ldap.login, methods=['GET', 'POST']) ldap.init_app(app) else: login_manager.login_view = 'auth.login' login_manager.init_app(app) if not app.debug and not app.testing and not app.config['SSL_DISABLE']: try: from flask.ext.sslify import SSLify sslify = SSLify(app) except ImportError: from flask.ext.sslify import SSLify raise MaliceDependencyError("Unable to import Flask-SSLify " "(install with `pip install Flask-SSLify`)") # Register blueprint(s) from .malice import malice as malice_blueprint app.register_blueprint(malice_blueprint) from .mod_auth import mod_auth as auth_module app.register_blueprint(auth_module, url_prefix='/auth') # from app.mod_api.controller import mod_api as api_module # app.register_blueprint(api_module, url_prefix='/api/v1') return app
# from lib.common.config import Config from lib.common.constants import MALICE_ROOT from lib.common.exceptions import MaliceDependencyError from lib.common.out import * from lib.core.database import db_insert, is_hash_in_db from lib.scanworker.file import PickleableFileSample from modules import av, file, intel # from app.malice.worker.av.f_prot import scanner as f_prot_engine # from app.malice.worker.file.doc.pdf import pdfparser, pdfid try: import rethinkdb as r except ImportError: raise MaliceDependencyError("Unable to import rethinkdb." "(install with `pip install rethinkdb`)") try: from redis import Redis from rq import Queue from rq.decorators import job except ImportError: raise MaliceDependencyError("Unable to import redis." "(install with `pip install redis`)") q = Queue('low', connection=Redis()) log = logging.getLogger(__name__) # class ScanManager(object): # """Handle Malice scan events.""" #
import ConfigParser import os from flask import flash from lib.common.abstracts import Intel from lib.common.constants import MALICE_ROOT from lib.common.exceptions import MaliceDependencyError from lib.common.utils import list_to_string, split_seq from lib.core.database import db_insert try: from virus_total_apis import PublicApi as vtPubAPI except ImportError: raise MaliceDependencyError("Unable to import virustotal-api " "(install with `pip install virustotal-api`)") try: import rethinkdb as r except ImportError: raise MaliceDependencyError("Unable to import rethinkdb " "(install with `pip install rethinkdb`)") class VirusTotal(Intel): pass def get_config(): VT_API, HTTP_PROXY, HTTPS_PROXY = None, None, None # Read config files intel_config = ConfigParser.SafeConfigParser()
from app.malice.controller import update_upload_file_metadata from app.malice.scans import batch_search_hash, scan_upload, single_hash_search from lib.common.exceptions import MaliceDependencyError from lib.common.utils import list_to_string, parse_hash_list from lib.core.database import (insert_in_samples_db, is_hash_in_db, update_sample_in_db) from . import mod_api as api # from ..models import User from .decorators import get_view_rate_limit, ratelimit try: import rethinkdb as r except ImportError: r = None raise MaliceDependencyError("Unable to import rethinkdb." "(install with `pip install rethinkdb`)") try: import pydeep except ImportError: pydeep = None raise MaliceDependencyError("Unable to import pydeep " "(install with `pip install pydeep`)") try: import magic except ImportError: magic = None raise MaliceDependencyError("Unable to import magic " "(install with `pip install magic`)") @api.route('/search/file', methods=['GET'])
__author__ = 'Josh Maine' __copyright__ = '''Copyright (C) 2013-2014 Josh "blacktop" Maine This file is part of Malice - https://github.com/blacktop/malice See the file 'docs/LICENSE' for copying permission.''' import os import ConfigParser from lib.common.utils import split_seq from lib.core.database import db_insert from lib.common.exceptions import MaliceDependencyError from lib.common.constants import MALICE_ROOT try: import rethinkdb as r except ImportError: raise MaliceDependencyError("Unable to import rethinkdb " "(install with `pip install rethinkdb`)") try: from bit9_api import Bit9Api except ImportError: raise MaliceDependencyError("Unable to import bit9-api " "(install with `pip install bit9-api`)") def get_config(): BIT9_USER, BIT9_PASS, HTTP_PROXY, HTTPS_PROXY = None, None, None, None # Read config.cfg file intel_config = ConfigParser.SafeConfigParser() malice_config = ConfigParser.SafeConfigParser() intel_config.read(os.path.join(MALICE_ROOT, 'conf/intel.conf')) malice_config.read(os.path.join(MALICE_ROOT, 'conf/malice.conf')) # Parse config.cfg file
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = 'Josh Maine' __copyright__ = '''Copyright (C) 2013-2014 Josh "blacktop" Maine This file is part of Malice - https://github.com/blacktop/malice See the file 'docs/LICENSE' for copying permission.''' import ConfigParser import os from lib.common.abstracts import Intel from lib.common.constants import MALICE_ROOT from lib.common.exceptions import MaliceDependencyError from lib.common.utils import split_seq from lib.core.database import db_insert try: from shadow_server_api import ShadowServerApi except ImportError: raise MaliceDependencyError( "Unable to import shadow-server-api " "(install with `pip install shadow-server-api`)") class ShadowServer(Intel): pass