Malware
Malware authors target bugs, or loopholes, to exploit. A common method is exploitation of a buffer overrun vulnerability, where software designed to store data in a specified region of memory does not prevent more data than the buffer can accommodate being supplied. Malware may provide data that overflows the buffer, with malicious executable code or data after the end; when this payload is accessed it does what the attacker, not the legitimate software, determines.
Government hacking
Nowadays, the most well-known and legitimate form of government hacking is the watering hole operation, which the government takes control of a criminal activity site and continues to operate it in order to distribute the virus to computer to access it. The malware can be installed through a link, in which the user clicks, or secretly, through an access to a certain site. The user is not aware of the virtual virus infection on his machine because the malware partially controls it, only to search for identifying information and send it back to the source.