コード例 #1
0
def main(distribution):

    # dependencies

    if distribution == 'fedora':
        dnf_install_packages('python-devel', 'python-setuptools')
        dnf_install_packages('libjpeg-devel')
        dnf_install_packages('openssl-devel', 'python3-tkinter')
    else:
        apt_install_packages('python-dev', 'python-setuptools')
        apt_install_packages('libjpeg-dev')
        apt_install_packages('libssl-dev', 'python3-tk')

    pip3_install_packages('pluginbase', 'Pillow', 'cryptography', 'pyopenssl',
                          'matplotlib', 'docker', 'networkx')

    # install yara
    _install_yara(distribution)

    # build extraction docker container
    logging.info('Building fact extraction container')

    output, return_code = execute_shell_command_get_return_code(
        'docker pull fkiecad/fact_extractor')
    if return_code != 0:
        raise InstallationError(
            'Failed to pull extraction container:\n{}'.format(output))

    # installing common code modules
    pip3_install_packages(
        'git+https://github.com/fkie-cad/common_helper_yara.git')
    pip3_install_packages(
        'git+https://github.com/mass-project/common_analysis_base.git')

    # install plug-in dependencies
    _install_plugins(distribution)

    # configure environment
    _edit_sudoers()
    _edit_environment()

    # create directories
    _create_firmware_directory()

    # compiling yara signatures
    compile_signatures()
    _, yarac_return = execute_shell_command_get_return_code(
        'yarac -d test_flag=false ../test/unit/analysis/test.yara ../analysis/signatures/Yara_Base_Plugin.yc'
    )
    if yarac_return != 0:
        raise InstallationError('Failed to compile yara test signatures')

    with OperateInDirectory('../../'):
        with suppress(FileNotFoundError):
            Path('start_fact_backend').unlink()
        Path('start_fact_backend').symlink_to('src/start_fact_backend.py')

    return 0
コード例 #2
0
def main(distribution):
    # dependencies
    apt_install_packages('python-dev', 'python-setuptools')
    apt_install_packages('libjpeg-dev', 'liblzma-dev', 'liblzo2-dev', 'zlib1g-dev')
    apt_install_packages('libssl-dev python3-tk')
    pip3_install_packages('pluginbase', 'Pillow', 'cryptography', 'pyopenssl', 'entropy', 'matplotlib')

    apt_install_packages('python-pip')
    # removes due to compatibilty reasons
    apt_remove_packages('python-lzma')
    pip2_remove_packages('pyliblzma')
    apt_install_packages('python-lzma')

    # install yara
    _install_yara()

    # installing unpacker
    _install_unpacker(distribution == 'xenial')

    # installing common code modules
    pip3_install_packages('git+https://github.com/fkie-cad/common_helper_process.git')
    pip3_install_packages('git+https://github.com/fkie-cad/common_helper_yara.git')
    pip3_install_packages('git+https://github.com/fkie-cad/common_helper_unpacking_classifier.git')
    pip3_install_packages('git+https://github.com/mass-project/common_analysis_base.git')

    # install plug-in dependencies
    _install_plugins()

    # compile custom magic file
    with OperateInDirectory('../mime'):
        cat_output, cat_code = execute_shell_command_get_return_code('cat custom_* > custommime')
        file_output, file_code = execute_shell_command_get_return_code('file -C -m custommime')
        mv_output, mv_code = execute_shell_command_get_return_code('mv -f custommime.mgc ../bin/')
        if any(code != 0 for code in (cat_code, file_code, mv_code)):
            raise InstallationError('Failed to properly compile magic file\n{}'.format('\n'.join((cat_output, file_output, mv_output))))
        Path('custommime').unlink()

    # configure environment
    _edit_sudoers()
    _edit_environment()

    # create directories
    _create_firmware_directory()

    # compiling yara signatures
    compile_signatures()
    _, yarac_return = execute_shell_command_get_return_code('yarac -d test_flag=false ../test/unit/analysis/test.yara ../analysis/signatures/Yara_Base_Plugin.yc')
    if yarac_return != 0:
        raise InstallationError('Failed to compile yara test signatures')

    with OperateInDirectory('../../'):
        with suppress(FileNotFoundError):
            Path('start_fact_backend').unlink()
        Path('start_fact_backend').symlink_to('src/start_fact_backend.py')

    return 0
コード例 #3
0
ファイル: backend.py プロジェクト: fkie-cad/FACT_core
def main(skip_docker, distribution):
    apt_packages_path = INSTALL_DIR / 'apt-pkgs-backend.txt'
    dnf_packages_path = INSTALL_DIR / 'dnf-pkgs-backend.txt'

    if distribution != 'fedora':
        pkgs = read_package_list_from_file(apt_packages_path)
        apt_install_packages(*pkgs)
    else:
        pkgs = read_package_list_from_file(dnf_packages_path)
        dnf_install_packages(*pkgs)

    install_pip_packages(PIP_DEPENDENCIES)

    # install yara
    _install_yara()

    _install_checksec()

    if not skip_docker:
        _install_docker_images()

    # install plug-in dependencies
    _install_plugins(distribution, skip_docker)

    # configure environment
    _edit_environment()

    # create directories
    _create_firmware_directory()

    # compiling yara signatures
    compile_signatures()
    _, yarac_return = execute_shell_command_get_return_code('yarac -d test_flag=false ../test/unit/analysis/test.yara ../analysis/signatures/Yara_Base_Plugin.yc')
    if yarac_return != 0:
        raise InstallationError('Failed to compile yara test signatures')

    with OperateInDirectory('../../'):
        with suppress(FileNotFoundError):
            Path('start_fact_backend').unlink()
        Path('start_fact_backend').symlink_to('src/start_fact_backend.py')

    return 0