Ethical Hacking – Batch Programming
Hello everyone in this video we’ll talk about a unique kind of programming language which is used in Windows in order to automate a day-to-day tasks and that programming language is called as best programming language and this best programming language is also used by hackers and trackers in order to create some malicious files and with the help of that files the hackers and the crackers can do some malicious activities on a particular system so this batch programming language is also used by developers in order to automate some day-to-day tasks but before going further let’s talk about that what’s what is the execution environment of this batch programs or is there any special software we need in order to create these files so the execution environment of batch file is very simple we need nothing all we just need is we need a text editor we can even use notepad and a notepad plus plus and that’s it so what we have to do is so any command which can be run on a command prompt can be used in batch files or a batch programming language so here you can see that any command which can be run on a command prompt can be used in our batch files so these commands can be written in batch files so which means our batch file or our batch program will actually run on a command prompt so that’s why we need nothing just the notepad in order to create our batch file now let’s talk about some sample programs which we will make in this video so these programs include lock your system so the help of some programs we can even lock a particular system so what we can do is we can make one batch file and we can send that file to anyone and if any one just open that file then its computer just get locked so what else we can do is we can also open multiple pages in browser and even we can create a malicious batch files which may result in firewall disabled and we can even create a backdoor for Windows and the process killer so with the help of some batch programming files tools we can even some extract data from the system so that’s why the batch programming is used is the most popular feature and windows now let’s see how we can make some batch files in order to automate day-to-day tasks and let’s create some malicious file with the help of batch programming language now let’s make some batch files in order to understand that how batch programming works well in order to make batch files and test them I will use Windows 7 operating system in my VirtualBox so that my main parent operating system will not be affected by that batch files so I recommend you to please use Windows 7 in VirtualBox in order to test the batch files which we will make in this course so as I told you earlier that in CMD that any command which can be run inside this command prompt can be used inside the batch files or in in other words any command that is supported by this command prompt can be used inside our batch files so just for example if we write here ping google.com you can see here that the ping command is supported and if we want to see the directory listing just right here dir and it will list out all the directories and if you want to check that Who am I that whether we are root or administrator here you can see here so which means any command which we can type here and if that command runs we can use that command inside our batch files so we don’t need any kind of special text editor in order to make batch file and we also don’t need any kind of execution environment in order to run that batch files all we just need is one notepad so you can use any text editor so I am using notepad here and the next thing we need is command prompt so first of all before starting the batch files let me give you a short introduction of the commands which we can use inside the command prompt so let me close this up and let’s start the command prompt as administrator so whenever you start the command prompt as an administrator so you will notice here that we are inside the system32 directory so this is our current path that where we are right in so if we want to find and list out the files and directories which are present inside this directory system32 you just have to write dir hit enter and it will list out all the files which are present inside this directory then if we want to change the directory just for example if I scroll up you will find here there are old files but just for example you want to come back one directory so you want to go here Windows so just right here CD CD for change directory and two dots so if you hit enter you will see that we are came out one directory back and right now we are here in local disk C Windows and let’s go back again so now you can see that we are in local disk C directory so let’s list out the files which are present inside this so you can see here there is one directory called as Windows users and if we want to change your directory and you want to go here to the users just right here CD users hit enter and you can see that right now we are inside users directory the main thing to be noticed is that in command prompt it’s not mandatory that you write all the command in small letters and even in capital letters you can see here that if I write here dir then it will also work and if we write here in dir in small letters then that will also work so the same thing we can apply while making our batch files now let’s make a simple batch file but before going there let me give you an introduction of echo command so if you are familiar with this command echo so this command is also used in Linux in order to print something so if I write here echo hello and hit enter so here you will see that the hello is printed right after this command and you can see here here is our output now let’s do one thing let’s first of all let’s create a simple batch file which will print out hello for us so whenever we are going to make a new batch file we always have to write at the rate echo off so why we are writing this as the ratico of i’ll explain you a little bit later so hit enter and then here we have to specify a command which we want to execute when this file will run so just right here Eko I am new file hit enter and in the last we have to write here pause so I am writing here pause I will explain you when I will explain this concept at the reticle off so let’s save this file you can save this file on desktop and anywhere else so write down the name demo and we always have to save the batch files with dot dat extension that is dot bat so once I save this file you can see that this file is created on my desktop and all the batch files are looked like this this is the icon of the batch files and if I go to its properties it will say that it’s a Windows batch files and if I open this file you can see here that it has printed I am a new file and as asking us to press any key to continue and if I press any key it just terminated so now let’s go back here to our source code now this thing is clear to you that the echo command is used to print out something and now what is the use of this at the rate echo off so just for example let me remove this line let me save this file again and let me run this again so that you can understand the difference between the echo and at the ratico of so now you can see here that if we not use at the rate echo off then what happen is this command prompt will execute this line first then once it executes this line or the first command then it executes the second command after the previous one and you can see here so you can see here that at the first this command prompt has executed echo I am a new file and here you can see its output and then later on it has executed this pause and you can see here that there is a positive and it’s saying press any key to continue and the main other disadvantage of not using at the rate Eco office that if we don’t use at the rate eco off then the code which we will write in our batch file will also be printed on the command prompt you can see here that here is our code echo I am a new file and the same code is printed on the command prompt so that’s why it’s mandatory to write at the rate echo off in order to hide our code and if I just run this file again you will see a clean neat output so let’s remove this pause and run it again and you will see that whenever I double click on it a command prompt will come and suddenly disappears you can see here so that’s why we use pause in order to hold our command prompt and you can see here now here is our command prompt so this is the basic usage that how we can create a batch file and how are the batch file works now let’s make some batch files in order to see that what else we can do so first of all we will see that how we can make a folder bomb so we can say the batch files are viruses so we can just say that the batch files are actually the files which are used in order to execute a particular command on a particular system so the folder bomb is actually just a batch file which will make a random folders in in a target machine so how to make a folder first of all let me just open my command prompt ok so let me let’s list out everything so you can see here the list of folder now in command prompt if we want to make a folder then what you have to do is so just right here MD that is for make directory or a make folder followed by the folder name which you want to create so just right here demo hit enter and if you just write here dir you will see that a new directory named as demo is created now what we will do is in our batch file we will make a code which will make a thousands of folder in our target machine let’s go back here to a notepad file let’s create a separate one so I will start with eco off then here I will start one loop which will iterate and go still infinity so in order to start loop and batch programming we have to write here : then ax so you can write here anything like X Y B there just a variable then here we have to write down a command which we want to execute so you want to execute MD then here I will write here random inside the percentage so what is the meaning of this so as I told you earlier that in order to make folder or a directory we have to write here MD followed by the directory name which we want to create like first so now we want to create a directory or thousands of time but we don’t want to wrap specify any particular name so that’s why I have written here random so it will start from any random number so that is MD percent I random and in the last we will write here and go to and X so here you can see that we have specified a particular loop that just started from here then execute this line until how till how long you have to execute this code I have written here go to X means we haven’t specified any particular point that after 10 times you will terminate after 15 times you will terminate just execute this command in infinity so let me just save this file and let me say every return or desktop and name it as a folder bomb dot bat and here you will see that a file folder bomb is created now let’s make a new folder and put it inside okay so here you can see that the file is here and let’s just double click on this file and you will see here a subdirectory or a file already exists and if you look at here at the background you will see here that to start making folders you can see a long list of folders so in order to stop this file and in order to stop the folders we have to just close this file and you can see here that within the seconds this file has created 14,000 to sixty-six folders so this is the beauty of batch files now let’s just try to make a file which will add a random user accounts in any of operating system so let’s go here so in Windows if you are not familiar with that how we can check the accounts in command prompt then there is one command called as net user which we can use in order to check that how many accounts are associated with this Windows operating system so if I hit enter here you will see that right now there are three accounts the first one is administrator then there is a guest then there is a root so we can also verify here that right now we are logged in as a root so in order to add a particular user inside the Windows operating system the first thing we have to do is we have to open a command prompt with the administrator privileges and then here we have to write here net user the net user followed by the username we want to add so just for example you want to create a new user so let it be demo one and then we have to write here /ad so if I hit enter here you will see that the command completed successfully now let’s verify that whether this user is created or not and you will see here that a user named as demo 1 is created so we can just verify it from here so manage other account and here you will see that the user named as demo – created now let’s do one thing let’s create one batch file which will add an thousands of users in a Windows 7 operating system so what you can do is you can send these files to your friends in USB drives from via through email and if someone just open this file and that person will just get affected so let’s create a new notepad file okay so the same thing I will write here at the rate echo off then I will add here in an infinite loop and I will write here command net user then here the same thing I will do I will write here random because we don’t want to specify a user name then add and in the last I will write here go to tell X we haven’t specified a particular position so that’s why I am writing here go to X to make it as an infinite infinite loop so let me save this file so user add dot b8e let’s just save this file and you can see here that the file is created so if you remember then I told you that in order to create user by command prompt we have to open a command prompt with an administrator privileges so just for example if I just run this script without administrative privileges let’s see what happened so you can see that it’s giving us an error that access is denied but if I just run this script as an administrator what we will see the command completed successfully so let’s just stop this file and let’s go here click on manage account and you will see here that this file has created lots of users in this operating system so I it’s not letting me to close this but no worries so what we can do is we can even verify by writing here net user and you can see the user names now let’s have a look at one more batch file that is called as folk bump so in operating system there is one call called as for call so the so the what fork to it actually create a lot of processes in our system which eventually makes our system to crash now let’s write here at the rate echo off and you will just get a Miss that in order to crash any system all we just need is the five digits code or the five letters the first one is percentile then 0 then again percentile then again 0 and if I save this file and let’s just rename it as a fork dot bat click on save and here is that file you can see so if I just open this file wait for five seconds and here you will see that my system is stuck now I can’t do anything if I want to close this file it will not letting me to close this you can see here the system is out of environment space because it has created lot of processes at the background you can see here that I can do anything so the only thing I can do is just reboot the system so let’s just reboot the system and let’s start it again so this is the beauty of batch programming then we can do lot of things if we know properly that how we can create a batch files and here you can see that they have lot of users but here is mine so now let’s create a batch file which will turn off the firewall when the user opened that batch file by administrative privileges but before going there let’s see that how we can turn off firewalls by using command prompt so there is one command called as net SH firewall set up mode that is operation mode and we want to disable it and if I hit enter you will see that the requested operation requires elevation which means this command is not successfully executed because we are not an administrator so that’s why we have to run this command in command prompt by with administrator privileges now let’s write here firewall set up mode and disabled and if I hit enter here you will see that the command executed successfully here it’s the success message okay now let’s just verify this let’s go here to control panel security Windows Firewall and here you will see that the Windows Firewall is off you can see the status Windows Firewall status now in order to enable this firewall just right here enable and you will see that the firewall is enabled now you can see its status now let’s add this functionality in our batch file so let me save this file on my desktop and here is that fine let me just run it as an administrator and let’s just go back to our control panel system and security Windows Firewall and here you will see that now firewall has turned off so this is how we can use bad programming in order to automate a today task and even we can create some malicious script which can infect a particular system so in this video we have discussed that vertex based programming and how to make some simple batch files in order to see that how much programming works so thanks for watching this video
We acknowledge that this video belongs to the author and thank them for it’s use.
Copyright Disclaimer under section 107 of the Copyright Act of 1976, allowance is made for “fair use” for purposes such as criticism, comment, news reporting, teaching, scholarship, education and research. Fair use is a use permitted by copyright statute that might otherwise be infringing..
As found on Youtube