# pralab/secml_malware architecture

> Architecture diagram of the GitHub repository pralab/secml_malware, 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/pralab/secml_malware
- Repository: https://github.com/pralab/secml_malware

## Overview

SecML Malware is a Python library for evaluating Windows malware detectors through adversarial PE-file manipulation. The principal workflow is to provide a malware sample and detector, run a white-box gradient attack or black-box search, and inspect the resulting evasion sample and detector confidence. The architecture also includes detector adapters and model families, PE transformation utilities, integrated-gradients explainability, and executable visualization. Attack-family interactions are documented in the README; unsampled implementations are represented at their exact paths, with uncertain internal calls omitted.

Main entry points: [`secml_malware/attack/whitebox`](https://github.com/pralab/secml_malware/tree/master/secml_malware/attack/whitebox) (White-box attacks), [`secml_malware/attack/blackbox/c_wrapper_phi.py`](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_wrapper_phi.py) (Detector adapter), [`secml_malware/attack/blackbox/c_blackbox_problem.py`](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_blackbox_problem.py) (Black-box attacks), [`secml_malware/attack/whitebox/c_end2end_evasion.py`](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_end2end_evasion.py) (Evasion framework)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_attack["Adversarial attacks"]
  node_whitebox["White-box attacks"]
  node_gradient["Gradient attacks"]
  node_byteattack["Byte optimization"]
  node_blackbox["Black-box attacks"]
  node_gamma["GAMMA search<br/>[c_gamma_evasion.py]"]
  node_optimizer["Genetic optimizer"]
  node_wrapper["Detector adapter<br/>[c_wrapper_phi.py]"]
  node_evasionbase["Evasion framework"]
end

subgraph group_models["Detection models"]
  node_classifier["End-to-end classifier"]
  node_endmodel["End-to-end model<br/>[basee2e.py]"]
  node_malconv["MalConv model<br/>[malconv.py]"]
  node_ember["EMBER classifier"]
  node_sorel["SOREL classifier"]
  node_remote["Remote classifier"]
end

subgraph group_analysis["Analysis tools"]
  node_xai["Integrated gradients"]
  node_visualization["Executable visualization<br/>[exe.py]"]
end

subgraph group_pe["PE utilities"]
  node_peops["PE transformations<br/>[pe_operations.py]"]
end

node_user(("Researcher"))

node_user -->|"runs attacks"| node_whitebox
node_user -->|"runs attacks"| node_blackbox
node_whitebox -->|"includes"| node_gradient
node_whitebox -->|"includes"| node_byteattack
node_whitebox -->|"uses framework"| node_evasionbase
node_gradient -->|"extends"| node_evasionbase
node_byteattack -->|"extends"| node_evasionbase
node_evasionbase -->|"uses classifier"| node_classifier
node_blackbox -->|"scores candidates"| node_wrapper
node_gamma -->|"specializes problem"| node_blackbox
node_optimizer -->|"optimizes problem"| node_blackbox
node_wrapper -->|"wraps detector"| node_classifier
node_wrapper -->|"adapts"| node_ember
node_wrapper -->|"adapts"| node_sorel
node_classifier -->|"wraps model"| node_endmodel
node_malconv -->|"extends"| node_endmodel
node_xai -->|"analyzes"| node_classifier
node_whitebox -.->|"supports PE edits"| node_peops
node_gamma -.->|"manipulates PE"| node_peops

click node_whitebox "https://github.com/pralab/secml_malware/tree/master/secml_malware/attack/whitebox"
click node_gradient "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_fast_gradient_sign_evasion.py"
click node_byteattack "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_discretized_bytes_evasion.py"
click node_blackbox "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_blackbox_problem.py"
click node_gamma "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_gamma_evasion.py"
click node_optimizer "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/ga/c_base_genetic_engine.py"
click node_wrapper "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_wrapper_phi.py"
click node_evasionbase "https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_end2end_evasion.py"
click node_classifier "https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_end2end_malware.py"
click node_endmodel "https://github.com/pralab/secml_malware/blob/master/secml_malware/models/basee2e.py"
click node_malconv "https://github.com/pralab/secml_malware/blob/master/secml_malware/models/malconv.py"
click node_ember "https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_ember.py"
click node_sorel "https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_sorel_net.py"
click node_remote "https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_remote.py"
click node_xai "https://github.com/pralab/secml_malware/blob/master/secml_malware/xai/c_integrated_gradients.py"
click node_visualization "https://github.com/pralab/secml_malware/blob/master/secml_malware/visualization/exe.py"
click node_peops "https://github.com/pralab/secml_malware/blob/master/secml_malware/utils/pe_operations.py"

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_whitebox,node_gradient,node_byteattack,node_blackbox,node_gamma,node_optimizer,node_wrapper,node_evasionbase toneBlue
class node_classifier,node_endmodel,node_malconv,node_ember,node_sorel,node_remote toneAmber
class node_xai,node_visualization toneMint
class node_peops toneRose
class node_user toneIndigo
```

## Components

### Adversarial attacks

- [White-box attacks](https://github.com/pralab/secml_malware/tree/master/secml_malware/attack/whitebox): `secml_malware/attack/whitebox`
- [Gradient attacks](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_fast_gradient_sign_evasion.py): `secml_malware/attack/whitebox/c_fast_gradient_sign_evasion.py`
- [Byte optimization](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_discretized_bytes_evasion.py): `secml_malware/attack/whitebox/c_discretized_bytes_evasion.py`
- [Black-box attacks](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_blackbox_problem.py): `secml_malware/attack/blackbox/c_blackbox_problem.py`
- [GAMMA search](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_gamma_evasion.py): `secml_malware/attack/blackbox/c_gamma_evasion.py`
- [Genetic optimizer](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/ga/c_base_genetic_engine.py): `secml_malware/attack/blackbox/ga/c_base_genetic_engine.py`
- [Detector adapter](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/blackbox/c_wrapper_phi.py): `secml_malware/attack/blackbox/c_wrapper_phi.py`
- [Evasion framework](https://github.com/pralab/secml_malware/blob/master/secml_malware/attack/whitebox/c_end2end_evasion.py): `secml_malware/attack/whitebox/c_end2end_evasion.py`

### Detection models

- [End-to-end classifier](https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_end2end_malware.py): `secml_malware/models/c_classifier_end2end_malware.py`
- [End-to-end model](https://github.com/pralab/secml_malware/blob/master/secml_malware/models/basee2e.py): `secml_malware/models/basee2e.py`
- [MalConv model](https://github.com/pralab/secml_malware/blob/master/secml_malware/models/malconv.py): `secml_malware/models/malconv.py`
- [EMBER classifier](https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_ember.py): `secml_malware/models/c_classifier_ember.py`
- [SOREL classifier](https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_sorel_net.py): `secml_malware/models/c_classifier_sorel_net.py`
- [Remote classifier](https://github.com/pralab/secml_malware/blob/master/secml_malware/models/c_classifier_remote.py): `secml_malware/models/c_classifier_remote.py`

### Analysis tools

- [Integrated gradients](https://github.com/pralab/secml_malware/blob/master/secml_malware/xai/c_integrated_gradients.py): `secml_malware/xai/c_integrated_gradients.py`
- [Executable visualization](https://github.com/pralab/secml_malware/blob/master/secml_malware/visualization/exe.py): `secml_malware/visualization/exe.py`

### PE utilities

- [PE transformations](https://github.com/pralab/secml_malware/blob/master/secml_malware/utils/pe_operations.py): `secml_malware/utils/pe_operations.py`

### Other components

- **Researcher**

## Connections

- Researcher → White-box attacks: runs attacks (evidence: `README.md`)
- Researcher → Black-box attacks: runs attacks (evidence: `README.md`)
- White-box attacks → Gradient attacks: includes (evidence: `secml_malware/attack/whitebox/__init__.py`)
- White-box attacks → Byte optimization: includes (evidence: `secml_malware/attack/whitebox/__init__.py`)
- White-box attacks → Evasion framework: uses framework (evidence: `secml_malware/attack/whitebox/c_discretized_bytes_evasion.py`)
- Gradient attacks → Evasion framework: extends (evidence: `secml_malware/attack/whitebox/c_fast_gradient_sign_evasion.py`)
- Byte optimization → Evasion framework: extends (evidence: `secml_malware/attack/whitebox/c_discretized_bytes_evasion.py`)
- Evasion framework → End-to-end classifier: uses classifier (evidence: `secml_malware/attack/whitebox/c_end2end_evasion.py`)
- Black-box attacks → Detector adapter: scores candidates (evidence: `secml_malware/attack/blackbox/c_blackbox_problem.py`)
- GAMMA search → Black-box attacks: specializes problem (evidence: `secml_malware/attack/blackbox/c_gamma_evasion.py`)
- Genetic optimizer → Black-box attacks: optimizes problem (evidence: `secml_malware/attack/blackbox/ga/c_base_genetic_engine.py`)
- Detector adapter → End-to-end classifier: wraps detector (evidence: `secml_malware/attack/blackbox/c_wrapper_phi.py`)
- Detector adapter → EMBER classifier: adapts (evidence: `secml_malware/attack/blackbox/c_wrapper_phi.py`)
- Detector adapter → SOREL classifier: adapts (evidence: `secml_malware/attack/blackbox/c_wrapper_phi.py`)
- End-to-end classifier → End-to-end model: wraps model (evidence: `secml_malware/models/c_classifier_end2end_malware.py`)
- MalConv model → End-to-end model: extends (evidence: `secml_malware/models/malconv.py`)
- Integrated gradients → End-to-end classifier: analyzes (evidence: `secml_malware/xai/c_integrated_gradients.py`)
- White-box attacks → PE transformations: supports PE edits (evidence: `secml_malware/attack/whitebox/c_format_exploit_evasion.py`)
- GAMMA search → PE transformations: manipulates PE
