OpCode-Based Malware Classification Using Machine Learning and Deep Learning Techniques

Varij Saini, Rudraksh Gupta, Neel Soni · 2025

Read OpCode-Based Malware Classification Using Machine Learning and Deep Learning Techniques by Varij Saini, Rudraksh Gupta, Neel Soni (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2504-13408.txt.

Introduction

Varij Saini, Rudraksh Gupta, and Neel Soni compare ways to sort harmful software by its low-level code, in a 2025 report. Their method reads the opcode stream, the step-by-step orders a program runs, and looks for patterns that mark each malware family. They test two routes: classic learning on hand-built features, and a deep network that learns its own features.

Classic tools included a support vector machine, a nearest-neighbor voter, and a decision tree. The support vector machine did best among them. The deep network, a convolutional net, scored close behind while skipping the hand-built features. The authors weigh both routes by accuracy and related scores, as a guide for security teams.

Catalog record

CREATORVarij Saini, Rudraksh Gupta, Neel Soni
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE21 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2504-13408

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

OpCode-Based Malware Classification Using Machine Learning and Deep Learning Techniques Varij Saini, Rudraksh Gupta, Neel Soni Abstract Executive Summary This technical report presents a comprehensive analysis of malware classification using OpCode sequences. Two distinct approaches are evaluated: traditional machine learning using n-gram analysis with Support Vector Machine (SVM), K-Nearest Neighbors (KNN), and Decision Tree classifiers; and a deep learning approach employing a Convolutional Neural Network (CNN). The traditional machine learning approach establishes a baseline using handcrafted 1-gram and 2-gram features from disassembled malware samples. The deep learning methodology builds upon the work proposed in “Deep Android Malware Detection” by McLaughlin et al. and evaluates the performance of a CNN model trained to automatically extract features from raw OpCode data. Empirical results are compared using standard performance metrics (accuracy, precision, recall, and F1-score). While the SVM classifier outperforms other traditional techniques, the CNN model demonstrates competitive performance with the added benefit of automated feature extraction. 1 Introduction In an era of increasingly sophisticated cyberattacks, the detection and classification of malicious software, or malware, remain central to safeguarding digital infrastructure. Among the most formidable threats are Advanced Persistent Threats (APTs), which employ stealthy and prolonged campaigns to exfiltrate sensitive data and compromise critical systems [ 1 , 2 ] . Traditional signature-based antivirus mechanisms have shown declining efficacy against such advanced adversaries, as malware authors continually develop obfuscation techniques to evade static and dynamic detection engines. In response, the cybersecurity research community has increasingly turned to machine learning (ML) and deep learning (DL) techniques, aiming to detect malware by uncovering subtle, intrinsic patterns within executable code [ 3 , 4 ] . One promising line of inquiry involves the analysis of OpCode sequences—low-level machine instructions executed by a CPU during program execution. OpCodes offer a more granular and robust representation of a program’s behavior than higher-level features, making them less susceptible to evasion through superficial code manipulation. This project builds upon this insight, proposing a comparative evaluation of traditional machine learning algorithms and a deep learning-based model for malware classification based solely on OpCode sequences extracted from disassembled malware binaries [ 5 , 6 ] . The primary goal of this research is to assess the trade-offs between handcrafted n-gram features and automated feature learning. The traditional approach employs Support Vector Machines (SVM), K-Nearest Neighbors (KNN), and Decision Tree classifiers using 1-gram and 2-gram frequency distributions as input features. These models serve as a performance benchmark for the proposed deep learning method, which utilizes a Convolutional Neural Network (CNN) architecture to directly process raw OpCode sequences. By eliminating manual feature engineering, the CNN approach aims to streamline the malware detection pipeline while uncovering latent sequence patterns that may not be captured by fixed-length n-grams [ 7 , 8 ] . To ensure methodological rigor, the models are trained and evaluated using standard classification metrics—accuracy, precision, recall, and F1-score—on a labeled dataset of APT malware families. Through this comparative study, we aim to provide empirical insights into the effectiveness of OpCode-based features, the scalability of automated learning in malware classification, and the practical implications for developing real-world threat detection systems. The research not only highlights the strengths and limitations of each approach but also establishes a reproducible framework for future work in OpCode-based malware analysis [ 9 , 10 ] . 1.1 Background and Motivation Malware continues to pose a critical threat to organizations worldwide, with evasion techniques rapidly evolving to bypass signature-based detection systems [ 11 ] . Static analysis of executable code structures, particularly through OpCode sequences, has emerged as a robust method for malware family identification. OpCodes, the machine-level instructions executed by processors, provide distinctive patterns even in obfuscated malware samples. The extraction and classification of these sequences form the foundation for effective threat intelligence and risk assessment. This project is designed to document Advanced Persistent Threat (APT) Tactics, Techniques, and Procedures (TTPs) and develop both traditional machine learning and deep learning models for detecting malicious payloads used by APT groups [ 12 , 13 ] . 1.2 Research Objectives The study aims to: • Evaluate the effectiveness of OpCode n-gram analysis for malware classification. • Compare the performance of traditional machine learning algorithms (SVM, KNN, Decision Tree) on 1-gram and 2-gram features. • Implement and evaluate a CNN-based model for OpCode-based malware classification. • Compare the performance of the CNN model with traditional classifiers to assess the trade-offs between manual feature engineering and automated deep learning feature extraction. • Develop a reproducible methodology for OpCode-based malware classification. 1.3 Scope and Limitations The research focuses on the static analysis of OpCode sequences extracted from disassembled malware samples. Dynamic analysis is beyond this study’s scope [ 14 , 15 ] . While the evaluation is limited to three traditional classifiers and a CNN, further advanced models may yield improvements. The work provides empirical evidence and establishes a methodological framework for future malware analysis [ 16 , 17 ] . 2 Methodology This study employs both traditional machine learning and deep learning techniques to classify malware based on OpCode sequences extracted from disassembled APT malware samples. The dataset comprises files labeled by malware family, from which raw OpCodes are extracted while discarding operands. For traditional models, 1-gram and 2-gram frequency features are computed and transformed into normalized feature vectors. Class imbalance is addressed using RandomOverSampler. Support Vector Machine (SVM), K-Nearest Neighbors (KNN), and Decision Tree classifiers are trained and evaluated using standard metrics [ 18 , 19 ] . In parallel, a Convolutional Neural Network (CNN) is implemented to process raw OpCode sequences without manual feature engineering. The CNN architecture includes two 1D convolutional layers, max pooling, ReLU activations, dropout regularization, and fully connected layers for classification. The model is trained using PyTorch with Adam optimization and learning rate scheduling. Performance of both approaches is evaluated using accuracy, precision, recall, and F1-score to assess effectiveness and generalization. 2.1 Dataset Acquisition and Preprocessing The dataset comprises disassembled OpCode files extracted from malware samples belonging to various APT families. The files are organized by malware family using filenames formatted as [malware_family]_[sample_id].opcode , enabling automated labeling during preprocessing. Traditional Machine Learning Approach • OpCode Extraction: Files are parsed to extract OpCode sequences, ignoring operands. • N-gram Generation: Both 1-gram (individual OpCodes) and 2-gram (sequential pairs) features are generated. • Feature Vector Creation: Frequency distributions of n-grams are used to create feature vectors. • Data Normalization and Class Imbalance Handling: StandardScaler is applied to normalize features, and RandomOverSampler is used to balance class distributions. Deep Learning Approach • Preprocessed OpCode sequences are loaded from previously generated numpy arrays. • Label encoding converts string labels to integers, and data is converted into PyTorch tensors with DataLoader objects created for batch processing. 2.2 Feature Extraction and Representation Feature extraction in this study is tailored to the nature of OpCode sequences derived from disassembled malware binaries. For the traditional machine learning approach, features are created by generating n-grams—specifically 1-grams (individual OpCodes) and 2-grams (consecutive OpCode pairs). These n-grams are counted to form frequency distributions, which are then transformed into numerical feature vectors representing each malware sample. The resulting vectors are normalized using StandardScaler to ensure consistent scaling across features [ 20 , 21 ] . In contrast, the deep

Read the complete text