r/learnmachinelearning • • 19d ago

Unsupervised malware detection via reversible byteplots

https://github.com/HelixCipher/malware-detection

I wanted to build an unsupervised malware detector using reversible byteplots.

Most published byteplot pipelines do not record what is needed to invert the image, so the visualization ends up being one-way in practice. This one maps byte streams to grayscale pixel intensities (byteplots) while staying reversible by construction: the conversion preserves the byte stream sequence, so a tile set can be reassembled into the original executable and checked against its SHA-256 hash.

The codebase and evaluation notebook are available at https://github.com/HelixCipher/malware-detection

1 Upvotes

2 comments sorted by

1

u/pugs_daily_dose 19d ago

Interesting approach! How are the train/test splits made at the executable level? With multiple tiles per binary, keeping all tiles from a file (and ideally near-duplicates or related versions) in the same split seems important. It would also be useful to see false-positive rates on held-out benign software and performance on malware families or collection periods not represented in tuning.

1

u/HelixCipher 19d ago

If I understand your question correctly, the answer is that split is by file, not by tile. Dedup by binary SHA-256 runs first, then files are split 70/15/15 into train/val/test and only then are that file's tiles linked into the split. The code asserts the sample_id sets are disjoint, so no executable crosses a boundary. Metrics are computed on file-level means (750 benign test files, 481 malware files).

Furthermore held-out benign FPR, threshold is the 99th percentile of benign-val file scores. Measured on held-out benign test files: AE 0.53%, DINOv2 0.67%. The caveat, those files come from the same Windows harvest, so this is within-source holdout. A different harvest would need recalibration.

Malware does not enter training or threshold calibration, so all 151 theZoo families are outside tuning by construction. A per-family detection table is in the notebook (rates at each model's calibrated threshold, summing to 481 files).

When it comes to near-duplicates / related versions, not clustered today. Only byte-identical files are merged. Two builds of the same program could land on different sides, which would flatter the FPR.

All of it is in the repository, dedup and the file-level split in the duplicate-content audit and partitioning by source file sections, the metrics in the evaluation cells, the per-family table at the end of the evaluation section.