1. Converting Malicious Binaries into Visual Imagery
A breakthrough technique in malware classification is treating raw executable files as continuous byte arrays and rendering them into 2D grayscale images.
A byte sequence consisting of values from 0x00 to 0xFF (0 to 255) maps directly to 8-bit grayscale pixel intensities (0 = black, 255 = white).
Raw Binary Byte Stream:
[4D 5A 90 00 03 00 00 00 04 00 00 00 FF FF 00 00 ...]
|
v Fixed-Width Pixel Reshaping
+------------------------------------------------------+
| Pixel 0,0 (77) Pixel 0,1 (90) Pixel 0,2 (144) ... | (DOS Header)
| Pixel 1,0 (0) Pixel 1,1 (3) Pixel 1,2 (0) ... |
| .................................................... |
| High-Frequency Texture (Code Section .text) | (Opcodes & Logic)
| .................................................... |
| Uniform Black/White Blocks (Zero-Padded Data) | (.data / Unused)
| High-Entropy Noise Texture (Encrypted/Packed Data) | (.rsrc / Payload)
+------------------------------------------------------+Image Width Selection Matrix:
| File Size Range | Fixed Image Width | Visual Representation |
|---|---|---|
< 10 KB | 32 pixels | Compact header layout |
10 KB – 30 KB | 64 pixels | Standard small utility |
30 KB – 100 KB | 128 pixels | Common trojan/ransomware size |
100 KB – 500 KB | 256 pixels | Complex packed binary |
> 1 MB | 1024 pixels | Large multi-stage payload |
2. DenseNet Architecture for Structural Feature Extraction
Traditional Convolutional Neural Networks (CNNs) pass feature maps sequentially from layer l to layer l+1. In deep networks, gradients vanish during backpropagation, leading to degraded performance.
DenseNet (Densely Connected Convolutional Networks) solves this by connecting every layer to every subsequent layer in a feed-forward fashion:
Every neural network layer receives inputs directly from all previous layers. This ensures essential structural details (like raw binary file headers and section boundaries) are never lost during deep training.
x_lLayer OutputAggregated feature representation generated by network layer l
H_lLayer TransformationComposite function: Batch Normalization, ReLU activation, and 3×3 Convolution
[x₀, ..., x_(l-1)]Feature ConcatenationAll feature maps from preceding layers stacked along the channel axis
Where [x_0, x_1, dots, x_l-1] represents the concatenation of feature maps produced in all preceding layers.
DenseNet Layer Interconnectivity:
[ Layer 0: Input Image ]
|---+---+---+
| | | |
v | | |
[ Layer 1: Conv 3x3 ]
|---+---+
| | |
v | |
[ Layer 2: Conv 3x3 ]
|---+
v |
[ Layer 3: Conv 3x3 ]
v
[ Transition Layer: Pooling & Compression ]Advantages for Malware Classification:
- 1Strong Feature Reuse: Low-level structural patterns (PE header boundaries, section alignment padding) are preserved alongside high-level semantic patterns.
- 2Substantial Parameter Reduction: Narrow layers with growth rate k=12 or k=32 require far fewer weights than traditional VGG or ResNet architectures.
3. Sequential Modeling: LSTMs for System Call Tracing
While DenseNet captures static spatial layout, it cannot evaluate time-series execution order. Threat actors frequently reorder subroutines to evade static detectors while preserving execution logic.
Long Short-Term Memory (LSTM) recurrent networks process sequences of system calls intercepted during dynamic analysis:
The classic 4-step Windows API sequence that malware uses to hijack a trusted host process: it opens the victim process, allocates memory space, writes malicious shellcode, and spawns a thread to run the code invisibly.
NtOpenProcessHandle AcquisitionRequests read/write memory privileges for a running victim process
NtAllocateVirtualMemoryMemory AllocationReserves unmapped executable memory buffer (PAGE_EXECUTE_READWRITE) in target
NtWriteVirtualMemoryPayload InjectionCopies malicious shellcode or DLL code directly into the allocated memory
NtCreateThreadExThread ExecutionForces the remote process to start executing instructions at the injected code address
Hybrid DenseNet + LSTM Architecture
Input Binary File
|
+-----------------------------------+
| |
v Render to Grayscale Image v Execute in Dynamic Sandbox
[ 256x256 Image ] [ System Call Sequence (Len: 500) ]
| |
v DenseNet-121 Feature Extractor v Embedding + Bidirectional LSTM
[ Spatial Latent Vector (512-dim) ] [ Temporal Latent Vector (256-dim) ]
| |
+-----------------+-----------------+
|
v Concatenate Vectors (768-dim)
[ Fully Connected Dense Layer ]
|
v Softmax Output
[ P(Malicious) vs. P(Benign) ]This hybrid approach ensures that even if an attacker alters binary visual layout through padding, the sequential LSTM detects the malicious execution pattern; conversely, if the malware stalls execution to evade the sandbox, DenseNet flags the anomalous structural layout!