A safe environment helps us to investigate the malware without exposing our machine or other machines on the network to unexpected and unnecessary risk. Malware can also be analyzed using individual physical machines on air-gapped networks. These are isolated networks with machines disconnected from the Internet or any other networks to prevent the malware from spreading.
The lack of Internet connection is a major disadvantage as many piece of malware depend on a live Internet connection for updates, command and control and other features. Another disadvantage of physical machines is that malware can be difficult to remove.
The main advantage of using physical machines is that malware can sometimes execute differently on virtual machines, As you're analyzing a malware on a virtual machine, some malware can detect that its being run on a virtual machine and it will behave differently. Because of the risks and disadvantages that come with using physical machines, virtual machines are commonly used for dynamic analysis.
The Structure Of A Virtual Machine
A guest OS is installed within the host OS on a virtual machine, and the OS running in the virtual machine is kept isolated from the host OS. Malware on a VM cannot harm the host OS. And if the malware damages the host OS, you can simply reinstall the OS in the VM or return the VM to a clean state.
Creating Your Malware Analysis Machine
Apart from disconnecting the VM from the internet there are a few other options
Host-Only Networking
Host-only networking, a feature that creates a separate private LAN between the host OS and the guest OS, is commonly used for malware analysis. A host-only LAN is not connected to the Internet, which means that the malware is contained within the VM but allowed some network connectivity.
When host-only networking is enabled, VMware creates a virtual network adapter in the host and virtual machines, and connects the two without touching the host's physical network adapter. The host's physical network adapter is still connected to the Internet or other external network.
Using Multiple VMs
This requires multiple VMs linked by a LAN but disconnected from the Internet and host machine, so that the malware is connected to a network, but the network isn't connected to anything important.
In this configuration, one VM is set up to analyze malware, and the second machine provides services. The two VMs are connected to the same VMNet virtual switch. IN this case, the host machine is still connected to the external network but not to the machine running the malware.
Using Your Malware Analysis Machine
To exercise the functionality of the subject malware as much as possible, all network services which the malware relies on must be simulated. e.g. malware commonly connects to an HTTP server to download additional malware. TO observe this, you'll need to give the malware access to a DNS server to resolve the server's IP address, as well as an HTTP server to respond to requests. With our custom configuration, the machine providing services should be running the services required for the malware to communicate.
Connecting Malware to the Internet
Perform some analysis first and connect only if you are comfortable with the risks.
The most common way to connect a VM to the Internet is a bridged network adapter, which allows the VM to be connected to the same network interface as the physical machine. Another way to connect malware running on a VM to the Internet is use VMware's NAT mode.
NAT mode shares the host's IP connection to the Internet. The host acts like a router and translates all requests from the VM so that they come from the host's IP address. This mode is useful when the host is connected to a network, but the network configuration makes it difficult, if not impossible to connect the VM's adapter to the same network.
Connecting and Disconnecting Peripheral Devices
Most devices can be connected either to the physical machine or the VM, but not both.
If you connect a USB device to a machine while the VM window is active, VMware will connect the device to the guest and not the host, which may be undesirable, considering the growing popularity of worms spreading through USB devices. To modify this setting, choose VM > Settings > USB Controller and uncheck the Automatically Connect new USB devices checkbox to prevent them from being connected to the VM.
Taking Snapshots
VMware's VM snapshots allow you to save a computer's current state and return to that point later, similar to a Windows restore point. It's like a built-in undo feature which saves you the hassle of re-installing the OS. After you have installed the OS and installed the tools, take a snapshot and this serves as you base snapshot.
You can also branch your snapshots to take different paths. For example:
1. While analyzing sample 1, you are frustrated and want to try another sample.
2. You take a snapshot of the malware analysis of sample 1
3. You return to the base image
4. You begin to analyze sample 2
5. You take a snapshot to take a break
When you return, you can access either snapshot at any time.
Transferring Files from a Virtual Machine
One drawback of using snapshots is that any work undertaken on the virtual machine is lost when you revert to an earlier snapshot. You can, however, save your work before loading the earlier snapshot by transferring any files that you want to keep to the host OS using VMware's drag and drop feature. Another way to transfer is VMware's shared folders. A shared folder is accessible from both the host and the guest OS, similar to a shared Windows folder.
The Risk of Using VMware for Malware Analysis
Some malware can detect when its running within a virtual machine, and many techniques have been published to detect just such a situation.
Perform some analysis first and connect only if you are comfortable with the risks.
The most common way to connect a VM to the Internet is a bridged network adapter, which allows the VM to be connected to the same network interface as the physical machine. Another way to connect malware running on a VM to the Internet is use VMware's NAT mode.
NAT mode shares the host's IP connection to the Internet. The host acts like a router and translates all requests from the VM so that they come from the host's IP address. This mode is useful when the host is connected to a network, but the network configuration makes it difficult, if not impossible to connect the VM's adapter to the same network.
Connecting and Disconnecting Peripheral Devices
Most devices can be connected either to the physical machine or the VM, but not both.
If you connect a USB device to a machine while the VM window is active, VMware will connect the device to the guest and not the host, which may be undesirable, considering the growing popularity of worms spreading through USB devices. To modify this setting, choose VM > Settings > USB Controller and uncheck the Automatically Connect new USB devices checkbox to prevent them from being connected to the VM.
Taking Snapshots
VMware's VM snapshots allow you to save a computer's current state and return to that point later, similar to a Windows restore point. It's like a built-in undo feature which saves you the hassle of re-installing the OS. After you have installed the OS and installed the tools, take a snapshot and this serves as you base snapshot.
You can also branch your snapshots to take different paths. For example:
1. While analyzing sample 1, you are frustrated and want to try another sample.
2. You take a snapshot of the malware analysis of sample 1
3. You return to the base image
4. You begin to analyze sample 2
5. You take a snapshot to take a break
When you return, you can access either snapshot at any time.
Transferring Files from a Virtual Machine
One drawback of using snapshots is that any work undertaken on the virtual machine is lost when you revert to an earlier snapshot. You can, however, save your work before loading the earlier snapshot by transferring any files that you want to keep to the host OS using VMware's drag and drop feature. Another way to transfer is VMware's shared folders. A shared folder is accessible from both the host and the guest OS, similar to a shared Windows folder.
The Risk of Using VMware for Malware Analysis
Some malware can detect when its running within a virtual machine, and many techniques have been published to detect just such a situation.