Ale96Pa/CVE-CAPEC

CSS

0

4 commits

updated May 20, 2025

See the code

README

Threatlinker

Abstract: Threat analysis is continuously growing in importance due to the always-increasing complexity and frequency of cyber attacks. Analyzing threats demands significant effort from security experts, leading to delays in the security analysis process. Different cybersecurity knowledge bases are currently available to support this task, but manual efforts are often required to correlate such heterogeneous sources into a unified view that would enable a more comprehensive assessment. To address this gap, we propose ThreatLinker, a methodology leveraging Natural Language Processing (NLP) to effectively and efficiently associate Common Vulnerabilities and Exposure (CVE) vulnerabilities with Common Attack Pattern Enumeration and Classification (CAPEC) attack patterns. The proposed technique combines semantic similarity with keyword analysis to improve the accuracy of association estimations. Experimental evaluations demonstrate superior performance compared to state-of-the-art models, reducing manual effort and analysis time, and enabling cybersecurity professionals to prioritize critical tasks.

Threatlinker is a Django-based project aimed at correlating Common Vulnerabilities and Exposures (CVE) with Common Attack Pattern Enumeration and Classification (CAPEC) attack patterns. This project seeks to streamline the process of identifying relationships between known vulnerabilities and attack patterns, enhancing threat intelligence analysis for cybersecurity professionals.

Versions used in development

  • Python: 3.11.8
  • Django: 5.1.2
  • PostgreSQL: 14
  • Memurai (Windows) 4.14 / Redis (Linux)

Installing PyTorch with CUDA

CUDA (Compute Unified Device Architecture) is a parallel computing platform and programming model created by NVIDIA. It allows PyTorch to perform computations on NVIDIA GPUs, significantly speeding up tasks such as training and inference for deep learning models.

If you have an NVIDIA GPU and CUDA installed on your machine, you can enable PyTorch to utilize GPU acceleration by installing a CUDA-compatible version of torch.

Note: CUDA is only compatible with NVIDIA GPUs. If you don’t have an NVIDIA GPU, you can skip this step and install the default CPU-only version of PyTorch.

Installation Instructions:

To check your CUDA version, run:

nvcc --version

Once you know your CUDA version, install PyTorch with CUDA support using the following command:

# Replace `cu118` with your specific CUDA version, e.g., cu117 for CUDA 11.7, cu116 for CUDA 11.6, etc.
pip install torch --index-url https://download.pytorch.org/whl/cu118

For more details on PyTorch installation options, visit the official PyTorch installation page.

Project Structure

The project is structured as follows:

  • Django Framework: Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It handles much of the complexity in web development, providing built-in tools for database management, form handling, authentication, and more. In this project, Django is the backbone that integrates and serves data, manages URL routing, and enables interaction between the different modules related to CVE, CWE, and CAPEC data.

  • PostgreSQL: PostgreSQL is a powerful, open-source object-relational database system that is used as the primary database for storing CVE, CWE, and CAPEC data in Threatlinker. It provides advanced indexing, data integrity, and supports JSON fields, making it an ideal choice for efficiently handling the complex relationships and structured data this project requires.

  • Memurai or Redis: Memurai (for Windows) or Redis (for Linux) serves as the message broker and task queue backend for Celery in this project. It handles asynchronous tasks, allowing us to process data updates, such as importing and updating CVE, CWE, and CAPEC records, without blocking the main application’s performance. This is essential for managing the background tasks required by the application, ensuring smooth and efficient data processing.

  • Virtual Environment: A Python virtual environment is set up to manage dependencies and maintain isolation from other projects, ensuring compatibility across different setups.

  • Git Integration: The project is managed using Git and hosted on GitHub for version control, allowing for collaborative development, tracking changes, and maintaining code history.

App Structure

The Threatlinker project is organized into four main applications, each with specific roles:

  • Core: Responsible for implementing correlation functionalities, AI-based textual similarity using various techniques, text preprocessing, and process parallelization.
  • Data: Manages data handling, updates, and the creation of models for CVE, CWE, CAPEC, and MITRE ATT&CK, including mechanisms to keep data current.
  • Graph: Focuses on the graph representation of entities and their connections, providing a visual and structural perspective of relationships.
  • View: Handles the display of other parts of the application not directly connected to the core functionalities.

Installation

  1. Set up the PostgreSQL database:

    • Access PostgreSQL as the default postgres user:
      psql -U postgres
      
    • If already exists:
      DROP DATABASE IF EXISTS threatlinker_db;
      DROP USER IF EXISTS threatlinker_user;
      
    • Create the database and user for the project:
      CREATE DATABASE threatlinker_db;
      CREATE USER threatlinker_user WITH PASSWORD 'threatlinkerpwd';
      GRANT ALL PRIVILEGES ON DATABASE threatlinker_db TO threatlinker_user;
      
    • Exit PostgreSQL:
      \q
      
  2. Clone the repository:

    git clone https://github.com/andreaciavotta/threatlinker.git
    cd threatlinker
    
  3. Create a virtual environment and activate it:

    • Windows:

      python -m venv .venv
      .venv\Scripts\activate
      
    • Linux/macOS:

      python3 -m venv .venv
      source .venv/bin/activate
      
  4. Install required dependencies (on Windows):

    install_windows.bat
    

    Please look at the CUDA dependencies if you have nVidia. If needed first use:

    pip cache purge
    
  5. Run migrations:

    python manage.py migrate
    
  6. Create an admin (superuser) account: To access the Django admin interface, you need to create a superuser. Run:

    python manage.py createsuperuser
    

    Follow the prompts to set up a username, email, and password for the superuser.

  7. Start the development server with parallel processes:

    python run_windows.py
    

    (For Linux, a similar script can be created to streamline startup.)

Usage

Once the server is running, navigate to http://127.0.0.1:8000 in your browser to access the application.

Development

To contribute to this project:

  1. Create a new branch for your feature or bugfix.
  2. Make changes and test them thoroughly.
  3. Push your branch to GitHub and open a pull request.

Ale96Pa/CVE-CAPEC

CSS

0

4 commits

updated May 20, 2025

See the code

README

Threatlinker

Abstract: Threat analysis is continuously growing in importance due to the always-increasing complexity and frequency of cyber attacks. Analyzing threats demands significant effort from security experts, leading to delays in the security analysis process. Different cybersecurity knowledge bases are currently available to support this task, but manual efforts are often required to correlate such heterogeneous sources into a unified view that would enable a more comprehensive assessment. To address this gap, we propose ThreatLinker, a methodology leveraging Natural Language Processing (NLP) to effectively and efficiently associate Common Vulnerabilities and Exposure (CVE) vulnerabilities with Common Attack Pattern Enumeration and Classification (CAPEC) attack patterns. The proposed technique combines semantic similarity with keyword analysis to improve the accuracy of association estimations. Experimental evaluations demonstrate superior performance compared to state-of-the-art models, reducing manual effort and analysis time, and enabling cybersecurity professionals to prioritize critical tasks.

Threatlinker is a Django-based project aimed at correlating Common Vulnerabilities and Exposures (CVE) with Common Attack Pattern Enumeration and Classification (CAPEC) attack patterns. This project seeks to streamline the process of identifying relationships between known vulnerabilities and attack patterns, enhancing threat intelligence analysis for cybersecurity professionals.

Versions used in development

  • Python: 3.11.8
  • Django: 5.1.2
  • PostgreSQL: 14
  • Memurai (Windows) 4.14 / Redis (Linux)

Installing PyTorch with CUDA

CUDA (Compute Unified Device Architecture) is a parallel computing platform and programming model created by NVIDIA. It allows PyTorch to perform computations on NVIDIA GPUs, significantly speeding up tasks such as training and inference for deep learning models.

If you have an NVIDIA GPU and CUDA installed on your machine, you can enable PyTorch to utilize GPU acceleration by installing a CUDA-compatible version of torch.

Note: CUDA is only compatible with NVIDIA GPUs. If you don’t have an NVIDIA GPU, you can skip this step and install the default CPU-only version of PyTorch.

Installation Instructions:

To check your CUDA version, run:

nvcc --version

Once you know your CUDA version, install PyTorch with CUDA support using the following command:

# Replace `cu118` with your specific CUDA version, e.g., cu117 for CUDA 11.7, cu116 for CUDA 11.6, etc.
pip install torch --index-url https://download.pytorch.org/whl/cu118

For more details on PyTorch installation options, visit the official PyTorch installation page.

Project Structure

The project is structured as follows:

  • Django Framework: Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It handles much of the complexity in web development, providing built-in tools for database management, form handling, authentication, and more. In this project, Django is the backbone that integrates and serves data, manages URL routing, and enables interaction between the different modules related to CVE, CWE, and CAPEC data.

  • PostgreSQL: PostgreSQL is a powerful, open-source object-relational database system that is used as the primary database for storing CVE, CWE, and CAPEC data in Threatlinker. It provides advanced indexing, data integrity, and supports JSON fields, making it an ideal choice for efficiently handling the complex relationships and structured data this project requires.

  • Memurai or Redis: Memurai (for Windows) or Redis (for Linux) serves as the message broker and task queue backend for Celery in this project. It handles asynchronous tasks, allowing us to process data updates, such as importing and updating CVE, CWE, and CAPEC records, without blocking the main application’s performance. This is essential for managing the background tasks required by the application, ensuring smooth and efficient data processing.

  • Virtual Environment: A Python virtual environment is set up to manage dependencies and maintain isolation from other projects, ensuring compatibility across different setups.

  • Git Integration: The project is managed using Git and hosted on GitHub for version control, allowing for collaborative development, tracking changes, and maintaining code history.

App Structure

The Threatlinker project is organized into four main applications, each with specific roles:

  • Core: Responsible for implementing correlation functionalities, AI-based textual similarity using various techniques, text preprocessing, and process parallelization.
  • Data: Manages data handling, updates, and the creation of models for CVE, CWE, CAPEC, and MITRE ATT&CK, including mechanisms to keep data current.
  • Graph: Focuses on the graph representation of entities and their connections, providing a visual and structural perspective of relationships.
  • View: Handles the display of other parts of the application not directly connected to the core functionalities.

Installation

  1. Set up the PostgreSQL database:

    • Access PostgreSQL as the default postgres user:
      psql -U postgres
      
    • If already exists:
      DROP DATABASE IF EXISTS threatlinker_db;
      DROP USER IF EXISTS threatlinker_user;
      
    • Create the database and user for the project:
      CREATE DATABASE threatlinker_db;
      CREATE USER threatlinker_user WITH PASSWORD 'threatlinkerpwd';
      GRANT ALL PRIVILEGES ON DATABASE threatlinker_db TO threatlinker_user;
      
    • Exit PostgreSQL:
      \q
      
  2. Clone the repository:

    git clone https://github.com/andreaciavotta/threatlinker.git
    cd threatlinker
    
  3. Create a virtual environment and activate it:

    • Windows:

      python -m venv .venv
      .venv\Scripts\activate
      
    • Linux/macOS:

      python3 -m venv .venv
      source .venv/bin/activate
      
  4. Install required dependencies (on Windows):

    install_windows.bat
    

    Please look at the CUDA dependencies if you have nVidia. If needed first use:

    pip cache purge
    
  5. Run migrations:

    python manage.py migrate
    
  6. Create an admin (superuser) account: To access the Django admin interface, you need to create a superuser. Run:

    python manage.py createsuperuser
    

    Follow the prompts to set up a username, email, and password for the superuser.

  7. Start the development server with parallel processes:

    python run_windows.py
    

    (For Linux, a similar script can be created to streamline startup.)

Usage

Once the server is running, navigate to http://127.0.0.1:8000 in your browser to access the application.

Development

To contribute to this project:

  1. Create a new branch for your feature or bugfix.
  2. Make changes and test them thoroughly.
  3. Push your branch to GitHub and open a pull request.