In this post, we want to discuss how to make a simple computer virus using python for a fun project. Hope you are doing well. Let’s start.


A computer virus is a type of malicious software program (“malware”) that, when executed, replicates by reproducing itself (copying its own source code) or infecting other computer programs by modifying them. Infecting computer programs can include as well, data files, or the “boot” sector of the hard drive. When this replication succeeds, the affected areas are then said to be “infected” with a computer virus.

The term “virus” is also commonly, but erroneously, used to refer to other types of malware. “Malware” encompasses computer viruses along with many other forms of malicious software, such as computer “worms”, ransomware, Trojan horses, key loggers, rootkits, spyware, adware, malicious Browser Helper Object (BHOs), and other malicious software. The majority of active malware threats are actually Trojan horse programs or computer worms rather than computer viruses.

Virus writers use social engineering deceptions and exploit detailed knowledge of security vulnerabilities to gain access to their host’s computers and computing resources. The vast majority of viruses target systems running Microsoft Windows, employing a variety of mechanisms to infect new hosts, and often using complex anti-detection/stealth strategies to evade antivirus software.

Motives for creating viruses can include seeking profit (e.g., with ransomware), desire to send a political message, personal amusement, to demonstrate that a vulnerability exists in software, for sabotage and denial of service, or simply because they wish to explore cybersecurity issues, artificial life, and evolutionary algorithms.

Computer Virus Phases

Basically, every computer virus has two phases –

  1. Insertion phase – in this phase, the virus inserts itself into the target.
  2. Execution phase- in this phase, the virus performs some actions.
Codding for Virus

Let’s check some code to make a simple virus. This is a fun project. Don’t be hesitate. The code performs a search for the python files and makes all the strings to the Following String “HAHA YOU ARE AFFECTED BY VIRUS!! AND THAT”S AN EVIL ALUGH BY THE WAY!!”.

You may also like 16 Best Free Bootable Antivirus Tools.

How to make a simple computer virus in Python

Leave a Comment