1 00:00:00,000 --> 00:00:04,360 Welcome to the Wireless Village. I have the pleasure of, for the second time this weekend, 2 00:00:04,420 --> 00:00:08,340 introducing my good friend who will remain nameless because for those of you who haven't 3 00:00:08,340 --> 00:00:12,360 had a chance to see him yet, I want you all to get a fine picture in your head of what a 4 00:00:12,360 --> 00:00:16,520 wonderful man this is. This man's been, well, we worked together for quite a while and that 5 00:00:16,520 --> 00:00:21,460 was a lot of fun and then he left me to start his own project and nobody had actually seen him for 6 00:00:21,460 --> 00:00:25,340 a while and when I say nobody had seen him for a while, I mean for some reason you just never saw 7 00:00:25,340 --> 00:00:31,040 him but what you did get was his wonderful voice. So without further ado, I'd like to have you all 8 00:00:31,040 --> 00:00:36,640 close your eyes so you don't get confused. I'd like to hear his famous catchphrase that he has 9 00:00:36,640 --> 00:00:41,760 at all the beginnings of his videos. Hello all, welcome to securitytube.net. 10 00:00:44,680 --> 00:00:47,640 And how do you miss that? Give this man a big hand. Thanks for coming. 11 00:00:51,320 --> 00:00:53,000 Thanks for that great introduction, Rick. 12 00:00:56,320 --> 00:01:02,960 Okay, so in this session, we're going to be looking at how to script your own Wi-Fi attack tools 13 00:01:02,960 --> 00:01:10,500 with Python. How many of you have scripted your own tools in any language? Wireless, okay. 14 00:01:10,940 --> 00:01:21,240 Python? Ruby? Perl? A couple? Okay. All the Perl guys are hesitating to raise their hands. 15 00:01:25,340 --> 00:01:29,040 So I've been doing a lot of wireless security for probably the last 15 years 16 00:01:30,500 --> 00:01:37,840 and being able to script quick proof of concepts always comes in handy. Now, when you look at 17 00:01:37,840 --> 00:01:44,200 wireless scripting, there are really two ways by which you can get packets from the network. 18 00:01:44,980 --> 00:01:52,320 One is using raw sockets, which is probably the absolute low-level way of talking to your 19 00:01:52,320 --> 00:01:55,320 operating system, telling it to go ahead and give you the packets. And the other way is to give you 20 00:01:55,340 --> 00:02:01,500 packets. The second, slightly more abstracted way would be to use something like Skippy, 21 00:02:02,660 --> 00:02:09,360 LippyCap, or some other wrapper which works around all the low-level details of a raw socket. 22 00:02:10,960 --> 00:02:18,900 So how many of you have ever created your own SSID sniffer with a raw socket or used raw sockets 23 00:02:18,900 --> 00:02:24,160 at all? Okay. So let me show you how it looks like. 24 00:02:44,520 --> 00:02:55,320 So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw socket based SSID sniffer in roughly 20 lines of code. So this is a raw 25 00:02:55,320 --> 00:03:01,980 of Python. This does not use any external library. Now, initially, there's an interesting 26 00:03:01,980 --> 00:03:08,240 story behind why I created this piece of code. Initially, I had actually created a much more 27 00:03:08,240 --> 00:03:15,920 simplified one, roughly the same number of lines using Skippy, right? After that, I posted 28 00:03:15,920 --> 00:03:22,800 this on Reddit programming. And all the programmers started flaming me. They were like, you use 29 00:03:22,800 --> 00:03:27,300 Skippy, right? That isn't allowed. I mean, if you have to do it, you have to do it using 30 00:03:27,300 --> 00:03:34,160 just raw sockets. So that's when I created the alternate version, which just uses raw 31 00:03:34,160 --> 00:03:43,060 sockets. Now, how does this work? It opens a raw socket. And then we bind it to an interface 32 00:03:43,060 --> 00:03:49,080 assuming mon zero. Unfortunately, we have to change that to a WLAN X mon now, if you 33 00:03:49,080 --> 00:03:50,780 use one of the latest versions. 34 00:03:52,180 --> 00:03:52,780 Is it? 35 00:03:52,800 --> 00:03:52,960 Oh. 36 00:03:55,340 --> 00:04:01,740 That's because I think that change was brought about by Zero Chaos' AirMon NG ZC, right? 37 00:04:02,080 --> 00:04:04,360 It's less confusing. You know what interfaces are. 38 00:04:05,620 --> 00:04:10,300 That kind of required me to change almost all my scripts, which I probably wrote over 39 00:04:10,300 --> 00:04:17,560 the last eight years. So everything crashes for the first time now. So here is an example 40 00:04:17,560 --> 00:04:22,780 of how you can do that. What we do after that is basically just receive from the interface 41 00:04:22,780 --> 00:04:31,380 and check if this is an 802.11 packet and after that, pick up the SSID length from the 42 00:04:31,380 --> 00:04:37,240 exact location and check if it is another SSID or not. I mean, we are going to be using 43 00:04:37,240 --> 00:04:43,220 this to learn using Python. This is an example that you could write your own SSID sniffer 44 00:04:43,220 --> 00:04:49,180 in Python in just so many lines. The only place where I see a good application of this 45 00:04:49,180 --> 00:04:52,760 is on an embedded device. So if you have an open interface like this one, it will be 46 00:04:52,760 --> 00:04:58,040 open WRT based router, where you're trying to go ahead, sniff the air, you probably want 47 00:04:58,040 --> 00:05:03,800 to use this rather than scapy. Unfortunately, scapy seems to hold most of the packets in 48 00:05:03,800 --> 00:05:09,640 memory and embedded devices don't have that much amount of memory. So all your scapy based 49 00:05:09,640 --> 00:05:16,920 scripts end up crashing on your open WRT systems if they run for a long time. Let me show you 50 00:05:18,780 --> 00:05:33,340 how this looks like. So my wireless interface is WLAN 3. I'm just going to go to an airmon-ng 51 00:05:37,820 --> 00:05:39,300 start WLAN 3. 52 00:05:40,480 --> 00:05:46,520 So I'm just going to go ahead and start WLAN 3. 53 00:05:55,740 --> 00:06:02,900 And then I'm going to change the interface to WLAN 3mon. You could even take it as an 54 00:06:02,900 --> 00:06:06,100 input if you wanted. Let's actually take it as an input. 55 00:06:29,940 --> 00:06:39,380 Now the very first demo always crashes. So I'm just going to use a channel hopper 56 00:06:41,380 --> 00:06:42,720 in the background. 57 00:06:57,780 --> 00:06:59,100 Okay, this is bad. 58 00:07:00,700 --> 00:07:01,980 Just give me a second. 59 00:07:29,040 --> 00:07:29,380 Okay. 60 00:07:31,680 --> 00:07:32,800 I'll just get back to this. 61 00:07:33,100 --> 00:07:35,640 Unusually, I mean, this is the first time this has ever bailed out on me. 62 00:07:36,780 --> 00:07:38,660 So it's probably just bad luck. 63 00:07:39,880 --> 00:07:41,120 I'll just come back. 64 00:07:41,200 --> 00:07:42,820 I'll definitely kind of make this run. 65 00:07:42,980 --> 00:07:44,220 What a horrible way to start. 66 00:07:46,820 --> 00:07:51,720 What I really want to talk today about is how to automate WPA-based attacks. 67 00:07:52,060 --> 00:07:54,620 How many of you have used WPA-CLI? 68 00:07:56,360 --> 00:07:56,960 Anyone? 69 00:07:57,720 --> 00:07:58,320 Okay. 70 00:07:58,400 --> 00:08:06,040 So the de facto network management utility is WPA supplicant on Linux-based machines. 71 00:08:06,800 --> 00:08:08,000 Now, interestingly, 72 00:08:09,300 --> 00:08:13,320 WPA supplicant allows what is called a control interface 73 00:08:13,320 --> 00:08:15,660 through which you can control it at run time. 74 00:08:15,900 --> 00:08:17,760 So you can actually change parameters, 75 00:08:17,840 --> 00:08:20,600 make it do interesting stuff while it is running. 76 00:08:22,780 --> 00:08:24,740 So once you connect your client card, 77 00:08:24,880 --> 00:08:28,420 typically your network manager would go ahead and start it. 78 00:08:28,640 --> 00:08:33,820 You can actually look at where run. 79 00:08:42,820 --> 00:08:44,080 Okay, just a second, guys. 80 00:08:44,240 --> 00:08:45,440 I think I'll just do a quick reboot. 81 00:08:46,800 --> 00:08:47,880 I know what is wrong. 82 00:08:47,980 --> 00:08:50,040 I actually killed many of the network management utilities. 83 00:08:50,520 --> 00:08:51,320 That's the reason why. 84 00:08:52,100 --> 00:08:53,480 So how is this going to work? 85 00:08:55,120 --> 00:09:01,160 Basically, WLAN, the WPA supplicant exposes a control interface. 86 00:09:01,860 --> 00:09:04,880 Meantime, I can actually show you what the control interface looks like. 87 00:09:08,580 --> 00:09:09,980 Hmm. 88 00:09:17,900 --> 00:09:19,300 Hmm. 89 00:09:20,520 --> 00:09:21,920 Hmm. 90 00:09:42,200 --> 00:09:52,140 okay so wpa supplicant basically has a control interface and that control interface is actually 91 00:09:52,140 --> 00:09:58,980 what is used by our network manager so internally wpa supplicant exposes all of these different 92 00:09:58,980 --> 00:10:07,440 interfaces to you the one we are going to use is what they call the control if now the control 93 00:10:07,440 --> 00:10:14,900 if is actually a c-based api and we are going to be using a python wrapper to go ahead and 94 00:10:14,900 --> 00:10:18,020 talk to that and control wpa supplicant 95 00:10:21,600 --> 00:10:29,400 now what does the control interface allow us to do it actually allows us to run a bunch of commands 96 00:10:29,400 --> 00:10:37,080 for example ping looking at the mib the status so let's say if you're connected to a wpa 97 00:10:37,440 --> 00:10:44,840 network or for that matter any network using wpa supplicant you can monitor the status on a 98 00:10:44,840 --> 00:10:53,580 separate terminal you can even look at things like the different key caches you can set variables 99 00:10:53,580 --> 00:11:01,040 do log on log off so every single thing you could actually do with the wpa supplicant config file 100 00:11:01,040 --> 00:11:06,940 you can actually control that at runtime using the wpa supplicant control interface 101 00:11:09,040 --> 00:11:10,400 so let me quickly log in 102 00:11:19,860 --> 00:11:36,680 the demo gods aren't with me today this is my fifth talk at defcon i did two main stage and i think one village talk and one is tomorrow but this seems to probably be it it's about time statistics caught up with me so something has to go wrong okay you'll see it should run 103 00:11:39,880 --> 00:11:46,340 interestingly wpa supplicant also has a very low level api called the dbus api 104 00:11:46,340 --> 00:11:56,260 this is used by a ton of gui programs to go ahead and basically emulate what is linux's com 105 00:11:56,260 --> 00:12:07,120 right if you've used windows com think of this as com on linux so this allows different programs to talk to each other using a dbus 106 00:12:07,880 --> 00:12:31,460 this is really a virtual bus over which programs can send message to each other so you can have subscribers consumers you can publish your apis so wpa supplicant actually publishes its own api which you can access over the dbus so you could send it command poll what is the current events happening and things like that 107 00:12:53,220 --> 00:13:02,060 now as soon as you run your machine your network manager automatically will start wpa supplicant if you have a wireless card 108 00:13:02,880 --> 00:13:07,420 if wpa supplicant is configured to run its control interface 109 00:13:07,440 --> 00:13:12,080 you should actually find it in var run wpa supplicant 110 00:13:13,060 --> 00:13:18,700 interestingly the control interface file has the exact same name as the interface 111 00:13:18,700 --> 00:13:21,560 right wlan 3 in this case 112 00:13:22,680 --> 00:13:29,840 now anytime you need to go ahead and talk to the existing running version of wpa supplicant 113 00:13:29,840 --> 00:13:32,000 you actually use the control interface 114 00:13:33,220 --> 00:13:36,820 so let's look at some very simple examples 115 00:13:38,800 --> 00:13:45,840 now the best way to learn the control interface is to use a utility called wpa cli 116 00:13:45,840 --> 00:13:47,060 so anyone used it 117 00:13:48,600 --> 00:13:56,640 ok this is like one of the little hidden gems i mean if you use wpa cli you can automatically figure out the entire control interface 118 00:13:57,360 --> 00:14:00,960 so if you run wpa cli without any arguments 119 00:14:00,960 --> 00:14:06,880 it will automatically go inside the var run wpa supplicant directory 120 00:14:06,880 --> 00:14:15,660 directory figure out the control interface file and in a way attach to it so now it can monitor 121 00:14:15,660 --> 00:14:23,960 and look at what is happening on your current running instance of wpa supplicant so if you 122 00:14:23,960 --> 00:14:30,620 notice we just got two events here which said control events can result wps ap available 123 00:14:30,620 --> 00:14:41,420 right so you could actually write your own aero dump ng just by going ahead and invoking wpa cli 124 00:14:41,420 --> 00:14:52,160 with scan results and there you go you have a ton of information about everything wpa supplicant and 125 00:14:52,160 --> 00:15:00,080 in turn your network manager sees it also tells you which of the aps are wps enabled 126 00:15:00,080 --> 00:15:00,600 so if you have a wps supplicant and you have a wps supplicant and you have a wps supplicant 127 00:15:01,840 --> 00:15:05,100 i don't know if aero dump supports this at this point is thomas here 128 00:15:06,720 --> 00:15:10,200 no i haven't seen wps being tagged anywhere 129 00:15:14,320 --> 00:15:20,480 and this does not require any special cards if you have a functional linux system with a 130 00:15:20,480 --> 00:15:26,540 wireless card on it which works you can run wps cli on it this does not require an atheros card 131 00:15:26,540 --> 00:15:30,600 or an alpha card or any special hardware right it will just work out of the way so 132 00:15:30,620 --> 00:15:30,780 that's the bottom of the box 133 00:15:33,000 --> 00:15:40,780 now there are tons of different commands you can actually use with wps cli probably the 134 00:15:40,780 --> 00:15:46,300 easiest way to get started with wps supplicant which can be very confusing if you look at 135 00:15:46,300 --> 00:15:47,600 what is available in the config 136 00:15:52,380 --> 00:16:00,420 now let's try and look at uh... if he can automate some of these things right so you 137 00:16:00,420 --> 00:16:03,020 you could play with WPA CLI later on. 138 00:16:03,320 --> 00:16:04,800 It's completely command line, 139 00:16:04,960 --> 00:16:06,180 ton of help out there. 140 00:16:06,840 --> 00:16:08,400 And all you have to do is 141 00:16:08,400 --> 00:16:10,880 to configure a network as an example, 142 00:16:10,960 --> 00:16:12,320 you'll use add network. 143 00:16:12,620 --> 00:16:14,580 It actually returns an ID to you. 144 00:16:14,660 --> 00:16:16,260 And then you go ahead and, you know, 145 00:16:16,700 --> 00:16:18,740 add the network configs and all of that. 146 00:16:18,980 --> 00:16:21,000 It's a great tool if you want to configure, 147 00:16:21,180 --> 00:16:22,740 but this talk is about automation. 148 00:16:23,340 --> 00:16:24,920 So I'm not going to talk about 149 00:16:24,920 --> 00:16:26,680 how to use WPA CLI, right? 150 00:16:26,760 --> 00:16:28,720 But definitely have a look at it. 151 00:16:30,740 --> 00:16:33,000 So now let's look at 152 00:16:33,000 --> 00:16:36,260 how we can control WPA supplicant 153 00:16:36,260 --> 00:16:38,280 using the WPA control APIs. 154 00:16:46,020 --> 00:16:47,320 Okay, let's wait for it. 155 00:16:48,620 --> 00:16:49,300 Something's wrong. 156 00:16:50,940 --> 00:16:52,160 Someone's watching over me. 157 00:16:53,540 --> 00:16:54,060 Okay. 158 00:16:55,920 --> 00:16:58,020 So I'm trying my best not even, 159 00:16:58,020 --> 00:17:00,100 you know, move a muscle on this side. 160 00:17:00,420 --> 00:17:02,100 So that probably the cable doesn't get, 161 00:17:02,140 --> 00:17:04,500 you know, shaken up in any way. 162 00:17:04,600 --> 00:17:05,200 But I... 163 00:17:10,500 --> 00:17:11,600 Now, interestingly, 164 00:17:11,720 --> 00:17:16,260 there is only one Python extension 165 00:17:16,840 --> 00:17:18,820 available for WPA control 166 00:17:18,820 --> 00:17:21,000 called PyWPA control. 167 00:17:21,280 --> 00:17:22,440 You can actually go to GitHub. 168 00:17:23,360 --> 00:17:26,660 And originally the author of WPA supplicant 169 00:17:26,660 --> 00:17:29,560 had published this with some demo code in there. 170 00:17:30,420 --> 00:17:32,080 Unfortunately, he didn't maintain it. 171 00:17:32,320 --> 00:17:35,940 So PyWPA CTRL is the one which is updated 172 00:17:35,940 --> 00:17:37,620 with some small patching here and there. 173 00:17:38,150 --> 00:17:39,580 So remember to download that. 174 00:17:40,460 --> 00:17:41,740 Once you do that, 175 00:17:41,880 --> 00:17:44,420 you basically have the power of Python 176 00:17:45,560 --> 00:17:48,680 to control your WPA supplicant interface. 177 00:17:49,520 --> 00:17:52,020 So I'm going to open up another tab. 178 00:17:56,280 --> 00:17:59,060 And just start WPA CLI on this. 179 00:18:00,080 --> 00:18:02,520 Interestingly, you can have multiple agents 180 00:18:03,080 --> 00:18:04,980 pulling the same control interface 181 00:18:04,980 --> 00:18:07,400 and even sending receiving commands, right? 182 00:18:09,040 --> 00:18:11,340 So we'll use WPA CLI 183 00:18:11,340 --> 00:18:13,140 just to look at the kind of events 184 00:18:13,140 --> 00:18:14,580 which are happening in the background. 185 00:18:20,800 --> 00:18:23,600 Just so that you don't have to watch me type in stuff. 186 00:18:25,680 --> 00:18:28,340 Using WPA control is actually quite easy. 187 00:18:29,540 --> 00:18:31,080 All we have to do is 188 00:18:32,280 --> 00:18:34,460 import WPA control as expected. 189 00:18:39,780 --> 00:18:41,240 Now, once you do that, 190 00:18:41,400 --> 00:18:43,760 you need to tell WPA control 191 00:18:44,440 --> 00:18:47,120 where the control interface exists, 192 00:18:47,220 --> 00:18:50,880 which is where run WPA supplicant WLAN 3 193 00:18:50,880 --> 00:18:51,940 in our case. 194 00:18:52,520 --> 00:18:54,740 So we're going to go ahead and define that 195 00:18:54,740 --> 00:18:55,880 as the control interface. 196 00:19:00,900 --> 00:19:04,060 all of the sample source code will be available for download 197 00:19:04,060 --> 00:19:06,220 then I'll give you a URL and you can download it 198 00:19:09,400 --> 00:19:12,640 now after this you can actually tell WPA control 199 00:19:12,640 --> 00:19:17,540 to open and get a handle to this control interface 200 00:19:18,940 --> 00:19:22,240 right this is done with very simply WPA CTRL 201 00:19:22,240 --> 00:19:27,400 dot WPA control give it the path to the control interface 202 00:19:30,220 --> 00:19:36,620 now once you do that you can actually go ahead and ping the interface 203 00:19:38,000 --> 00:19:41,820 and if everything works fine you should get back a 204 00:19:42,640 --> 00:19:46,140 anyone if you ping it what do you get back 205 00:19:47,300 --> 00:19:52,120 a pong right so that's basically their own 206 00:19:52,120 --> 00:19:52,220 interface so that's basically their own interface 207 00:19:52,220 --> 00:19:55,300 internal quick heartbeat test mechanism 208 00:19:55,300 --> 00:19:59,740 so you can ping it just to ensure that hey do I have a stable connection 209 00:19:59,740 --> 00:20:03,420 is the control interface still running and 210 00:20:03,420 --> 00:20:06,840 all of the commands which we talked about here 211 00:20:07,860 --> 00:20:11,880 can actually be sent over the WPA CTRL interface 212 00:20:11,880 --> 00:20:15,820 I mean this is fantastic total hidden 213 00:20:15,820 --> 00:20:19,740 gems in here I mean you can actually automate live attacks and a ton of stuff 214 00:20:23,920 --> 00:20:24,880 now interestingly 215 00:20:24,880 --> 00:20:30,720 with just a couple of lines of Python you can actually control WPA supplicant 216 00:20:30,720 --> 00:20:36,240 and tell it to scan the network so before we do that you can look at the 217 00:20:36,240 --> 00:20:37,320 status of the interface 218 00:20:37,320 --> 00:20:37,740 so before we do that you can look at the status of the interface 219 00:20:37,740 --> 00:20:45,640 by just using status and right now it says he is inactive 220 00:20:45,640 --> 00:20:49,520 not connected really do anything and it just gives you a MAC address 221 00:20:50,640 --> 00:20:52,200 now we can request several Dynamics projects to do a server network setup 222 00:20:52,220 --> 00:21:00,500 a scan now keep in mind your network manager is already talking to wpa supplicant and requesting 223 00:21:00,500 --> 00:21:08,420 it to scan the air probably once every minute one of the ways you can stop that is kill the 224 00:21:08,420 --> 00:21:15,000 network manager or stop it and then you start your own instance of wpa supplicant with the right 225 00:21:15,000 --> 00:21:20,740 config options so that the control interface is available right then you might not have the 226 00:21:20,740 --> 00:21:27,540 network manager interfering so a lot of times when you actually try to run a scan you might 227 00:21:27,540 --> 00:21:35,100 actually get an error busy right now it says okay which is great and if we go back here let's try 228 00:21:35,100 --> 00:21:42,020 scanning once again so we are requesting a scan and a couple of seconds later you'll actually see 229 00:21:42,020 --> 00:21:48,960 scan results available so this is the wpa cli interface which is also monitoring for all the 230 00:21:48,960 --> 00:21:50,660 live events which wpa 231 00:21:50,660 --> 00:21:57,800 supplicant is publishing on its control interface so the moment we have scanned results and that's 232 00:21:57,800 --> 00:22:02,980 something you can monitor in python as well you could very simply go back 233 00:22:07,300 --> 00:22:10,240 and pretty much write your own version of arrow dump 234 00:22:11,980 --> 00:22:14,360 there you go isn't that great 235 00:22:16,460 --> 00:22:17,080 and 236 00:22:17,860 --> 00:22:18,480 and 237 00:22:20,660 --> 00:22:27,960 , and you could just run this in a loop you know time it once every couple of seconds and then you 238 00:22:27,960 --> 00:22:32,860 can get all the results interestingly if the network manager is running you do not even have 239 00:22:32,860 --> 00:22:40,440 to do anything it'll automatically scan periodically there are also event based mechanisms where you 240 00:22:40,440 --> 00:22:47,300 can be told when a scan is complete so people who've programmed like a callback right so that 241 00:22:47,300 --> 00:22:50,640 you receive a callback and you can only handle events and you can only handle events and you can 242 00:22:50,660 --> 00:23:00,620 see the results when they happen rather than having to poll for events continuously now here is one quick word of caution is if you run scan 243 00:23:00,620 --> 00:23:08,860 successively really quickly you're actually going to get fail busies now all of these scan requests are actually getting 244 00:23:08,860 --> 00:23:17,140 cached so after some time you'll actually have wpa supplicant quickly process them one after the other 245 00:23:20,800 --> 00:23:28,420 now this is something you would need to handle in your code and you'll actually see the error busy quite a lot of the fail busy quite a lot 246 00:23:30,800 --> 00:23:49,680 sometimes it's probably channel hopping still collecting stuff so you cannot time it you can't say okay after five seconds i can be sure the scan results are available you can't do that one mechanism is if you poll you have to check for the return value the other is where you subscribe and wait for the right event 247 00:23:49,680 --> 00:23:50,120 ,, 248 00:23:50,660 --> 00:23:53,300 right we'll talk about the event based mechanism a little later 249 00:23:56,580 --> 00:24:00,800 now wpa cli actually has like a ton of commands in there 250 00:24:00,800 --> 00:24:02,740 let me see if i can 251 00:24:06,500 --> 00:24:07,760 pick something up 252 00:24:09,620 --> 00:24:10,180 ,, 253 00:24:28,900 --> 00:24:29,460 okay 254 00:24:30,120 --> 00:24:32,200 i'll share this document as well this is 255 00:24:32,880 --> 00:24:37,320 a draft of one of the chapters i was writing for our next book 256 00:24:37,320 --> 00:24:37,600 ,, 257 00:24:37,600 --> 00:24:41,220 but wpa cli if i just quickly scroll down 258 00:24:41,220 --> 00:24:45,640 to show you the relevant part before we can move on to other interesting things 259 00:24:51,860 --> 00:25:01,720 so you can actually configure wpa psk wpa2 psk enterprise networks and all of that using wpa cli 260 00:25:02,440 --> 00:25:05,180 so here is an example you know scroll up 261 00:25:05,180 --> 00:25:05,680 ,, 262 00:25:06,540 --> 00:25:13,560 here's an example of how to configure a wpa-psk network using wpa cli so we 263 00:25:13,560 --> 00:25:14,100 first 264 00:25:14,840 --> 00:25:16,180 do an ad network, 265 00:25:16,420 --> 00:25:22,780 this returns an id and we need to use that ideanow to refleonce that network configuration 266 00:25:23,480 --> 00:25:25,640 every tiny talk to wpa-cli 267 00:25:26,860 --> 00:25:32,100 so after that you're going to be going to go ahead and change for example the ssid 268 00:25:32,680 --> 00:25:33,300 ah ? 269 00:25:33,300 --> 00:25:33,800 ,,, 270 00:25:33,800 --> 00:25:35,160 2018.13.12.white__30.com . ,, 271 00:25:35,160 --> 00:25:38,020 so WPA supplicant even allows you 272 00:25:38,020 --> 00:25:40,840 to decide whether you would like to send things like 273 00:25:40,840 --> 00:25:44,480 null probe requests or just silently wait for beacons 274 00:25:44,480 --> 00:25:46,580 all of that can be configured 275 00:25:47,320 --> 00:25:49,040 now in the case of PSK 276 00:25:49,040 --> 00:25:52,040 auth is going to be open, it's WPA PSK 277 00:25:52,040 --> 00:25:54,580 we are using tkip and then finally 278 00:25:54,580 --> 00:25:58,520 we use PSK, this is a demo 1.2.3 279 00:25:58,520 --> 00:26:01,140 mode defines whether this is infrastructure 280 00:26:01,140 --> 00:26:02,560 or independent BSS 281 00:26:04,180 --> 00:26:05,760 and very similarly 282 00:26:05,760 --> 00:26:08,360 you could actually go ahead and configure 283 00:26:09,800 --> 00:26:11,980 WPA2 PSK and enterprise as well 284 00:26:11,980 --> 00:26:15,640 so I highly recommend using and looking at 285 00:26:15,640 --> 00:26:18,460 WPA CLI as I said it's the best way to learn stuff 286 00:26:19,920 --> 00:26:21,620 now let's actually look at some 287 00:26:21,620 --> 00:26:23,940 serious scripting which we can do 288 00:26:38,480 --> 00:26:40,480 so event monitoring 289 00:26:41,380 --> 00:26:44,480 here's a simple example of how to monitor events 290 00:26:44,480 --> 00:26:46,400 really very simple 291 00:26:46,400 --> 00:26:49,460 all you have to do is call attach 292 00:26:49,460 --> 00:26:52,500 and after that you can just wait 293 00:26:52,500 --> 00:26:53,680 receiving for events 294 00:26:53,680 --> 00:26:57,240 so WPA.receive is a blocking call 295 00:26:57,240 --> 00:27:00,320 so anytime a new event is available 296 00:27:00,320 --> 00:27:01,760 you get woken up 297 00:27:02,560 --> 00:27:05,040 now if you're thinking what about individual events 298 00:27:05,040 --> 00:27:07,760 can I just subscribe to a scan result event 299 00:27:07,760 --> 00:27:12,120 well the control interface does not support that directly 300 00:27:12,120 --> 00:27:15,260 you probably have to write your own wrapper around it 301 00:27:15,260 --> 00:27:17,740 and then call whatever code you want 302 00:27:17,740 --> 00:27:19,360 depending on what event you received 303 00:27:22,920 --> 00:27:25,500 now one of the things I'd always wanted to do 304 00:27:25,500 --> 00:27:27,820 is write a live 305 00:27:28,640 --> 00:27:30,520 WPA PSK attack tool 306 00:27:30,520 --> 00:27:32,540 I mean there is nothing more to do than to write a live WPA PSK attack tool 307 00:27:32,560 --> 00:27:34,940 there is nothing more than an academic value to that 308 00:27:34,940 --> 00:27:36,320 now here is what I mean by that 309 00:27:37,420 --> 00:27:38,640 let's take a word list 310 00:27:38,640 --> 00:27:42,180 how do we crack WPA or WPA to PSK right now 311 00:27:42,180 --> 00:27:44,280 can anyone just explain while I connect everything 312 00:27:55,300 --> 00:27:57,600 what if there is no client around 313 00:28:03,340 --> 00:28:05,080 what if you're an impatient person 314 00:28:08,600 --> 00:28:13,780 so one of the interesting things which you can look at 315 00:28:13,780 --> 00:28:16,200 and this actually applies to a lot of stuff 316 00:28:22,080 --> 00:28:23,440 is what if 317 00:28:23,440 --> 00:28:27,080 I mean again there isn't much of practical value to this 318 00:28:27,080 --> 00:28:28,800 but the best part is you can still do it 319 00:28:28,800 --> 00:28:31,000 what if we could actually take 320 00:28:31,000 --> 00:28:32,260 pass phrases 321 00:28:32,260 --> 00:28:32,540 pass phrases 322 00:28:32,540 --> 00:28:39,740 out of a word list and try and check every single passphrase against the access point live 323 00:28:41,880 --> 00:28:48,780 now when you look at something like an air replay ng or many of these tools they are stateless 324 00:28:48,780 --> 00:28:54,000 which is most of them operate typically with the single packet principle right you send a 325 00:28:54,000 --> 00:28:59,940 you forget about it you keep sending dots doing a fake authentication actually is easy just a 326 00:28:59,940 --> 00:29:09,260 probe request response and the asoc stuff trying to verify a wpa passphrase live against an ap 327 00:29:09,260 --> 00:29:17,040 is non-trivial you actually need to have the entire wpa stack available including things like 328 00:29:17,040 --> 00:29:23,020 looking at the four-way handshake checking you know the different nonces creating your ptk 329 00:29:23,020 --> 00:29:29,000 and then finally verifying that against the mic right 330 00:29:29,000 --> 00:29:29,920 which is a very important thing to do and then finally verifying that against the mic 331 00:29:29,940 --> 00:29:35,920 which is like a signature over some of the four-way handshake packets only then do we actually know 332 00:29:35,920 --> 00:29:43,920 that hey the ap and i both of us have the same passphrase now how do you do something like that 333 00:29:43,920 --> 00:29:50,320 if you wanted to and actually this attack and automation doesn't just apply to wpa psk any time 334 00:29:50,320 --> 00:29:57,040 you actually want a full network stack available to you and where you'd like to try different 335 00:29:57,040 --> 00:29:59,920 attacks you would probably have to do something like this and that's what we're going to do 336 00:29:59,940 --> 00:30:07,160 we have to use the control interface of wpa supplicant or host apd right host apd also has 337 00:30:07,160 --> 00:30:10,100 a control interface so how do we do that 338 00:30:25,560 --> 00:30:29,120 okay so i've i'm going to show you what this script does in just a bit 339 00:30:29,940 --> 00:30:37,040 so it's a wpa psk live cracker and what it does is it goes through a dictionary 340 00:30:37,040 --> 00:30:43,220 picks up individual passphrases and tries it against the access point live 341 00:30:45,940 --> 00:30:53,380 yay right the reason i did not mention the ssid and all of that yet is i know the ctf guys would 342 00:30:53,380 --> 00:30:59,840 immediately like go ahead and send diodes and stop uh you know this from working so now i can go back 343 00:30:59,940 --> 00:31:05,500 to the script and show you how this works uh the same template can be used for any stateful attack 344 00:31:06,080 --> 00:31:11,780 so let's say you would like to create an access point on demand and you know an mitm setup you 345 00:31:11,780 --> 00:31:17,940 could go ahead use the control interface for host apd accordingly uh how does the code look like 346 00:31:18,880 --> 00:31:24,640 all of these python scripts would be shared after the class so you can run it yourself later on 347 00:31:31,580 --> 00:31:40,280 now if you recall i'd shown you wpa clis config on how you can go ahead and create a network and 348 00:31:40,280 --> 00:31:47,320 set different parameters for that network right so we are going to be using wpa controls api 349 00:31:47,980 --> 00:31:55,700 to simulate all of those steps but inside our own code so for every single passphrase in our word 350 00:31:55,700 --> 00:31:59,920 list we go ahead create the appropriate network setting and we're going to go ahead and create 351 00:31:59,940 --> 00:32:06,900 a network and then we tell wpa supplicant to actually run and try and connect to that 352 00:32:06,900 --> 00:32:15,360 so if i were to monitor wpa supplicant while this attack is going on uh you probably really 353 00:32:15,360 --> 00:32:20,600 appreciate what is happening in the background and why it is so heavyweight that you need a 354 00:32:20,600 --> 00:32:27,600 full-blown stack so i'm running this and actually start seeing tracebacks on wpa supplicant 355 00:32:30,100 --> 00:32:36,900 if you notice it's trying to authenticate associated right this is wpa supplicant 356 00:32:36,900 --> 00:32:41,360 trying to do the four-way handshake and there you go the first attempt the four-way handshake 357 00:32:41,360 --> 00:32:48,720 failed do you see that right and it basically disconnects then i give it the next passphrase 358 00:32:48,720 --> 00:32:54,680 and then it goes back and tries again second one right now is right on the list so 359 00:32:54,680 --> 00:32:59,580 finally key negotiation succeeds and we are able to connect to the network 360 00:33:01,020 --> 00:33:08,060 so by monitoring all of these state changes you can actually write your own stateful tools 361 00:33:08,060 --> 00:33:13,960 which probably can launch more sophisticated attacks after connections here is another 362 00:33:13,960 --> 00:33:21,920 simple example let's say you want to check every single open ssid and verify which one has 363 00:33:21,920 --> 00:33:29,440 free internet access on it right how do you do that right now if i told you to write a script 364 00:33:29,940 --> 00:33:38,520 connect to every network right and tell me if this has an internet available without maybe 365 00:33:38,520 --> 00:33:44,880 you know any form of captive portal on it or if it has a captive portal then maybe capturing 366 00:33:44,880 --> 00:33:51,420 the captive portals page and storing it somewhere right so you could use the exact same process 367 00:33:51,420 --> 00:33:57,880 all that would differ here is we would first scan the air do you recall when we called scan results 368 00:33:59,940 --> 00:34:05,900 the whole wpa ctrl scan and then we got the scan results and for every ap in the scan result 369 00:34:05,900 --> 00:34:11,040 we go ahead try and connect to it based on the security parameters which we see 370 00:34:11,040 --> 00:34:15,280 which is of course in this case it's open does not have any form of encryption 371 00:34:16,440 --> 00:34:22,600 once that is the case we try and connect to that access point and see if that succeeds 372 00:34:24,060 --> 00:34:29,820 wpa supplicant will raise the event and then you can actually even call the dhcp 373 00:34:29,940 --> 00:34:35,760 client on that interface actually could even have it running and then you can check if you're able 374 00:34:35,760 --> 00:34:42,280 to access servers and things like that so this is just an easy example really anything which 375 00:34:42,280 --> 00:34:49,900 requires you to do stateful things now if i were to go back just to look at the complicated part 376 00:34:49,900 --> 00:34:56,700 of the script now all of this looks quite simple and you don't have to do all the commands again 377 00:34:56,700 --> 00:34:59,300 and again all you have to change is just the passphrase 378 00:34:59,940 --> 00:35:08,320 every single time so i'm going through the word list and for every passphrase all i do is set the 379 00:35:08,320 --> 00:35:15,560 passphrase and then select and enable this network when we do that and send this command 380 00:35:15,560 --> 00:35:21,920 to wpa supplicant over the control interface wpa supplicant immediately starts picking up 381 00:35:21,920 --> 00:35:29,220 the configuration you created and tries to connect now all of the problems which i faced 382 00:35:29,940 --> 00:35:34,560 i mean i actually thought this would just be 20 lines of code that's it but when i started 383 00:35:34,560 --> 00:35:43,480 working with it do you recall all those fail busy fail those events seem to be happening more often 384 00:35:43,480 --> 00:35:51,220 than probably i realized so what i had to do is anytime i run a command i actually have a wrapper 385 00:35:51,220 --> 00:35:59,580 on top of it so this wrapper will actually automatically try to run that command for up 386 00:35:59,940 --> 00:36:05,900 to five times the command failing right so it tries the command gets back a failure says okay 387 00:36:05,900 --> 00:36:12,300 let's wait for maybe you know a second or two let's try it once again so this seems to be the 388 00:36:12,300 --> 00:36:18,240 only way and which i finally figured a lot of people were using as well uh including you would 389 00:36:18,240 --> 00:36:25,520 actually find not exactly this but something similar in android's wpa supplicant python code 390 00:36:25,520 --> 00:36:29,740 as well so literally all your linux and posix 391 00:36:29,940 --> 00:36:35,460 systems which use wpa supplicant including android actually automates most of the connection 392 00:36:35,460 --> 00:36:42,260 for the network manager using this exact control interface right there is no other choice really 393 00:36:42,260 --> 00:36:49,060 i mean the only other choice is you have a fixed config file which you start wpa supplicant with 394 00:36:50,400 --> 00:36:55,740 while a network manager needs the flexibility to be able to change the network based on what 395 00:36:55,740 --> 00:36:59,720 the user selects so this was one of the 396 00:36:59,940 --> 00:37:04,820 things i had to write uh it's actually very simple you know all i do is a while one and 397 00:37:04,820 --> 00:37:11,420 i go ahead keep trying uh catch the exception people who've used python if you haven't every 398 00:37:11,880 --> 00:37:16,980 language pretty much has something similar to this and i just go ahead and try up to 399 00:37:16,980 --> 00:37:27,160 maximum retries uh this actually works quite well let me actually delete uh the right passphrase 400 00:37:27,160 --> 00:37:28,040 from the word list 401 00:37:37,820 --> 00:37:41,680 and if you go back here you should be able to see the entire trace back 402 00:37:45,920 --> 00:37:51,760 now one of the other things i also managed to do after this is actually fire other automated 403 00:37:51,760 --> 00:37:58,540 tools so as an example let's say you want some kind of an automated scan to run after connection 404 00:37:58,540 --> 00:37:59,920 so you could connect to the network manager and you could connect to the network manager 405 00:37:59,920 --> 00:38:04,840 and you could control wpa supplicant connect to the network and once you get a dhcp address 406 00:38:04,840 --> 00:38:10,960 you can then launch nmap and all of those automatically right so a lot of automation 407 00:38:11,960 --> 00:38:18,540 across not just wi-fi but layers above it can actually happen with this script as a starting 408 00:38:18,540 --> 00:38:26,340 point i've tried brute forcing for up to 5000 of course it takes an astronomical time as i said 409 00:38:26,340 --> 00:38:29,480 the whole purpose of a wpa psk cracking 410 00:38:29,920 --> 00:38:35,880 live is more academic and just to illustrate the fact that you can do this without having to write 411 00:38:35,880 --> 00:38:44,140 your own network stack of any kind uh but it is actually quite stable uh the only flaky part was 412 00:38:44,140 --> 00:38:51,360 getting the ok busy and the ok errors from time to time and if you handle that with a wrapper it's 413 00:38:51,360 --> 00:38:59,220 actually quite stable any any questions with respect to the control interface 414 00:38:59,920 --> 00:39:03,980 i mean this is just one example of what you can do it's up to your creativity 415 00:39:04,620 --> 00:39:09,940 and you know the task at hand but any questions so far control interface yeah 416 00:39:13,320 --> 00:39:19,820 if you have multiple cards so here's the thing right because in a way wpa supplicant 417 00:39:19,820 --> 00:39:27,100 has a true stack not a simulated one using raw sockets so if you look at things like airbase ng 418 00:39:27,100 --> 00:39:29,900 they sniff packets just using raw sockets so if you look at things like airbase ng they sniff 419 00:39:29,920 --> 00:39:33,760 packets just using raw sockets so you could actually run multiple instances of airbase ng 420 00:39:33,760 --> 00:39:39,060 and one instance wouldn't interfere with the other because there is no true network stack attached 421 00:39:39,760 --> 00:39:45,880 but wpa supplicant actually has a stack and unfortunately because of that you can only run 422 00:39:45,880 --> 00:39:51,420 one instance on one card you could run multiple instances but you need multiple cards for that 423 00:39:51,420 --> 00:39:57,240 what is the other way you can automate is by doing everything in raw sockets 424 00:39:59,920 --> 00:40:04,940 but that is actually very very painful given the fact that the wpa four-way handshake and 425 00:40:04,940 --> 00:40:10,040 everything which follows after that including the group key management and the gtks and all of that 426 00:40:10,640 --> 00:40:17,740 is something which is quite difficult to emulate if you just wanted to do it in you know your own 427 00:40:17,740 --> 00:40:24,960 fake ap software but yes you could that would be one of the ways to do it question okay okay 428 00:40:35,560 --> 00:40:44,540 now one of the other things is something actually even more sophisticated just going to keep this 429 00:40:44,540 --> 00:40:49,500 simple all the code examples are available probably take a couple of hours to go through 430 00:40:49,500 --> 00:40:58,600 what dbus is but at a very high level a lot of programs use what is called the dbus which can be 431 00:40:58,600 --> 00:40:59,900 a system dbus or a system dbus or a system dbus or a system dbus or a system dbus or a system dbus 432 00:40:59,920 --> 00:41:06,500 or only on a per application basis think of this as a message queue at a very high level 433 00:41:06,500 --> 00:41:15,040 right so i can go ahead and say okay me wpa supplicant can go ahead and receive or send 434 00:41:15,040 --> 00:41:21,440 messages on the dbus and anyone who like to control me or probably go ahead and read data 435 00:41:21,440 --> 00:41:28,540 from what i'm doing can subscribe to the same dbus this isn't restricted to wpa supplicant 436 00:41:28,540 --> 00:41:29,900 actually i'm not going to go ahead and subscribe to the same dbus but i'm going to go ahead and 437 00:41:29,900 --> 00:41:37,220 a lot of software does this on posix based systems so here is an example and this this 438 00:41:37,220 --> 00:41:40,820 code can be a little intimidating but actually it is quite simple 439 00:41:40,820 --> 00:41:45,360 of how you can automate a wpa enterprise attack 440 00:41:48,100 --> 00:41:56,440 using dbus i'll just explain what it is so let's say in the case of peep or eapttls you probably 441 00:41:56,440 --> 00:41:59,720 want to try different iterations of usernames and passwords just as 442 00:41:59,900 --> 00:42:06,640 one other example right so in this case we could again use the wpa control interface which we just 443 00:42:06,640 --> 00:42:13,340 looked at what is the downside with the control interface the responses which you receive are all 444 00:42:13,340 --> 00:42:19,180 text based so you have to do the text parsing most of them are just separated by new lines so 445 00:42:19,180 --> 00:42:25,220 every line is separated by a new line the dbus gives you a pure data structure 446 00:42:25,880 --> 00:42:29,720 right so that you can actually work with data structures and objects 447 00:42:29,900 --> 00:42:35,300 directly rather than having to use text and maybe try to convert it to whatever compatible 448 00:42:35,300 --> 00:42:45,040 object your program requires so at the very top what we do is we mention the different dbus 449 00:42:45,040 --> 00:42:52,300 parameters this typically would tell the application where the dbus path interface and 450 00:42:52,300 --> 00:42:58,880 all of that is now wpa supplicant has all of this very well defined in its documentation 451 00:43:00,300 --> 00:43:05,860 right so they have a huge documentation for the dbus api 452 00:43:07,860 --> 00:43:14,860 ideally most of the implementations which i've seen of the dbus for supplicant is all c code 453 00:43:15,720 --> 00:43:20,560 your network manager for example actually uses the dbus api 454 00:43:23,880 --> 00:43:29,720 now the dbus api provides you most of the interfaces the control one does 455 00:43:29,900 --> 00:43:32,420 but as i said now you get back objects 456 00:43:33,860 --> 00:43:41,140 if i go back to the code now most of the process is exactly similar 457 00:43:43,140 --> 00:43:51,200 you would just have to do it in the dbus way right so that you can set up you know who you 458 00:43:51,200 --> 00:43:56,120 want to send messages to call the appropriate interfaces and all of that stuff all this code 459 00:43:56,120 --> 00:43:59,880 is going to be available for free uh personally i haven't seen a lot of dbus apps in the past 460 00:43:59,900 --> 00:44:03,840 i've seen much of this code being around anywhere so it kind of took me some time 461 00:44:03,840 --> 00:44:09,020 to write it because the documentation around this is poor the only good places i could 462 00:44:09,020 --> 00:44:14,600 find something was android's document or documentation really android's code for its 463 00:44:14,600 --> 00:44:17,860 network manager which also uses dbus and a couple of other things 464 00:44:22,360 --> 00:44:28,840 so with this you can actually i've kind of given scripts here uh you can automate scans 465 00:44:28,840 --> 00:44:31,520 So here is an example of me scanning with Dbus. 466 00:44:33,120 --> 00:44:37,060 It almost kills you, given the fact that the last time we scanned, 467 00:44:37,220 --> 00:44:39,760 we just basically sent scan and we just printed it, right? 468 00:44:39,820 --> 00:44:40,620 And everybody clapped. 469 00:44:40,800 --> 00:44:42,380 I'm sure when I run this, nobody will. 470 00:44:44,260 --> 00:44:47,100 So you could actually go ahead, start the scan. 471 00:44:47,240 --> 00:44:51,600 Let me show you how the scan looks like using the Dbus interface. 472 00:44:52,860 --> 00:44:55,660 So you need to know the interface ID. 473 00:44:55,660 --> 00:44:59,180 ID and run scan WLAN 3. 474 00:45:01,140 --> 00:45:04,140 Now, the best part of using Dbus is, as I said, 475 00:45:04,180 --> 00:45:05,420 everything you receive is objects. 476 00:45:05,800 --> 00:45:11,120 So you can actually parse all of these individual parameters very nicely 477 00:45:11,120 --> 00:45:15,900 and kind of reuse them in your program, right? 478 00:45:16,240 --> 00:45:18,140 Parse some of them, you can parse the rest. 479 00:45:18,700 --> 00:45:20,260 Some of them are still placeholders. 480 00:45:21,980 --> 00:45:25,160 So you could run the scan, get the list of APs, 481 00:45:25,180 --> 00:45:25,640 look at the list of APs, 482 00:45:25,640 --> 00:45:26,540 look at interesting ones, 483 00:45:26,640 --> 00:45:30,700 and now launch another module to do an automated attack. 484 00:45:31,740 --> 00:45:36,760 The WPA supplicant interface is the only one available right now 485 00:45:36,760 --> 00:45:42,720 to actually do very complicated stateful attacks on Wi-Fi, right? 486 00:45:43,220 --> 00:45:44,980 I haven't seen anything else. 487 00:45:47,660 --> 00:45:50,060 Any questions with respect to the Dbus? 488 00:45:50,100 --> 00:45:53,400 I mean, I'd probably take at least a day to go through the Dbus API 489 00:45:53,400 --> 00:45:55,140 if I were to teach it in a class. 490 00:45:55,640 --> 00:45:57,420 I just want to keep it high level 491 00:45:57,420 --> 00:45:59,920 and so that people can download and try the code 492 00:45:59,920 --> 00:46:02,560 rather than me explaining every aspect of it. 493 00:46:04,880 --> 00:46:05,320 Questions? 494 00:46:08,080 --> 00:46:08,520 Okay. 495 00:46:09,580 --> 00:46:11,580 Apart from this, of course, you also have 496 00:46:12,380 --> 00:46:15,220 some of the other code which we are giving out. 497 00:46:20,000 --> 00:46:20,760 Skippy, anyone? 498 00:46:21,980 --> 00:46:22,420 Skippy? 499 00:46:22,620 --> 00:46:23,400 Yay, right? 500 00:46:23,600 --> 00:46:24,040 Okay. 501 00:46:24,700 --> 00:46:25,140 Yeah. 502 00:46:25,640 --> 00:46:27,560 So a ton of Skippy code. 503 00:46:28,960 --> 00:46:30,820 A couple of the interesting ones, 504 00:46:32,240 --> 00:46:35,940 including things like monitoring probe requests through Skippy. 505 00:46:36,860 --> 00:46:37,880 You can try it. 506 00:46:37,880 --> 00:46:40,780 I mean, compared to using the WPA control and the Dbus API, 507 00:46:41,100 --> 00:46:42,860 I think Skippy is Python 101. 508 00:46:43,220 --> 00:46:46,080 So, I mean, it's super easy to use Skippy. 509 00:46:46,200 --> 00:46:49,440 There isn't much to it at all per se. 510 00:46:49,500 --> 00:46:51,020 So I'm not going to run Skippy code. 511 00:46:53,000 --> 00:46:54,900 This zip file should be available. 512 00:46:57,100 --> 00:47:03,080 At pentesteracademy.com slash wifivillage in the next one hour. 513 00:47:03,200 --> 00:47:05,300 I couldn't make my VPN work. 514 00:47:05,480 --> 00:47:06,020 I wonder why. 515 00:47:08,140 --> 00:47:10,160 So as soon as I get it working, it should be there. 516 00:47:10,680 --> 00:47:13,220 pentesteracademy.com slash wifivillage. 517 00:47:13,280 --> 00:47:14,560 Let me kind of write that out for you. 518 00:47:15,460 --> 00:47:17,080 You can download all the code. 519 00:47:17,260 --> 00:47:20,680 You can email me in case you're having any issues with the code 520 00:47:20,680 --> 00:47:25,220 or if there is any other interesting... 521 00:47:25,980 --> 00:47:27,740 aspect of it, which you want to know. 522 00:47:28,440 --> 00:47:31,160 Any other questions, queries about programming 523 00:47:32,220 --> 00:47:35,960 your own kind of wireless attack tool, which is stateful. 524 00:47:36,680 --> 00:47:39,440 All the deauth and all that is actually quite easy to write. 525 00:47:39,700 --> 00:47:41,220 I mean, you could write it with Skippy. 526 00:47:41,360 --> 00:47:42,580 You could do it in raw sockets. 527 00:47:42,600 --> 00:47:45,980 Most of them are just single packet or at most a couple of packets. 528 00:47:46,340 --> 00:47:48,260 Those are quite easy to write and maintain. 529 00:47:48,760 --> 00:47:52,000 Even the fake auth, I'd actually recommend using Skippy. 530 00:47:53,280 --> 00:47:55,620 Skippy has a couple of functions where it can actually... 531 00:47:55,640 --> 00:47:58,740 wait for the response, where it understands that 532 00:47:58,740 --> 00:48:01,860 if I send out a probe request, I'm looking for a response. 533 00:48:02,200 --> 00:48:05,420 Or if I send out an SOC request, I'm looking for a response. 534 00:48:05,660 --> 00:48:09,040 So I'd recommend Skippy up to fake auth. 535 00:48:09,660 --> 00:48:12,500 Beyond that, if you want to do anything stateful, 536 00:48:12,540 --> 00:48:16,160 which is stable, you probably look no further 537 00:48:16,160 --> 00:48:17,640 than the WPA control APIs. 538 00:48:20,000 --> 00:48:22,040 Extremely stable code, very well written. 539 00:48:22,380 --> 00:48:25,220 You know, being a C programmer, I actually looked at the code 540 00:48:25,220 --> 00:48:25,620 and I was like, oh, this is a really good code. 541 00:48:25,620 --> 00:48:28,160 I mean, you know, it's way better than what I could probably ever write. 542 00:48:30,820 --> 00:48:33,360 Been around probably for the last 15 years, 543 00:48:33,500 --> 00:48:35,400 so it's a fantastic code base. 544 00:48:37,020 --> 00:48:40,560 Every POSIX system uses WPA supplicant and host APD. 545 00:48:40,680 --> 00:48:43,880 By the way, they haven't published the interface for host APD, 546 00:48:43,920 --> 00:48:46,520 but you can tap into similar stuff and work with it as well 547 00:48:47,040 --> 00:48:48,680 by creating fake APs. 548 00:48:50,040 --> 00:48:54,560 Why is it better to use host APD over something like 549 00:48:54,560 --> 00:48:55,600 Airbase interface? 550 00:48:55,620 --> 00:49:02,180 What is the difference and where is it important 551 00:49:02,940 --> 00:49:04,400 to realize that difference? 552 00:49:04,580 --> 00:49:05,660 How many of you have used Airbase? 553 00:49:07,620 --> 00:49:08,140 Okay. 554 00:49:09,060 --> 00:49:12,240 How many of you have never created a fake AP? 555 00:49:13,360 --> 00:49:13,880 Okay. 556 00:49:14,940 --> 00:49:16,980 So people who used Airbase, 557 00:49:18,700 --> 00:49:21,560 you know, could we use Airbase if you wanted to do 558 00:49:21,560 --> 00:49:22,420 WPA enterprise? 559 00:49:24,500 --> 00:49:25,380 WPA enterprise. 560 00:49:25,620 --> 00:49:30,240 If you wanted to create a WPA2 peep or a TTLS based honeypot 561 00:49:30,240 --> 00:49:33,180 where you also have a back-end radius server. 562 00:49:33,320 --> 00:49:35,320 Actually, we did a bunch of demos yesterday 563 00:49:35,320 --> 00:49:37,220 in the last class we took, 564 00:49:37,880 --> 00:49:39,700 but maybe some of you weren't here. 565 00:49:39,840 --> 00:49:41,860 So could we do that with Airbase? 566 00:49:42,680 --> 00:49:43,200 No. 567 00:49:43,400 --> 00:49:43,920 Why? 568 00:49:45,140 --> 00:49:47,500 Because Airbase was in mental smoke. 569 00:49:48,360 --> 00:49:49,960 So you must do 570 00:49:51,940 --> 00:49:53,740 linium 4 bypass tech 571 00:49:53,740 --> 00:49:54,840 in the 572 00:49:55,920 --> 00:49:57,120 Airbase monitor mode. 573 00:49:58,020 --> 00:50:00,540 But if you work in monitor mode, we get all packets. 574 00:50:00,880 --> 00:50:03,240 So Airbase could actually pick up all the packets 575 00:50:03,240 --> 00:50:04,320 and do the needful, right? 576 00:50:09,480 --> 00:50:12,880 I mean, you're close, but not close enough. 577 00:50:13,320 --> 00:50:13,960 Go ahead. 578 00:50:14,080 --> 00:50:14,760 Give it a try. 579 00:50:16,740 --> 00:50:20,260 You need to build own host data. 580 00:50:21,440 --> 00:50:22,200 That's the point. 581 00:50:22,240 --> 00:50:22,440 Demon. 582 00:50:23,440 --> 00:50:23,900 Phone. 583 00:50:25,520 --> 00:50:27,140 Okay, you're close. 584 00:50:27,320 --> 00:50:28,440 Let me give the answer. 585 00:50:29,080 --> 00:50:31,700 So basically, what Airbase cannot do 586 00:50:31,700 --> 00:50:34,280 is low-level EAP packet redirection. 587 00:50:35,280 --> 00:50:35,620 Right? 588 00:50:35,660 --> 00:50:37,980 So when we look at WPA enterprise, 589 00:50:39,140 --> 00:50:42,420 all the initial network logon over 802.1X 590 00:50:42,420 --> 00:50:43,500 happens using EAP. 591 00:50:44,640 --> 00:50:46,120 I mean, EAP isn't IP. 592 00:50:46,300 --> 00:50:47,740 EAP is a protocol in by itself. 593 00:50:48,060 --> 00:50:50,680 So Airbase doesn't understand EAP. 594 00:50:51,400 --> 00:50:53,120 And Airbase doesn't work 595 00:50:53,120 --> 00:50:54,660 right now at least. 596 00:50:54,840 --> 00:50:56,980 And it cannot redirect EAP packets 597 00:50:56,980 --> 00:50:57,980 to the RADIUS server. 598 00:50:58,580 --> 00:50:59,660 Host APD can. 599 00:51:05,560 --> 00:51:08,760 Yeah, I mean, you could modify 600 00:51:08,760 --> 00:51:10,260 any tool if you added the support, 601 00:51:10,400 --> 00:51:11,860 but right now there isn't any support, 602 00:51:12,080 --> 00:51:12,900 is what I mean. 603 00:51:13,040 --> 00:51:15,780 Yeah, I mean, you could modify any source code 604 00:51:15,780 --> 00:51:17,080 to add any support you like, 605 00:51:17,160 --> 00:51:18,760 but as of this point, there isn't. 606 00:51:19,000 --> 00:51:19,440 Right? 607 00:51:19,480 --> 00:51:22,440 I mean, it isn't a limitation of it conceptually. 608 00:51:22,600 --> 00:51:24,680 It's a limitation in the sense of not being 609 00:51:24,680 --> 00:51:25,180 implemented. 610 00:51:26,420 --> 00:51:26,900 Right? 611 00:51:27,240 --> 00:51:28,200 Any questions? 612 00:51:29,540 --> 00:51:30,460 Any other questions? 613 00:51:31,620 --> 00:51:33,780 So you can download this code in 614 00:51:34,360 --> 00:51:35,420 maybe an hour's time. 615 00:51:35,520 --> 00:51:36,500 The link should be up. 616 00:51:36,700 --> 00:51:38,680 And if you have any questions about 617 00:51:38,680 --> 00:51:40,500 programming or automation with Python, 618 00:51:41,380 --> 00:51:42,860 we did the very first 619 00:51:42,860 --> 00:51:44,880 Python for Pentesters course online 620 00:51:44,880 --> 00:51:45,900 in the world. 621 00:51:46,060 --> 00:51:47,980 So we love Python. 622 00:51:48,160 --> 00:51:49,580 So if there's anything, just send us an email. 623 00:51:49,700 --> 00:51:50,140 Thank you. 624 00:51:51,500 --> 00:51:52,020 Thank you.