Some of us are
cursed unfortunate to have to be using Windows when it has been long known to be the least secure operating system in the whole world, essentially.
There are a variety of ways that malware can infect your computer but we are not concerned about any of them right now, we are here to discuss one thing.
Most malware have a kill-switch that terminates if it is running inside a virtual machine, or is running with some other parameters, so in this post, I will tell you the common cases where a virus will exit and show you how to activate them.
Easy:The simplest case is when the malware is unable to talk to anything on the internet. In this case, based on samples that I have seen, they automatically exit and/or query in an infinite loop. An offline computer cannot be hacked. The way to detect this is to run monitoring with Wireshark or tcpcap, and have other software read the log files they generate and alert you if a program is repeatedly querying an IP address or website.
Here in this case, the virus will quit if the hostname matches one from a specific list. You are able to open any reverse engineering tool like WinDbg and search for human-readable strings, to find them out. If you have MinGW installed you can also use the "strings" program in the terminal.
Similarly, the virus quits if the system's MAC address matches one on a hard-coded list. There are some MAC address spoofers you can find on Google which can spoof your MAC address to be one of those addresses, which will make you immune to that strain of malware.
Medium:Similarly, the virus will sometimes refuse to execute if the username matches a hard-coded list. But since you can't easily change the username on a Windows account, this could pose a problem. The solution is to use a reverse engineering tool to "insert" your own username as a string (but it would be a lot safer to not run the program).
Generally speaking, malware will not run on any computer that it believes is a virtual machine. This includes all systems with resolution less than 800x600. You can't easily spoof your display resolution, however you can intercept API calls to Windows by downloading/building the Detours program by Microsoft and intercepting the calls. And also you can use the Process Monitor program that is part of Sysinternals to detect this API call.
Hard:
If there's a hard-coded list of IP addresses, you can take advantage of that, but this usually does not work for two reasons. First, home connections use NAT by their ISP which means their IP address keeps changing. And second, it is next to impossible to spoof the IP address unless you have access to specialized software that is not available on Windows. But you can try anyway.
Certain viruses detect the strings "VMware" and "VBox" insite the registry editor for the hardware ID, the disks, etc. But it is very dangerous to change these as you might break your computer by using the registry editor.
I have one more tip for you: If you use a VPN for the whole computer, you will bypass most malware which checks if you are using a residential (home) connection or a datacenter (VPN) connection. So you should have a VPN running at all times, even if it is a free one.
I hope this helps somebody and makes them avoid getting hacked.