Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Malware Analysis

You're reading from   Mastering Malware Analysis A malware analyst's practical guide to combating malicious software, APT, cybercrime, and IoT attacks

Arrow left icon
Product type Paperback
Published in Sep 2022
Publisher Packt
ISBN-13 9781803240244
Length 572 pages
Edition 2nd Edition
Arrow right icon
Authors (2):
Arrow left icon
Amr Thabet Amr Thabet
Author Profile Icon Amr Thabet
Amr Thabet
Alexey Kleymenov Alexey Kleymenov
Author Profile Icon Alexey Kleymenov
Alexey Kleymenov
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Part 1 Fundamental Theory
2. Chapter 1: Cybercrime, APT Attacks, and Research Strategies FREE CHAPTER 3. Chapter 2: A Crash Course in Assembly and Programming Basics 4. Part 2 Diving Deep into Windows Malware
5. Chapter 3: Basic Static and Dynamic Analysis for x86/x64 6. Chapter 4: Unpacking, Decryption, and Deobfuscation 7. Chapter 5: Inspecting Process Injection and API Hooking 8. Chapter 6: Bypassing Anti-Reverse Engineering Techniques 9. Chapter 7: Understanding Kernel-Mode Rootkits 10. Part 3 Examining Cross-Platform and Bytecode-Based Malware
11. Chapter 8: Handling Exploits and Shellcode 12. Chapter 9: Reversing Bytecode Languages – .NET, Java, and More 13. Chapter 10: Scripts and Macros – Reversing, Deobfuscation, and Debugging 14. Part 4 Looking into IoT and Other Platforms
15. Chapter 11: Dissecting Linux and IoT Malware 16. Chapter 12: Introduction to macOS and iOS Threats 17. Chapter 13: Analyzing Android Malware Samples 18. Index 19. Other Books You May Enjoy

Setting up the environment

Being able to safely analyze malicious samples is a prerequisite for any engineer performing reverse engineering, whether it is a one-time task or a daily routine. Usually, for this purpose, Virtual Machines (VMs) are used because it is easy to make copies of them, apply any changes, and save snapshots to restore some previous state of the machine. Another option is to have dedicated physical machines separated from critical networks; in this case, some backup software is generally used to quickly restore the previous state of the machine. In this section, we are going to talk about setting up a safe environment for malware analysis and the most important steps to focus on.

Choosing the virtualization software

When you are ready to create a new VM, the first task is to choose what software will be used for this purpose. Generally, the top choices of reverse engineers are the following:

  • VMware: A very popular commercial solution that also provides a free player to run already existing VMs
  • VirtualBox: A free fully functional alternative that allows both the creation and running of VMs

Both of the preceding options provide similar end-user-oriented functionality and features such as snapshot management, emulation of shared ports, devices, folders, a clipboard, and network access.

QEMU is another option here, but the project has historically been more focused on emulation than virtualization, and its user interface (UI) might be less user-friendly for daily reverse engineering work. Other projects worth mentioning here include the Kernel-Based Virtual Machine (KVM) virtualization module, commonly used together with QEMU, and the Xen and Hyper-V hypervisors.

Regardless of what software you choose, the corresponding VM images can generally be converted from one type to another. However, each virtualization software has its own guest tools that make it possible to use features such as shared clipboards – in this case, they will need to be installed and set up separately.

Finally, there are pre-built VM images with a set of RE tools already pre-installed:

  • FLARE VM: A free, open source, Windows-based solution supported by Mandiant/FireEye
  • REMnux: A free, open source, Linux-based distribution that also provides pre-built VMs

Safety features

Here are the top safety features that should be respected when creating an RE-oriented VM lab:

  • Disabled network

As we know, many malware categories may misuse the network for malicious purposes. Whether it is sending spam, propagating to other machines, or stealing engineers’ proprietary licenses, the rule of thumb here is to disable the network by default. There are plenty of techniques and pieces of software that can be used to simulate a network connection for analysis purposes, such as INetSim and FakeNet.

Figure 1.2 – Disabled network in the VirtualBox VM’s settings

Figure 1.2 – Disabled network in the VirtualBox VM’s settings

  • No shared devices

Many forms of virtualization software, by default, link connected peripheral physical devices to the VM. This can be extremely dangerous, for example, in the case of USB drives. In this case, malware can propagate there and this way escape the secure environment. Therefore, all such devices should be disabled.

Figure 1.3 – Disabled USB controller in the VirtualBox VM’s settings

Figure 1.3 – Disabled USB controller in the VirtualBox VM’s settings

  • Be careful with shared folders

Shared folders map some folders present on the host machine to folders mapped on the guest (virtual) machine for easy file transfer. The main concern here is that viruses can infect files located there (namely, executables or documents) or replace existing files with malicious ones. And just like that, the malware has found a way to the host machine. So, shared folders should always be used with care. One way this can be done is to avoid storing any files there longer than necessary: once the files are copied there on the host machine, take them out of there on the guest VM and leave the folder empty until the next task. Making the shared folder read-only for the guest machine is another option.

Once we have prepared our lab VM, the next question is – how can we copy our malicious samples there for analysis? There are multiple ways this can be done:

  • Private network: Ideally, this should be avoided as malware running on the guest machine may also have network access to the host machine.
  • Shared folders: As just discussed, use with care.
  • Shared clipboard: One of the safest solutions. Requires guest additions to be installed on the VM in order to work.

As for moving files back from the VM to the production PC, the rule of thumb here is to exercise extreme caution. Consider doing it only for text files containing the result of your work and similar cases. If it is absolutely necessary to transfer anything containing malicious code and data (including memory dumps and network PCAPs), consider using password-protected archives to store them, which shouldn’t be extracted on the host machine.

You have been reading a chapter from
Mastering Malware Analysis - Second Edition
Published in: Sep 2022
Publisher: Packt
ISBN-13: 9781803240244
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image