# lehasas/malware-analysis-and-detection architecture

> Architecture diagram of the GitHub repository lehasas/malware-analysis-and-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lehasas/malware-analysis-and-detection
- Repository: https://github.com/lehasas/malware-analysis-and-detection

## Overview

This repository is a research workflow for classifying malware from binary-derived images with two CNN variants. The documented path is binaries to grayscale images, dataset splitting, then model training or testing and generated results; hyperparameter experiments are a separate capability. The training entry point is documented but not excerpted, so its connections to loaders, models, and metrics are shown as unverified rather than asserted. Source excerpts establish image conversion, dataset loading, CNN definitions, and plotting behavior.

Main entry points: [`CNN_Malware_Train_Test.py`](https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Malware_Train_Test.py) (Train test runner), [`metrics.py`](https://github.com/lehasas/malware-analysis-and-detection/blob/master/metrics.py) (Metrics and plots), [`scripts/binary_to_image.py`](https://github.com/lehasas/malware-analysis-and-detection/blob/master/scripts/binary_to_image.py) (Binary converter), [`scripts/data_preprocessing.py`](https://github.com/lehasas/malware-analysis-and-detection/blob/master/scripts/data_preprocessing.py) (Dataset splitter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_converter["Binary converter<br/>[binary_to_image.py]"]
  node_splitter["Dataset splitter"]
end

subgraph group_learn["Model learning"]
  node_loaders["Image loaders<br/>[data_loaders.py]"]
  node_runner["Train test runner"]
  node_cnn_one["CNN model one<br/>[CNN_Models.py]"]
  node_cnn_two["CNN model two<br/>[CNN_Models.py]"]
end

subgraph group_analysis["Evaluation and experiments"]
  node_metrics["Metrics and plots<br/>[metrics.py]"]
  node_tuning["Hyperparameter study"]
end

subgraph group_artifacts["Data and results"]
  node_binary_samples["Malware samples<br/>[samples.7z]"]
  node_image_data["Class images"]
  node_dataset_splits["Train val test"]
  node_train_results["Training outputs"]
  node_test_results["Test outputs"]
end

node_researcher(("Researcher"))
node_wandb["Weights and Biases"]

node_researcher -->|"provides samples"| node_binary_samples
node_binary_samples -->|"converts binaries"| node_converter
node_converter -->|"writes images"| node_image_data
node_image_data -->|"splits images"| node_splitter
node_splitter -->|"writes subsets"| node_dataset_splits
node_dataset_splits -->|"loads images"| node_loaders
node_researcher -->|"trains or tests"| node_runner
node_runner -.->|"uses loaders"| node_loaders
node_runner -.->|"uses model"| node_cnn_one
node_runner -.->|"uses model"| node_cnn_two
node_runner -.->|"reports metrics"| node_metrics
node_runner -->|"saves training results"| node_train_results
node_runner -->|"saves test results"| node_test_results
node_metrics -->|"writes plots"| node_test_results
node_metrics -->|"reads losses"| node_train_results
node_researcher -->|"studies parameters"| node_tuning
node_tuning -->|"uses platform"| node_wandb

click node_binary_samples "https://github.com/lehasas/malware-analysis-and-detection/blob/master/samples.7z"
click node_converter "https://github.com/lehasas/malware-analysis-and-detection/blob/master/scripts/binary_to_image.py"
click node_image_data "https://github.com/lehasas/malware-analysis-and-detection/tree/master/Images"
click node_splitter "https://github.com/lehasas/malware-analysis-and-detection/blob/master/scripts/data_preprocessing.py"
click node_dataset_splits "https://github.com/lehasas/malware-analysis-and-detection/tree/master/output"
click node_loaders "https://github.com/lehasas/malware-analysis-and-detection/blob/master/data_loaders.py"
click node_runner "https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Malware_Train_Test.py"
click node_cnn_one "https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Models.py"
click node_cnn_two "https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Models.py"
click node_metrics "https://github.com/lehasas/malware-analysis-and-detection/blob/master/metrics.py"
click node_train_results "https://github.com/lehasas/malware-analysis-and-detection/tree/master/train_output"
click node_test_results "https://github.com/lehasas/malware-analysis-and-detection/tree/master/test_output"
click node_tuning "https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Malware_Hyperparameter_Study.ipynb"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_converter,node_splitter toneBlue
class node_loaders,node_runner,node_cnn_one,node_cnn_two toneAmber
class node_metrics,node_tuning toneMint
class node_binary_samples,node_image_data,node_dataset_splits,node_train_results,node_test_results toneRose
class node_researcher,node_wandb toneIndigo
```

## Components

### Data preparation

- [Binary converter](https://github.com/lehasas/malware-analysis-and-detection/blob/master/scripts/binary_to_image.py): `scripts/binary_to_image.py`
- [Dataset splitter](https://github.com/lehasas/malware-analysis-and-detection/blob/master/scripts/data_preprocessing.py): `scripts/data_preprocessing.py`

### Model learning

- [Image loaders](https://github.com/lehasas/malware-analysis-and-detection/blob/master/data_loaders.py): `data_loaders.py`
- [Train test runner](https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Malware_Train_Test.py): `CNN_Malware_Train_Test.py`
- [CNN model one](https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Models.py): `CNN_Models.py`
- [CNN model two](https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Models.py): `CNN_Models.py`

### Evaluation and experiments

- [Metrics and plots](https://github.com/lehasas/malware-analysis-and-detection/blob/master/metrics.py): `metrics.py`
- [Hyperparameter study](https://github.com/lehasas/malware-analysis-and-detection/blob/master/CNN_Malware_Hyperparameter_Study.ipynb): `CNN_Malware_Hyperparameter_Study.ipynb`

### Data and results

- [Malware samples](https://github.com/lehasas/malware-analysis-and-detection/blob/master/samples.7z): `samples.7z`
- [Class images](https://github.com/lehasas/malware-analysis-and-detection/tree/master/Images): `Images`
- [Train val test](https://github.com/lehasas/malware-analysis-and-detection/tree/master/output): `output`
- [Training outputs](https://github.com/lehasas/malware-analysis-and-detection/tree/master/train_output): `train_output`
- [Test outputs](https://github.com/lehasas/malware-analysis-and-detection/tree/master/test_output): `test_output`

### Other components

- **Researcher**
- **Weights and Biases**

## Connections

- Researcher → Malware samples: provides samples (evidence: `README.md`)
- Malware samples → Binary converter: converts binaries (evidence: `README.md`)
- Binary converter → Class images: writes images (evidence: `scripts/binary_to_image.py`)
- Class images → Dataset splitter: splits images (evidence: `README.md`)
- Dataset splitter → Train val test: writes subsets (evidence: `scripts/data_preprocessing.py`)
- Train val test → Image loaders: loads images (evidence: `data_loaders.py`)
- Researcher → Train test runner: trains or tests (evidence: `README.md`)
- Train test runner → Image loaders: uses loaders
- Train test runner → CNN model one: uses model
- Train test runner → CNN model two: uses model
- Train test runner → Metrics and plots: reports metrics
- Train test runner → Training outputs: saves training results (evidence: `README.md`)
- Train test runner → Test outputs: saves test results (evidence: `README.md`)
- Metrics and plots → Test outputs: writes plots (evidence: `metrics.py`)
- Metrics and plots → Training outputs: reads losses (evidence: `metrics.py`)
- Researcher → Hyperparameter study: studies parameters (evidence: `README.md`)
- Hyperparameter study → Weights and Biases: uses platform (evidence: `README.md`)
