BroAPT-App Detection Framework

The BroAPT-App framework processes extracted files, perform malware detection upon those files with detection API configured through the configuration file.

BroAPT-App Detection Framework
  1. The BroAPT-App framework fetches basic information about the extracted file, including file path, MIME type, file UID, source PCAP file, etc.

    Each file extracted, since it will be named after:


    with such pattern, the BroAPT-App framework will generate an Entry to represent the information of the target file, e.g. for a extracted file named:


    the BroAPT-App framework will generate the Entry object as following:

  2. Based on the MIME type, the BroAPT-App framework will obtain MIME specific detection API for the extracted file.

  3. The BroAPT-App framework will then start detecting the extracted file based on the specification described in the API.

    When detection, as the Docker container may not be capable of such action, the BroAPT-App framework may request the BroAPT-Daemon server to remote detect the extracted file.

    BroAPT Client-Server Detection Framework

    The BroAPT-Daemon server is a RESTful API server implemented using Flask microframework. At the moment it supports following APIs:

    URI Routing

    HTTP Method




    Query detection listing



    Query detection report

    /api/v1.0/scan data={"key": "value"}


    Request remote detection



    Delete detection record

MIME Specific API Configuration

In the BroAPT-App framework, we used an API configuration file to provide the BroAPT system with MIME specific detection mechanism. The configuration file is written in YAML, inspired by Docker Compose and Travis CI.

The directory structure of API configuration file and its related files are as below:

│   # API configuration file
├── api.yml
│   # MIME: application/*
├── application/
│   └── ...
│   # MIME: audio/*
├── audio/
│   └── ...
│   # default API
├── example/
│   └── ...
│   # MIME: font/*
├── font/
│   └── ...
│   # MIME: image/*
├── image/
│   └── ...
│   # MIME: message/*
├── message/
│   └── ...
│   # MIME: model/*
├── model/
│   └── ...
│   # MIME: multipart/*
├── multipart/
│   └── ...
│   # MIME: text/*
├── text/
│   └── ...
│   # MIME: video/*
└── video/
   └── ...

The /api/ folder will be mapped into the Docker container at runtime and the /api/api.yml is the exact API configuration file. The API for example MIME type is the default fallback detection method for those with NO existing detection API configured.

In the configuration file, you can specify global environment variables under the environment key:

  # API root path (from environment vairable)
  # Python 3.6
  PYTHON36: /usr/bin/python3.6
  # Python 2.7
  PYTHON27: /usr/bin/python
  # Shell/Bash
  SHELL: /bin/bash

And for a certain MIME, e.g. PDF files (MIME is application/pdf), the configuration should be as following:

    remote: false
    # default working directory is ``/api/application/pdf/``
    # now changed to ``/api/application/pdf/pdf_analysis``
    workdir: pdf_analysis
      ENV_FOO: 1
      ENV_BAR: cliche
      - apt-get update
      - apt-get install -y python python-pip
      - ${PYTHON27} -m pip install -r requirements.txt
      - rm -rf /var/lib/apt/lists/*
      - apt-get remove -y --auto-remove python-pip
      - apt-get clean
      - ${PYTHON27} [...]
      - ...
    report: ${PYTHON27}


Shell-like globing is now supported for MIME types, you may specify an API using application/*, which will be used for both application/ and application/ms-powerpoint.

In the configuration file, the report key is mandatory.

If set remote key as true, the BroAPT-App framework will request the BroAPT-Daemon server to perform remote detection.

And if an API configuration is shared by multiple MIME types, you should set shared key as true, so that the API would be process-safe at runtime.

After parsing through the cfgparser.parse() function, the API configuration above will be represented as:

       'API_ROOT': '${BROAPT_API_ROOT}',
       'PYTHON36': '/usr/bin/python3.6',
       'PYTHON27': '/usr/bin/python',
       'SHELL': '/bin/bash',
       'ENV_FOO': '1',
       'ENV_BAR': 'cliche'
       'apt-get update',
       'apt-get install -y python python-pip',
       '${PYTHON27} -m pip install -r requirements.txt',
       'rm -rf /var/lib/apt/lists/*',
       'apt-get remove -y --auto-remove python-pip',
       'apt-get clean'
       '${PYTHON27} [...]',
    inited=<Synchronized wrapper for c_ubyte(0)>,
  • API.inited is to mark if the installation process had been run successfully.

  • API.shared is to mark if the configuration is shared by multiple MIME types.

  • API.locked is to mark if the process is locked to prevent resource competition.

At runtime, if the BroAPT-App framework is to detect a file at /dump/application/pdf/test.pdf, the main procedure is as follows:

  1. Set environment variables:

  2. Change the current working directory to /api/application/pdf/pdf_analysis.

  3. If the API.inited is now False, which means the installation process is NOT yet performed, then acquire API.locked and execute the commands:

    apt-get update
    apt-get install -y python python-pip
    python -m pip install -r requirements.txt
    rm -rf /var/lib/apt/lists/*
    apt-get remove -y --auto-remove python-pip
    apt-get clean

    afterwards, toggle API.inited to True and release API.locked.

  4. Execute detection commands:

    /usr/bin/python [...]
  5. Once finished, execute report generation script /usr/bin/python

Integrated Detection Services

At the moment, the BroAPT system had integrated six detection solusions.

Default Detection powered by VirusTotal

VirusTotal aggregates many antivirus products and online scan engines to check for viruses that the user’s own antivirus may have missed, or to verify against any false positives.

As mentioned above, the example MIME type is the default fallback detection mechanism in case of missing configuration. The configuration is as below:

    ## sleep interval
    ## max retry for report
    VT_RETRY: 10
    ## percentage of positive threshold
    VT_PERCENT: 50
    ## VT API key
    VT_API: ...
    ## path to VT file scan reports
    VT_LOG: /var/log/bro/tmp/
  report: ${PYTHON36}

Android APK Detection powered by AndroPyTool

AndroPyTool is a tool for extracting static and dynamic features from Android APKs. It combines different well-known Android apps analysis tools such as DroidBox, FlowDroid, Strace, AndroGuard or VirusTotal analysis. Provided a source directory containing APK files, AndroPyTool applies all these tools to perform pre-static, static and dynamic analysis and generates files of features in JSON and CSV formats and also allows to save all the data in a MongoDB database.

AndroPyTool is configured for detection of APK files, whose MIME type is application/ in IANA registry. The configuration is as below:

    remote: true
    workdir: AndroPyTool
      APK_LOG: /home/traffic/log/bro/tmp/
      - docker pull alexmyg/andropytool
    report: ${SHELL}

Since the environment configuration of AndroPyTool is much too complex, we directly used its official Docker image for detection. Therefore, the AndroPyTool is called through remote detection mechanism, i.e. BroApt-Daemon server performs detection using AndroPyTool Docker image on APK files then send the report back to BroAPT-App framework for records.

Office Document Detection powered by MaliciousMacroBot

MaliciousMacroBot is to provide a powerful malicious file triage tool for cyber responders; help fill existing detection gaps for malicious office documents, which are still a very prevalent attack vector today; deliver a new avenue for threat intelligence, a way to group similar malicious office documents together to identify phishing campaigns and track use of specific malicious document templates.

MaliciousMacroBot is configured for detecting Office files, which is a document type based on XML, such as Microsoft Office and OpenOffice. The MIME types of such documents include application/msword, application/ms-excel, application/ and application/vnd.openxmlformats-officedocument.*, etc. The configuration is as below:

  vnd.openxmlformats-officedocument.*: &officedocument
    workdir: ${API_ROOT}/application/vnd.openxmlformats-officedocument/
      MMB_LOG: /var/log/bro/tmp/
      - yum install -y git
      - git clone
      - ${PYTHON36} -m pip install ./MaliciousMacroBot/
      - yum clean -y all
    report: ${PYTHON36}
    shared: officedocument
  msword: *officedocument *officedocument *officedocument


As you may have noticed here, the configured MIME types detected by MaliciousMacroBot has a * globing syntax, such shall be matched using shell-like globing mechanism.

As the MaliciousMacroBot detection method is shared by multiple MIME types, we set the shared key in the API to an identifier for the detection method, so that at runtime, such detection method will be process-safe.

Linux ELF Detection powered by ELF Parser

ELF Parser is designed for static ELF analysis. It can quickly determine the capabilities of an ELF binary through static analysis, then discover if the binary is known malware or a possible threat without ever executing the file.

ELF Parser is configured for the ELF file (MIME type: application/x-executable only. The configuration is as below:

    ## ELF Parser
    remote: true
      ELF_LOG: /home/traffic/log/bro/tmp/
      ELF_SCORE: 100
    workdir: ELF-Parser
      - docker build --tag elfparser:1.4.0 --rm .
    report: ${SHELL}

Common Linux Malware Detection powered by LMD

Linux Malware Detect (LMD) is a malware scanner for Linux, that is designed around the threats faced in shared hosted environments. It uses threat data from network edge intrusion detection systems to extract malware that is actively being used in attacks and generates signatures for detection. In addition, threat data is also derived from user submissions with the LMD checkout feature and from malware community resources. The signatures that LMD uses are MD5 file hashes and HEX pattern matches, they are also easily exported to any number of detection tools such as ClamAV.

LMD is configured for various common file types. The configuration is as below:

  octet-stream: &lmd
    ## LMD
    workdir: ${API_ROOT}/application/octet-stream/LMD
      LMD_LOG: /var/log/bro/tmp/
      - yum install -y git which
      - test -d ./linux-malware-detect/ ||
        git clone
      - ${SHELL}
    report: ${SHELL}
    shared: linux-maldet
  html: *lmd
  x-c: *lmd
  x-perl: *lmd
  x-php: *lmd

Malicious JavaScript Detection powered by JaSt

JaSt is a low-overhead solution that combines the extraction of features from the abstract syntax tree with a random forest classifier to detect malicious JavaScript instances. It is based on a frequency analysis of specific patterns, which are either predictive of benign or of malicious samples. Even though the analysis is entirely static, it yields a high detection accuracy of almost 99.5% and has a low false-negative rate of 0.54%.

JaSt as is dedicated for javaScript files. The configuration is as below:

  javascript: &javascript
    workdir: ${API_ROOT}/application/javascript/JaSt
      JS_LOG: /var/log/bro/tmp/
      - yum install -y epel-release
      - yum install -y git nodejs
      - test -d ./JaSt/ ||
        git clone
      - ${PYTHON3} -m pip install
      - ${PYTHON3} ./JaSt/clustering/
          --d ./sample/
          --l ./lables/
          --md ./models/
          --mn broapt-jast
    - ${PYTHON3} ./JaSt/clustering/
        --f ${BROAPT_PATH}
        --m ./models/broapt-jast
    report: ${PYTHON3}
    shared: javascript
  javascript: *javascript