# ocatak/malware_api_class architecture

> Architecture diagram of the GitHub repository ocatak/malware_api_class, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ocatak/malware_api_class
- Repository: https://github.com/ocatak/malware_api_class

## Overview

Below are step-by-step instructions and guidelines specific to this project:

##### Main Components
a. Data Storage and Dataset:
- The “hashes” directory contains a mass of subfolders with numbered directories that likely store API call fingerprints or hashed representations.
- Additional dataset files such as “labels.csv”, “ApiIndex.txt”, and the zipped archive “mal-api-2019.zip” represent the raw data.
b. Data Analysis & Processing Modules:
- The “src” folder is the heart of the analysis. It contains sub-modules:
– “src/common” for utility functions like “HashMap.py” and WinApi related helpers.
– “src/multiclass” where various machine learning parameters and runners (e.g., AnalizeRunner.py, DTParameter.py, KNNParameter.py, LSTMMultiClass.py, SVMParameter.py) are implemented.
– “src/other” hosting an alternate set of analysis scripts, possibly for a different analysis workflow.
– “src/utility” which hosts additional support scripts. This includes integration with external services (e.g., VTService.py for VirusTotal API), filtering and extraction routines, and results management.
c. External Dependencies / Services:
- The README indicates that API calls to VirusTotal are performed (via VTService.py) to gather malware family information.
- There are also external datasets referenced (the sample_analysis_data.csv, official dataset links, etc.).

##### Relationships and Interactions
- Data Flow: The dataset from “hashes”, “labels.csv”, or the zip file is input for various analysis routines.
- The “src/multiclass” and “src/other” modules are responsible for processing this data using different machine learning algorithms. They likely interact with data provided via “src/common” and “src/utility” for pre-/post-processing.
- External integration: The VTService module in “src/utility” communicates with the VirusTotal API, indicating that some processing steps include external API calls.
- Support Scripts: Utility scripts like “analize_filter.py”, “group_malware_accordingto_type.py”, and others manage specific utility tasks (e.g., grouping, filtering, converting API call logs).

##### Architectural Patterns & Design Principles
- Modularity: The clear partitioning of code into “common”, “multiclass”, “other”, and “utility” suggests a modular design—each folder encapsulates a slice of the functionality.
- Separation of Concerns: Data management (dataset files and directories) is separated from algorithmic processing (analysis modules) and from external integrations (VTService and API-related operations).
- Extensibility: With different scripts and modules for various ML methods (SVM, LSTM, etc.) and different analysis workflows, it is designed to allow easy extension or substitution of the analysis components.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Storage Layer
    subgraph "Data Storage Layer"
        DS_hashes["hashes"] 
        DS_labels["labels.csv"]
        DS_apiindex["ApiIndex.txt"]
        DS_zip["mal-api-2019.zip"]
        DS_sample["sample_analysis_data.csv"]
    end

    %% Data Analysis & Processing
    subgraph "Data Analysis & Processing"
        subgraph "Common Utilities"
            CU_HashMap["HashMap.py"]
            CU_WinApi["WinApi.py"]
        end

        subgraph "Multiclass Analysis Module"
            Ma_Analize["AnalizeRunner.py"]
            Ma_DT["DTParameter.py"]
            Ma_KNN["KNNParameter.py"]
            Ma_LSTMMulti["LSTMMultiClass.py"]
            Ma_LSTM["LSTMParameter.py"]
            Ma_Latex["LatexReporter.py"]
            Ma_Model["ModelUtil.py"]
            Ma_RF["RFParameter.py"]
            Ma_SVM["SVMParameter.py"]
        end

        subgraph "Other Analysis Module"
            OA_DT["OtherAnalize_DT.py"]
            OA_KNN["OtherAnalize_KNN.py"]
            OA_SVM["OtherAnalize_SVM.py"]
            OA_SVM_M["OtherAnalize_SVM_mclass.py"]
        end

        subgraph "Utility Functions & External Integrations"
            U_VT["VTService.py"]
            U_other["Other Utility Scripts"]
        end
    end

    %% External System
    External["VirusTotal API"]

    %% Connections from Data Storage to Common Utilities
    DS_hashes --> CU_HashMap
    DS_labels  --> CU_HashMap
    DS_apiindex --> CU_HashMap
    DS_zip     --> CU_HashMap
    DS_sample  --> CU_HashMap

    %% Connections from Common Utilities to Analysis Modules
    CU_HashMap --> Ma_Analize
    CU_HashMap --> OA_DT

    %% Connections from Analysis Modules to Utility Functions
    Ma_Analize --> U_VT
    OA_DT --> U_VT

    %% Connection from Utility Functions to External System
    U_VT --> External

    %% Styling: Define classes for colouring
    classDef datastore fill:#ffe6f0,stroke:#b30059,stroke-width:2px;
    classDef analysis fill:#e6f0ff,stroke:#0033cc,stroke-width:2px;
    classDef utility fill:#e6ffe6,stroke:#009933,stroke-width:2px;
    classDef external fill:#fff0e6,stroke:#cc6600,stroke-width:2px;

    class DS_hashes,DS_labels,DS_apiindex,DS_zip,DS_sample datastore;
    class CU_HashMap,CU_WinApi,Ma_Analize,Ma_DT,Ma_KNN,Ma_LSTMMulti,Ma_LSTM,Ma_Latex,Ma_Model,Ma_RF,Ma_SVM,OA_DT,OA_KNN,OA_SVM,OA_SVM_M analysis;
    class U_VT,U_other utility;
    class External external;

    %% Click Events for Data Storage
    click DS_hashes "https://github.com/ocatak/malware_api_class/tree/master/hashes"
    click DS_labels "https://github.com/ocatak/malware_api_class/blob/master/labels.csv"
    click DS_apiindex "https://github.com/ocatak/malware_api_class/blob/master/ApiIndex.txt"
    click DS_zip "https://github.com/ocatak/malware_api_class/blob/master/mal-api-2019.zip"
    click DS_sample "https://github.com/ocatak/malware_api_class/blob/master/sample_analysis_data.csv"

    %% Click Events for Common Utilities
    click CU_HashMap "https://github.com/ocatak/malware_api_class/blob/master/src/common/HashMap.py"
    click CU_WinApi "https://github.com/ocatak/malware_api_class/blob/master/src/common/WinApi.py"

    %% Click Events for Multiclass Analysis Module
    click Ma_Analize "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/AnalizeRunner.py"
    click Ma_DT "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/DTParameter.py"
    click Ma_KNN "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/KNNParameter.py"
    click Ma_LSTMMulti "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/LSTMMultiClass.py"
    click Ma_LSTM "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/LSTMParameter.py"
    click Ma_Latex "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/LatexReporter.py"
    click Ma_Model "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/ModelUtil.py"
    click Ma_RF "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/RFParameter.py"
    click Ma_SVM "https://github.com/ocatak/malware_api_class/blob/master/src/multiclass/SVMParameter.py"

    %% Click Events for Other Analysis Module
    click OA_DT "https://github.com/ocatak/malware_api_class/blob/master/src/other/OtherAnalize_DT.py"
    click OA_KNN "https://github.com/ocatak/malware_api_class/blob/master/src/other/OtherAnalize_KNN.py"
    click OA_SVM "https://github.com/ocatak/malware_api_class/blob/master/src/other/OtherAnalize_SVM.py"
    click OA_SVM_M "https://github.com/ocatak/malware_api_class/blob/master/src/other/OtherAnalize_SVM_mclass.py"

    %% Click Events for Utility Functions & External Integrations
    click U_VT "https://github.com/ocatak/malware_api_class/blob/master/src/utility/VTService.py"
    click U_other "https://github.com/ocatak/malware_api_class/tree/master/src/utility"
```
