What convolutional neural network architecture works best for classifying malware images
Tags: Machine Learning, Research, Artificial Intelligence, Deep Learning, Security

What convolutional neural network architecture works best for classifying malware images

Apparently, we can now detect viruses by converting them into images

As the world goes digital, cybersecurity becomes exceedingly important. Manually programming rules to catch the viruses is slow and will never keep up with ever-changing malware. This is why the idea of representing malware binaries as an image was groundbreaking. The procedure is relatively simple and is done by the following procedure:

How to catch malware

This approach comes with several benefits. Accurate conversion to images will allow us to use the various deep-learning based CNNs in image classification. Visualizing the malware will let us spot patterns. And all this can be done without having to run the malware. This is a big plus for security. Classifying Malware Images with Convolutional Neural Network Models by Bensaoud et al dives into this. It compares the performance of several image-classification architectures when it comes to classifying malware images. In this article, I will explain the different models compared, as well as elaborate on the results. As always, I will talk of any implications and extensions. At the end of this article, will be the annotated version of the paper, so that you can understand some of the nuances better.

The need for ML-based detection

Some might be wondering why ML-based detection would be useful. It would be much more expensive than traditional ways. Would the overhead justify itself? In a chart:

This rapidly increasing number is more than enough justification. This pandemic has accelerated the online shift. As automation changes many areas of life, this number will keep increasing. Building robust and generalized models will not only work well for all types of malware present but also for future malware (more in the extension section).

Results and Understanding the different protocols

Above is a summary of the results predicting the classifying different types of viruses. We see some variance with 2 models getting sub-30% accuracy. The other 4 are all in their 90s. Inception V3 is the winner. If you don’t know these models, no worries, I will now be explaining them all. All the architecture images are taken from the images unless specified otherwise.

VGG 16

VGG 16 is a very interesting model. It prioritizes depth over width by applying 3x3 convolution filters that are small. This allows them to increase the number of layers from 16 to 19. It was first proposed in the paper “Very Deep Convolutional Networks for Large-Scale Image Recognition” by a team from the University of Oxford. It performed extremely well on the ImageNet dataset, beating more complex models. However, in this case, it wasn’t able to classify the malware effectively.

Inception V3

Inception V3 is an improvement on the GoogleNet Inception V1. It is an impressive model that is able to keep up with models like VGGNet despite using over 20 times fewer parameters. This model is 42 layers deep, reducing the error. This combines 5 Inception Module As, 4 Inception Module Bs, 2 Inception Module Cs which are combined with 2 Grid Size Reductions and a final auxiliary classifier. This makes it quite powerful, despite a low number of parameters. More information can be found by reading the paper Rethinking the Inception Architecture for Computer Vision. Its results in this assignment speak for itself.

ResNet 50

Another heavy hitter in the image recognition space. This model provides “extra connections between non-contiguous convolutional layers, using shortcut connections.” This allows the model to skip through layers to deal with vanishing gradients in order to achieve lower loss and better results. The network had 152 layers, (8 times deeper than a comparable VGG network). However, it also had a poor performance in this task. Read more here: Deep Residual Learning for Image Recognition

CNN-SVM

CNN-SVM adds a novel twist to a familiar model. “For classification, deep learning models usually use the softmax activation function as the top layer for prediction and minimization of cross-entropy loss. Tang[42] replaced the softmax layer with a linear SVM” This replacement of the softmax with a linear SVM to the final layer of a CNN allowed for the extraction of features for input images with a linear SVM. This worked very well with facial expression recognition. However, it seems to underperform compared to CNN-Softmax which makes me curious why it was used here. Paper: An Architecture Combining Convolutional Neural Network (CNN) and Support Vector Machine (SVM) for Image Classification. I will read more on this, and update anything I learn. If you know about this, be sure to share in the comments.

GRU-SVM

“Agarap and Pepito[17] modified the architecture of a Gated Recurrent Unit (GRU) RNN by using SVM as its final output layer for use in a binary, non-probabilistic classification task (see Fig 8). They used GRU-SVM on the Malimg dataset and achieved 84.92% accuracy.” This was all the paper said about this. So I did some more digging into this. A GRU is a recently-developed variation of the long short-term memory (LSTM) unit. This is a type of Recurrent Neural Net. It excels in areas like translation, NLP, and speech recognition. GRU-SVM model actually outperforms the conventional networks using softmax as the last layer. The paper I found about it is: A Neural Network Architecture Combining Gated Recurrent Unit (GRU) and Support Vector Machine (SVM) for Intrusion Detection in Network Traffic Data.

MLP-SVM

Another SVM addition. This time we don’t replace the final layer of a multi-layer perceptron with an SVM. Instead, we have run the SVM and MLP in parallel and combine their results to get our classification. This technique is essentially an ensemble of 2 models. Done right, ensembles can be very powerful since models can be picked that cover each others weaknesses. This shows in the performance of the MLp-SVM which has the second-best performance of the architectures. It even beat the Inception model at classifying certain families of malware.

A more detailed look at the performance

If you’d prefer a graph:

Closing

This paper was super exciting for various reasons. This combines my love for ML, outside the box thinking, and malware detection to create a perfect paper. I will definitely be going over papers mentioned in the index to learn more about the actual process.

I’m curious why certain CNN architectures were picked over the others. Also the predictions should be extended by including noise into the malware-images. In one of my early articles: How Did Google Researchers Beat ImageNet While Using Fewer Resources? we saw how noise makes models more robust, generalizable, and far far cheaper to train. By adding noise here, we might create models that perform not only for malware that exists now but for the future as well.

Reach out to me

Thank you for reading this. I am dropping all my relevant social media below. Follow any (or all) to see my content across different platforms. I like to use the strengths of different platforms. Leave any feedback you might have, as it really helps a growing content creator like myself. If you found this useful, please share the article.

I’ve shortened the URLs using this great service. They do great work, so show them some love. This is not sponsored, but it’s always good to promote useful work.

Check out my other articles on Medium. : https://rb.gy/zn1aiu

My YouTube. It’s a work in progress haha: https://rb.gy/88iwdd

Reach out to me on LinkedIn. Let’s connect: https://rb.gy/m5ok2y

My Twitter: https://twitter.com/Machine01776819

My Substack: https://devanshacc.substack.com/

If you would like to work with me email me: devanshverma425@gmail.com

Live conversations at twitch here: https://rb.gy/zlhk9y

To get updates on my content- Instagram: https://rb.gy/gmvuy9

Get a free stock on Robinhood: https://join.robinhood.com/fnud75

Paper

As promised, below is the annotated paper below. Be sure to read it yourself, to get a better understanding of the research.