Is is possible for malware to be written in a low-level language such as C or C++ and do the following:

  1. Infect a single operating systems(such as Windows)
  2. Detect other machines on the same network
  3. Determine other machines operating systems
  4. If the operating system is the same(Windows) attempt similiar attack
  5. If the operating system is different(OSX or Linux) use quine or download a small attack module to attack the different operating system

TL;DR: Can a C or C++ virus attack multiple operating systems?

(9/8/2016) UPDATE:

Here is recent article of what I am talking about:

  • 3
    There is no reason why this should not be possible, i.e. there is malware out there which can spread within a windows environment, there is malware which can download components to infect more (and also other OS) and of course you can write malware also in C/C++ as you can do in various other languages. – Steffen Ullrich Nov 22 '15 at 6:39
  • 1
    Sure, this is how worms spread themself. – Daniel Ruf Nov 22 '15 at 9:41
  • Have you done any research? I'm seeing lots of hits when I Google variations of your question. – schroeder Nov 22 '15 at 17:51
  • @schroeder I asked this question because it has not been asked on this StackExchange site. It is nice to see other's opinions and answers. – Jared Burrows Nov 22 '15 at 19:57
  • 2
    @JaredBurrows the expectation is that you have done some research before asking questions. If you have, it is helpful that you cite your research in your question so that the members of the community don't end up repeating someone else or pointing you to sources that you have already mined. – schroeder Nov 23 '15 at 0:52
up vote 11 down vote accepted

Short answer: certainly. Remember that once your system is compromised (step 1 in your question), and attacker can perform downloads and run ARBITRARY code. A common approach is "fingerprint and drop", wherein the malware determines the characteristics of your system, and downloads appropriate payloads to execute the attack.

An example of a worm which runs on Windows but is designed to attack another system would be Stuxnet.

An example of malware which fingerprints and drops would be any exploit kit (for example, Angler) that uses drive by downloads.

  • 1
    It may be a interesting answer if the same "executable" can do the same, without the need to upload different parts of code – GameDeveloper Apr 29 '16 at 8:04

I recently reviewed a student's homework assignment that was written in Python, that:

  • Creates a new temporary directory/folder
  • Does some stuff in that folder
  • Moves the output file to the parent directory/folder
  • Deletes the temporary folder

Well at least thats what he thought it did. It actually deletes whatever the current directory is, including the output file.

I gave him an 8/10. -5 points for accidentally deleting the current directory and not having suitable tests. +3 for making it cross-system compatible.

EDIT: Oh, i didn't see the bit about the malware having to be C and C++. Since Python is compiled at runtime, I think the answer still stands though. It's an irrelevant distinction regardless. The Python/Java could have downloaded whatever pre-compiled binary it needed for whatever system it was on, and run that, if the malware really had to be C. Else it could have been a polyglot of Python/C that compiled itself.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.