Python WiFi DoS (Denial of Service) attack

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- In this video, I'm going to show you a simple Python script that runs a denial service attack or DoS attack against a WiFi network. So once you run this Python script that I've written and linked below, which you can find on my GitHub page it will basically destroy a WiFi network. Now, before we get started, only use the script on networks that you personally own, or have permission to attack. Please don't use this Python script that I'm gonna demonstrate in this video in a coffee shop, please don't use it on your parents or on a network that you don't have authorization to run the Python script against. So again, don't use this on your neighbor if they playing loud music, as an example, such as other people have done on YouTube. In this example, I'm attacking this a WiFi router. So the network that I'm gonna attack is this little TP Link WiFi router. In this example, I've got a Windows computer that's gonna be the client that we're gonna knock off the network. And then I'm running Kali or Kali Linux if you prefer within a virtual machine on my Mac. Now for this attack to work, you need a WiFi adapter such as this. This is an Alfa network adapter. It supports both monitor and injection mode. So you don't have to use an external WiFi adapter like this but you need one that supports injection and monitor mode if you really wanna attack a WiFi networks, this Alpha network adapter works really well. The disadvantage of this one is it only supports 2.4 gigahertz WiFi not five gigahertz. So you could buy a more expensive adapter that supports both 2.4 and five but this is a great WiFi adapted to start with because Kali Linux automatically picks it up. (upbeat music) Okay, so let me demonstrate the script and then I'll go through the script in more detail so that you can see how the script works. It's really well worth your time learning Python because it gives you a lot of options, fantastic programming language. So on my Windows computer, I'll open up a Command Prompt, and what I'll do here is ping Google with -T so that the pink doesn't time out. So you can see the ping is continuing to run. And what I can do as an example is go to a website such as Facebook so I'm able to connect to the internet. Okay, so my ping is continuing but what I'll do on Kali is open up a terminal. I'll make this slightly bigger. Okay, so iwconfig shows me that I have a WiFi network connected. I'll disconnect this WiFi adapter from my Mac and then I'll plug it back in again. I'm asked, do I wanna connect this to my Mac or to Linux? I'm going to connect it to Linux. And once again you can see that my WiFi adapter is connected, it's currently in managed mode. Now, if you're not sure how to do that, have a look at this video where I'll show you how to install Kali on a Windows computer as an example. I also showed you in this video, how to manually do what I'm demonstrating here but just to make it more interesting, I've created a Python script that speeds things up and makes it a lot simpler. So on Kali, I'm gonna create a file called wifidos.py. Nano is a basic text editor, you could use Vi if you prefer. But I'm basically creating a file called wifidos.py. This is my Python script which is pre-written. So I've created this Python script, and I've also put a lot of comments in the Python script so that you can see exactly what's happening. So unlike some other examples that are found online which are really complicated and don't have a lot of comments, I've put a lot of comments in this code. I'm really hoping that it makes it easier for you to learn Python and explains what this code is doing. So what I'll do at this point is simply copy that code, and I'll paste it into nano on Kali. Press Control X to exit press Y to save, script is saved. So LS shows me that I've got my wifidos.py script. So if I run Python, and in this case I'll run Python3 and run that script. Now, in this example, Kali is remembering previous commands that I've typed. So I've simply use the right arrow key to complete the command. You'll probably have to manually type the command out. But Python3, wifidosdot.py, you can see here that an error display is telling me that I need to run this as pseudo. So pseudo basically allows me to run the script with root privileges. So pseudo Python3 wifidos.py, have to put my password in, so I'll put in my password of Kali, and it's now picked up the WiFi adaptor to use. Now, if I didn't have that WiFi adapter connected, the script would tell me that I need to connect it. So in the script, I've added options such as if you're not running the script as pseudo, the script will break. If no wifi, adapters connected, we're told to connect to the WiFi adapter. So I've tried to add various problems that you may encounter to the script to make sure that it runs successfully. In this example, I've only got one WiFi adapter. So I'm gonna use zero to select that WiFi adapter. The script destroys any processes that could conflict with putting this adapter into monitor mode. You need an adapter once again, that supports monitor mode like this Alpha adapter. So it kills any conflicting processes and then it puts the adapter into monitor mode and then it discovers the WiFi networks around. This is the WiFi network that I want to attack. On my Windows computer, you can see that that's the network that the Windows computer is connected to. So I wanna attack that WiFi network, so I'm gonna press Control C and then use zero to select this WiFi network and press Enter. What's happening now is deauthentication messages are being sent to the WiFi adapter which will stop this device from connecting to the internet. So you can see that pings are starting to time out. And if I open up another tab on my web browser and try and go to facebook.com, you'll notice that there's a problem with a network. If I go to another website, let's say google.com, the device is not able to connect to the internet because I'm basically deauthenticating all clients on this network. So, as an example, if I try and play some music here from a website, nothing happens. The music can't play because I'm breaking this network. If I press Control C on my script to stop a deauthentications, ping start working, and back on my PC, I should hopefully be able to connect to various websites, so I can connect to Facebook, I can connect to Google, I can connect to LinkedIn. And let's try different music file, the music starts playing. So if I run that script again, select my WiFi adapter, select my WiFi network that I wanna attack, start attacking the network. What you'll notice here on the pings is that they'll start to time out. So the pings timeout while de-authentication messages are being sent to the WiFi network. Now it is recommended that you attack a single client rather than just sending Dos messages to everyone on the WiFi network. And I'll cover that in a separate video. So I'll show you how to adapt the script so that you can select an individual client and just attack that. So, as an example, well you may just wanna attack an iPhone or you may wanna just attack a music system, so you can attack a specific device on a WiFi network. Now what's amazing about this is you don't have to know the password of the WiFi network that you're attacking, you can attack any WiFi network as long as you're within the vicinity, in other words, you are seeing the WiFi network, you can attack it. Now again, you don't have to be connected to the WiFi network to run the denial of service attack against that WiFi network, you simply have to be in the vicinity. You have to basically be able to see the WiFi network in the air. So your WiFi adapter has to be able to pick up that that WiFi network is there. So again, if I run that script, these are the WiFi networks that I'm currently seeing around me. So my WiFi adapter can pick up these WiFi networks. So if you're too far away from the WiFi network, you wouldn't be able to run the attack, but as long as you're within the vicinity and can see it in the air, then you'll be able to attack it, you don't need to know the password of the WiFi network. Now I'm hoping you enjoying these types of videos. I'm hoping you enjoying these kinds of scripts. Python is a really powerful language. If you learn Python, you can do a lot of things, including stuff like this. Now, with that being said if you enjoyed this video, please like it, please consider subscribing to my YouTube channel and clicking on the bell to get notifications. I'm hoping to reach a million subs in this year, so please help me do that. Now, please note, when I break the script by using control C as an example, we get trace back messages. I've created two versions of the script. In the script, you can actually see the output of the commands that you're running. So we can see the DoS messages going to the access point. In a separate script, I'm using a sub-process. So I'm pushing that to a sub-process so you don't see that output, but what it does allow me to do is to use a Control break or control C on the Python script and do some clear up after the script is run. This first script doesn't do that, but I've put both scripts below this video, so you have two different versions of the Python script. The first script I think is the simplest to use, but if you wanna take it a little bit further, you can have a look at the second script as well. I'm gonna show you what the Python script does, but again, I've put a lot of comments in the Python script so that I don't have to make this video extremely long to explain every single line of code. Have a look at the Python script, which you can once again download using my GitHub link below. But as always, only use this kind of code for ethical hacking purposes, only attack a network that you own or have permission to attack. We're importing a whole bunch of modules here including sub-process or regular expressions, CSV, and others, what are we gonna do is create an empty list of WiFi networks, and then we going to do a test to see if a SSID is already in the list. So we are checking if an SSID already exists. If it doesn't exist in our list, we're going to add it. I've got a basic user interface, you could delete all of this if you don't want it. We are checking to see that the user's using pseudo privileges, if not, we tell the user to run the program with pseudo. We remove any CSV files before we run our script. We are breaking the script at the end so we can clear up the CSV files. You could do that using the second script that I've created and put below. But in this first script, it's kind of like a heartbreak of the script, so the CSV file remains there. So before we run the script, again, we do a clear up of any CSV files. So we basically make a backup directory. If it already exists, we simply move the files to that directory, but if it doesn't exist, we create it and then move the files to that subdirectory. Then we check for the WiFi interfaces. In our example, we assuming that the WiFi interfaces will be wlan zero or wlan one or wlan two, et cetera. And then we're going to use a sub-process. So we running an additional process to check the WiFi interfaces using iwiconfig. If a network adapter is not fond we tell the user to plug a network adapter in, but if it is found, then we ask them to select the relevant WiFi network interface. You could have multiple WiFi interfaces connected to Kali, so we ask the user to select one. We making sure that they select one that actually exists, then we store that in a variable for easy reference. We tell the user that we're gonna kill any conflicting processes. You need to do this when running the commands. In this video I showed you how to manually run all these commands. So if you wanna see it step by step, then have a look at this video. But here we basically taking that knowledge and putting it into a script which makes it much easier rather than manually doing things over and over again. It's much better just to automate it to using a script like this. So we kill the processes, we put the WiFi network adept into monitor mode, we use popen to check for WiFi networks. So we basically using airodump-ng, and we're gonna check the WiFi networks running around us, that basically gives us this output here so we can see the various WiFi networks. So this is actually showing us the output. We clear the screen before printing the interfaces and then we display all that information. So we can see our SSID information. We create a nice, pretty menu showing all that information. So basically with airodump-ng, it puts the output to a CSV file, and then reading that CSV file, and then displaying it to the user. So this information is actually being displayed from a CSV file. Airmon-ng writes the information to CSV file and then we display it here. So every second that's updated, when the user presses Control C, we tell them to make a choice. So if I press Control C here, I need to make a choice, and the network that I wanna attack is this one. So I'm going to select 14. If I did select some random number like 45, we would be told to do that again. So I select 14, and now the deauths are sent to the WiFi network. So we ensure that it's a valid choice, if it's not, we ask them to try again. We make it easier to read the code by specifying the hack B SSID and the hack channel. We run this command to specify the channel that we're gonna hack on. So that was picked up previously when we saw the output of the WiFi networks, we could determine the WiFi channel. So we run airmon-ng to specify the channel, and then we run aireplay-ng with the deauth command. And this is unlimited deauth to just de-authenticte any clients on the network, and that's what you can see here on the Windows computer, it's being deified indicated from the WiFi network. And then the user needs to press Control C to break the script. So once again, if I press Control C there, keyboard interrupt, script ends. Now, LS shows us that we've got the CSV file. So when we run the script again, that's gonna be moved to the backup directory so that the script can run without additional CSV files interfering with what we're trying to read. Okay so that's the one script, the other script is very, very similar. The differences at the end. At the end of the script, we're gonna use popen to a D authentic Kate clients. And now, because we doing that, we can still control the script. So we can print out that clients have being deauthenticated. Press Control C to stop. And then when you press Control C, we tell the user that we stopping monitoring mode. So we stop monitoring mode on the WiFi adapter, and we exit the script. Now you should actually which I'll add here is start the network services again. But the script allows you to do a proper cleanup, you could if you like reboot your virtual machine or your Kali Linux installation. if you don't wanna do that, we'll just type the commands manually to start these services. So, as an example, using the first script, the one that I've demonstrated, iwiconfig shows me that the adapter is in monitor mode, so I wanna use this command airmon-ng stop wlan zero mon, and I need to do that as route to now put the WiFi adapter into managed mode. I couldn't do that with the first script once again because I press control C to break it and then the script ended. But in the second script, I did that. And what you can do as well is start network manager. Okay, so there you go. Hopefully you've enjoyed this video. If you did, please consider subscribing to my YouTube channel, please like this video and click on the bell to get notifications. I'm hoping to reach a million subs this year, so please help me do that. I'm David Bombal, wanna wish you all the very best. (upbeat music)
Info
Channel: David Bombal
Views: 113,443
Rating: 4.964252 out of 5
Keywords: wifi dos, wifi doser, wifi, python, scanner, wifi scanner, python scan, hacking, hackers, ethical hacker, ethical hacking, hacker, hacking course, hacking tutorial, black hat hacking, learn hacking, ethical hacking tutorial, ceh, kali linux, oscp certification, elearnsecurity, ine, ctf, how to hack, learn ethical hacking, cyber security course, windows 10 python, python wifi, wifi password, wifi tips, python tutorial, python 3, learn python, denial of service, ddos attack, dos
Id: iGXB5NanUK4
Channel Id: undefined
Length: 17min 42sec (1062 seconds)
Published: Thu Mar 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.