Learning Cmd Commands

36

description

Subject: Command Line Interface

Transcript of Learning Cmd Commands

Page 1: Learning Cmd Commands
Page 2: Learning Cmd Commands

1

backb0neb00t3r Learning cmd commands

Read me

batch file batc file Programming batch batch hacker ac t t a C++ python Web Web ac e php t t a theory :D What is Batch file? Batch file c c a C:\a.txt C:\folder\green.jpg D:\ cmd Copy C:\a.txt D: copy

Page 3: Learning Cmd Commands

2

backb0neb00t3r Learning cmd commands

C:\folder\green.jpg D: batc e temp recent ဏ ဏ batc e ဏ ဏ batc e a c ce t windows system c :D Batch file ၇ ec , a e, e , t , ca , if, for c batc cmd if For :D Echo command c Hello World! Notepad program.bat Hello world!

@echo off echo Hello World! Pause

Page 4: Learning Cmd Commands

3

backb0neb00t3r Learning cmd commands

ec @echo off C:\Users\ @echo off Pause command a e pause Hello World! e a y ey t c t e :D a e ဏ Goto command Goto goto

@echo off echo hi goto a echo hey

Page 5: Learning Cmd Commands

4

backb0neb00t3r Learning cmd commands

echo hello :a echo Hello World pause

echo hi goto a a a a :a a Rem command rem comment( e

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

Page 6: Learning Cmd Commands

5

backb0neb00t3r Learning cmd commands

Hi rem e Call command Call word batch file ca notepad name.txt Batc e

@echo off echo hi pause call name.txt

name.txt call ( ) D:

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

Page 7: Learning Cmd Commands

6

backb0neb00t3r Learning cmd commands

CMD( command prompt) Batch command :D

c c a Cmd windows key + R run box cmd cmd :D File management D:\name.txt note Cmd copy D:\name.txt D:\note 1 file(s) copied note Copy cut Paste move cut-paste D:\note\name.txt .. move D:\note\name.txt C:\

Page 8: Learning Cmd Commands

7

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 c 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

Page 9: Learning Cmd Commands

8

backb0neb00t3r Learning cmd commands

1 file(s) copied e Changing path e e a e username Users username D: D: D: D: dir <DIR> < IR> ( ) love cd love D:\love> D:\love dir

Page 10: Learning Cmd Commands

9

backb0neb00t3r Learning cmd commands

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

Page 11: Learning Cmd Commands

10

backb0neb00t3r Learning cmd commands

dir /p C:\Windows\System32 /p Creating folder cmd D: b te mkdir booter booter dir mkdir linux ၂ ၄၈ ( matrix folders ) Matrix folders Notepad ၇ .bat

@echo off

Page 12: Learning Cmd Commands

11

backb0neb00t3r Learning cmd commands

:a mkdir %random% goto a pause

:D

% a %

Page 13: Learning Cmd Commands

12

backb0neb00t3r Learning cmd commands

random name mkdir %random% random name Cmd colour cmd color 9A cmd 0 BLACK 8 GRAY 1 BLUE 9 LIGHT BLUE 2 GREEN A LIGHT GREEN 3 AQUA B LIGHT AQUA 4 RED C LIGHT RED 5 PURPLE D LIGHT PURPLE 6 YELLOW E LIGHT YELLOW 7 WHITE F LIGHT WHITE color

Page 14: Learning Cmd Commands

13

backb0neb00t3r Learning cmd commands

color 01 color cmd cmd right click properties :D Title Cmd C:\W w booter title booter booter Clear screen cmd cls Prompt design Prompt C:\Users\username> Prompt prompt love Prompt D:\love> prompt

Page 15: Learning Cmd Commands

14

backb0neb00t3r Learning cmd commands

t booter> prompt booter $g < $ < prompt booter $l t b 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)

Page 16: Learning Cmd Commands

15

backb0neb00t3r Learning cmd commands

Previous commands (up arrow) Date and Time ate ate enter the new date enter the new date date /t time /t time

Page 17: Learning Cmd Commands

16

backb0neb00t3r Learning cmd commands

Autocomplete date date date a t 2.21.2014 echo 2.21.2014 | date shift ec c | T e Message w w msg * This is message! cmd batch Shutdwon, restart, logoff Cmd batch file shutdown, restart, logoff .

Page 18: Learning Cmd Commands

17

backb0neb00t3r Learning cmd commands

shutdown /s shutdown /a shutdown /s /t 1800 /t 1800 ၁၈ /t 00 L shutdown /l L e ta t

Page 19: Learning Cmd Commands

18

backb0neb00t3r Learning cmd commands

shutdown /r e ta t batch file cmd Run commands c a cmd run notepad notepad program notepad run regedit registry editor registry editor c a 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

Page 20: Learning Cmd Commands

19

backb0neb00t3r Learning cmd commands

run c a 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

Page 21: Learning Cmd Commands

20

backb0neb00t3r Learning cmd commands

/a net users (type) t ta a e administrator standard user ett A t ator account standard user administrator net localgroup administratos booter /add administrator administrator standard user net localgroup administrators booter /delete administrtors group information net user booter booter I at ex e ( password setting

Page 22: Learning Cmd Commands

21

backb0neb00t3r Learning cmd commands

Local group memberships e standard user administrators administrator net user booter /delete booter booter net user booter * net user booter password a w :D

Page 23: Learning Cmd Commands

22

backb0neb00t3r Learning cmd commands

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 L e e t a ab e 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

Page 24: Learning Cmd Commands

23

backb0neb00t3r Learning cmd commands

%date% Display date %temp% Temp foleder System information Cmd y te M t e b a , RAM, CPU, BIOS, Network card systeminfo system manufacturer motherboard ဏ system model M t e b a motherboard driver cd driver t e b a Redirect output y te text file systeminfo > C:\Users\%username%\Desktop\system.txt e t y te text file system in at

Page 25: Learning Cmd Commands

24

backb0neb00t3r Learning cmd commands

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

Page 26: Learning Cmd Commands

25

backb0neb00t3r Learning cmd commands

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% a e a ab e

Page 27: Learning Cmd Commands

26

backb0neb00t3r Learning cmd commands

%% booter male variable Ma e a ab e set a=male a variable variable ဏ user I t variable

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

.bat batch file .... et / a = user input pass variable echo type your password: type your password:

Page 28: Learning Cmd Commands

27

backb0neb00t3r Learning cmd commands

Input password pass variable echo Your password is %pass% %pass% variable c clear screen set /p pass= echo type your password: set echo e e t 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

Page 29: Learning Cmd Commands

28

backb0neb00t3r Learning cmd commands

) pause

If exist C:\....\mgy.exe del C:\....\mgy.exe echo else If statement Mgy.exe .. If exi t y exe e c 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 )

Page 30: Learning Cmd Commands

29

backb0neb00t3r Learning cmd commands

: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 I % a % eq 1995

Page 31: Learning Cmd Commands

30

backb0neb00t3r Learning cmd commands

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, archive attribute attrib e , y te att b hidden e

Page 32: Learning Cmd Commands

31

backb0neb00t3r Learning cmd commands

e att b \hehe.txt att b attrib D:\hehe.txt A D:\hehe.txt A A attrib a c e hidden h system s read-only r 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 .

Page 33: Learning Cmd Commands

32

backb0neb00t3r Learning cmd commands

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 ye . e “ \My folder\*”

Page 34: Learning Cmd Commands

33

backb0neb00t3r Learning cmd commands

my folder /p yes * * * yes no /q Quiet e /q “ \My folder\*” \My folder\* “ “ My folder “” “” * /q / * e /q “ \My folder\* txt” y e .txt \My folder\*.exe .exe e /q “ \My folder\b * *” bo txt exe bo \My folder\bo????.txt bo txt

Page 35: Learning Cmd Commands

34

backb0neb00t3r Learning cmd commands

del “ \My e ” My e My e folder /s / “ \My folde ” /q Viewing hidden file dir hidden e /a “ \My e ”

Page 36: Learning Cmd Commands

35

backb0neb00t3r Learning cmd commands

Suggestion cmd batch file del /? e system learning learn Written by backb0neb00t3r(MHU)

Greetz to all MHUs