Sie sind auf Seite 1von 36

1

Read me
batch

file
batc

file

Programming
batch

batch
hacker

ac
C++

t t

python

Web

Web

ac e

php
t t

theory

:D

What is Batch file?


Batch

file

C:\a.txt
D:\
backb0neb00t3r

cmd

a
C:\folder\green.jpg
Copy C:\a.txt D:

copy

Learning cmd commands

C:\folder\green.jpg D:
batc

e
temp

recent


batc

batc

a
windows

ce t

system

:D
Batch file

if, for

ec

, a e, e ,

t , ca ,

batc

cmd
if

For
:D

Echo command
c
Hello World!
Notepad
program.bat

Hello

world!

@echo off
echo Hello World!
Pause

backb0neb00t3r

Learning cmd commands

ec
@echo

off

C:\Users\
@echo off

Pause command
a e

pause

Hello World!

a y

ey t

:D
a e

Goto command
Goto

goto

@echo off
echo hi
goto a
echo hey
backb0neb00t3r

Learning cmd commands

echo hello
:a
echo Hello World
pause
echo hi

goto a

a
:a

Rem command
rem

comment(

@echo off
echo hi
rem echo hi
echo hey
echo hello
pause

backb0neb00t3r

Learning cmd commands

Hi

rem
e

Call command
Call
word

batch file

ca

notepad
name.txt

Batc

@echo off
echo hi
pause
call name.txt

name.txt
call
(

D:
@echo off
echo hi
call D:\name.txt
pause

backb0neb00t3r

Learning cmd commands

CMD( command prompt)


Batch command

:D

Cmd

windows key + R
cmd

run box
cmd

:D

File management

D:\name.txt

note

Cmd
copy D:\name.txt D:\note
1

file(s)

copied

note

Copy
cut
move

Paste
cut-

paste

D:\note\name.txt

..

move D:\note\name.txt C:\


backb0neb00t3r

Learning cmd commands

1 file(s) moved
e a e
C:\name.txt

rename.txt

ren C:\name.txt rename.txt


1 file(s) copied , 1 file(s) moved
batch file

e t

rem
move

rename.txt

name.txt

move C:\rename.txt C:\name.txt


1

file(s)

moved

Na e txt
copy C:\name.txt C:\koko.txt
Koko.txt
name.txt
koko.txt
del C:\koko.txt

backb0neb00t3r

Learning cmd commands

1 file(s) copied

Changing path

e a e

username
Users

username
D:

D:
D:

D:
dir

<DIR>
< IR>
(

)
love

cd love

D:\love>
D:\love
dir
backb0neb00t3r

Learning cmd commands

cd ..
cd
cd ..
x
linux
:D
D:\general\ebook\tutorials\

cd D:\general\ebook\tutorials\

dir

backb0neb00t3r

Learning cmd commands

10

dir /p
C:\Windows\System32
/p

Creating folder
cmd
D:

te

mkdir booter
booter
dir
mkdir

linux

( matrix folders )

Matrix folders
Notepad

.bat

@echo off
backb0neb00t3r

Learning cmd commands

11

:a
mkdir %random%
goto a
pause

:D

%a
backb0neb00t3r

%
Learning cmd commands

12

random name
mkdir

%random%

random

name

Cmd colour
cmd

color 9A
cmd

BLACK

GRAY

BLUE

LIGHT BLUE

GREEN

LIGHT GREEN

AQUA

LIGHT AQUA

RED

LIGHT RED

PURPLE

LIGHT PURPLE

YELLOW

LIGHT YELLOW

WHITE

LIGHT WHITE
color

backb0neb00t3r

Learning cmd commands

13

color 01
color
cmd
cmd

right click

properties
:D

Title
Cmd

C:\W

booter
title booter
booter

Clear screen
cmd
cls

Prompt design
Prompt
C:\Users\username>
Prompt

prompt
love

Prompt

D:\love>

backb0neb00t3r

prompt

Learning cmd commands

14

booter>

prompt booter $g
<
<
b

prompt booter $l

$
t

te
$g

$A & (Ampersand)
$B | (pipe)
$C ( (Left parenthesis)
$D Current date
$E Escape code (ASCII code 27)
$F ) (Right parenthesis)
$G > (greater-than sign)
$H Backspace (erases previous cha
$L < (less-than sign)
$N Current drive
$P Current drive and path
$Q = (equal sign)
$S (space)
$T Current time
$V Windows XP version number
$_ Carriage return and linefeed
$$ $ (dollar sign)

backb0neb00t3r

Learning cmd commands

15

Previous commands

(up arrow)

Date and Time


ate
ate
the

new

enter

date
enter the new date

date /t

time /t

time

backb0neb00t3r

Learning cmd commands

16

Autocomplete
date
date
date
a t
2.21.2014
echo 2.21.2014 | date

shift
ec
c
T

Message
w

msg * This is message!


cmd

batch

Shutdwon, restart, logoff


Cmd

batch file

shutdown, restart, logoff


.

backb0neb00t3r

Learning cmd commands

17

shutdown /s

shutdown /a

shutdown /s /t 1800
/t

1800

/t 00
L
shutdown /l
L

backb0neb00t3r

e ta t

Learning cmd commands

18

shutdown /r
e ta t

batch file
cmd

Run commands
c

notepad

cmd

run

notepad program

notepad

run
registry editor

registry editor
c

cmd

Command prompt

notepad

Notepad

regedit

Registry editor

gpedit.msc

Group policy editor

msconfig

System configuration

services.msc

Windows services

control

Control panel

devmgmt.msc

Device manager

dfrg.msc

Disk Defragmenter

Cleanmgr

Disk cleanup

diskmgmt.msc

Disk management

mspaint

Paint

explorer

Windows explorer

calc

calculator

backb0neb00t3r

regedit

Learning cmd commands

19

run

Dealing with users

net users
User

accounts

for

\\computername

Administratr

Guest
built-in

net user booter password /add


The command completed successfully.
booter

password

net user
backb0neb00t3r

Learning cmd commands

20

/a
net users
(type)
administrator

t ta
standard

user
ett

A
standard

t ator account

user

administrator

net localgroup administratos booter /add


administrator

administrator

standard user
net localgroup administrators booter /delete
administrtors group
information
net user booter
booter

at
ex

( password
backb0neb00t3r

setting
Learning cmd commands

21

Local group memberships


e

standard

user

administrators
administrator

net user booter /delete


booter
booter
net user booter *

net user booter password


a w
:D

backb0neb00t3r

Learning cmd commands

22

Environment variables
Environment variables

operation

system
C:\Windows

environment variable

%systemroot%

cd %systemroot%
C:\Windows

e t a ab e

cd C:\Users\%username%
% e a e%
environment variable
e t a ab e
OS

%%

environment variables
e
e

e t

a ab e

e t a ab e

%username%

Username

%userprofile%

User path( C:\Users\%username% )

%computername%

Computer name

%RANDOM%

Generat a random number

%systemroot%

Windows directory

%time%

Display time

backb0neb00t3r

Learning cmd commands

23

%date%

Display date

%temp%

Temp foleder

System information
Cmd

y te

M t eb a ,

RAM, CPU, BIOS, Network card


systeminfo
system
manufacturer

motherboard

model

system

M t eb a

motherboard

driver

cd

driver

t eb a

Redirect output

y te

text file

systeminfo > C:\Users\%username%\Desktop\system.txt


e t

y te
system in

backb0neb00t3r

text file
at

Learning cmd commands

24

systeminfo

..
.

Exit

exit

Task
Taskmanager
ce
taskmanager

cmd

ce

tasklist
ce
image name, pid

ce

at

ce
process

pid

Pid

728
taskkill /pid 728
ce

backb0neb00t3r

Learning cmd commands

25

taskkill /pid 728 /pid 1040 /pid 1298


process

image

name
taskkill /im notepad.exe
te a exe

Process

Image name

Naming partition

label C: OS
C:

OS

D:

E:

Creating variables
a ab e

Variable

environment variables

variable
variable

set booter=male
variable

echo %booter%
ae

backb0neb00t3r

a ab e
Learning cmd commands

26

%%

booter

male

variable
Ma e
a ab e

set a=male
a
variable
variable

user

variable

@echo off
set /p pass= echo type your password:
cls
echo Your password is %pass%.
Pause
.bat

batch file
et /

pass

user

input

variable

echo type your password:


backb0neb00t3r

a =

....

type your password:


Learning cmd commands

27

Input
pass
password

is

password

variable

echo Your

%pass%
%pass%
c

variable

clear screen

set /p pass= echo type your password:

e t

set

echo

a ab e
a ab e

cmd
variable

variable

If statement
I

If

conditional statement

C:\Windows\System32\mgy.exe
If
@echo off
if exist C:\Windows\System32\mgy.exe (
del C:\Windows\System32\mgy.exe
echo MGY.exe was found.So, I deleted this.It's a virus.
) else (
echo MGY.exe was'nt found.It' OK! :D
backb0neb00t3r

Learning cmd commands

28

)
pause
If exist
del

C:\....\mgy.exe

C:\....\mgy.exe
echo

else

If statement
Mgy.exe
.. If

exi t

y exe

M y exe
e e

. :D
if exist

if note exist
If
If

@echo off
:start
echo Welcome to my program
set /p pass= echo Please tell me your dirth-year to use my program:
if %pass% leq 1995 (
goto old
) else (
goto young
)
backb0neb00t3r

Learning cmd commands

29

:young
echo You can't use my program
pause
cls
goto start
:old
cls
echo You can use my program.
pause
goto :program
:program
cls
echo We are the world
pause
echo We are the children
pause
echo Time to stop my program ! Have a nice day !
pause
exit

If

backb0neb00t3r

I % a % eq 1995

Learning cmd commands

30

1995

1995

Le

t a

eq a
equ

Equal

neq

Not equal

lss

Less than

leq

Less than or equal

gtr

Greater than

geq

Greater than or equal

File attributes
attributes

( attributes )
Hidden

attribute,

read-only attribute,
system file attribute,
attribute

archive
attrib
e , y te

att b

hidden

backb0neb00t3r

Learning cmd commands

31

e att b

\hehe.txt

att b
attrib D:\hehe.txt
A

D:\hehe.txt

A attrib
system

s read-only

ac

hidden

hidden

attrib +h D:\hehe.txt
e e txt

attrib +h hehe.txt

hidden

attrib +h +r +s D:\hehe.txt
hidden system read-only

backb0neb00t3r

Learning cmd commands

32

attrib h r s D:\hehe.txt
att b

Deleting files
Del
attrib

att b
e
h s r

del

del /a:hsr D:/hehe.txt


hehe.txt

hsr

hehe.txt
cmd

del /p D:\hehe.txt
Delete ( y / n ) ?
y

backb0neb00t3r

ye

\My folder\*

Learning cmd commands

33

my folder
/p

yes

yes no
/q

e /q

Quiet

\My folder\*
\My folder\*


My

folder

* /q /

e /q

\My folder\* txt


y

.txt
\My folder\*.exe

.exe
e /q

\My folder\b * *
bo

exe
folder\bo????.txt

backb0neb00t3r

txt
bo

bo

\My
txt

Learning cmd commands

34

del

\My

My
My

e
e

folder
/s

\My folde

/q

Viewing hidden file


dir

hidden
e

/a

backb0neb00t3r

\My

Learning cmd commands

35

Suggestion
cmd

batch file

del /?
e
system

learning

learn

Written by backb0neb00t3r(MHU)

Greetz to all MHUs

backb0neb00t3r

Learning cmd commands

Das könnte Ihnen auch gefallen