1 00:00:00,000 --> 00:00:05,920 And I would like to give a short introduction to my good friend Ted NoLastName here. 2 00:00:06,900 --> 00:00:11,160 Ted's just some random dude who hangs out here and on our Discord. 3 00:00:11,260 --> 00:00:21,000 And I said, man, I really want to reimplement this thing that Draghorn wrote for old Kismet in new Kismet, but I suck at programming. 4 00:00:21,000 --> 00:00:24,640 So do you think maybe you could, like, anybody want to help? 5 00:00:24,640 --> 00:00:27,380 And he's like, oh yeah, sure, I want to do that. 6 00:00:27,380 --> 00:00:30,320 And then he wrote the whole bloody thing and sent it to me. 7 00:00:30,320 --> 00:00:33,420 And I'm like, hey, cool, this works great. 8 00:00:33,500 --> 00:00:34,900 Let's use this. 9 00:00:34,900 --> 00:00:48,200 So not only is he giving a talk about that and some other fun stuff that he's done, we're using his tool that he wrote because I begged for somebody, anybody to write it for our gear talk to talk about how we select gear. 10 00:00:48,340 --> 00:00:59,060 So yeah, Kismet is an amazing tool and it's got an amazing REST interface and you can apparently spend a few hours and make several really neat things. 11 00:00:59,060 --> 00:01:02,080 So listen to Ted, no last name here. 12 00:01:08,000 --> 00:01:09,160 Hi. 13 00:01:10,300 --> 00:01:11,840 Hey, I'm Ted. 14 00:01:14,400 --> 00:01:24,580 I started doing wireless capture the flag with these guys about a year ago at B-Sides DC and I kind of have been addicted ever since. 15 00:01:26,020 --> 00:01:32,740 So yeah, I'm Ted, this is my first time at DEF CON, be gentle, but it's not a Ted talk. 16 00:01:35,280 --> 00:01:39,420 If you don't already know what Kismet is and you're in this room, you should Google it. 17 00:01:39,420 --> 00:01:40,520 Kismet is good. 18 00:01:42,660 --> 00:01:44,800 Kismet happens to have a REST API. 19 00:01:46,300 --> 00:01:49,860 I think technically it's a REST-like API, but whatever. 20 00:01:50,280 --> 00:01:55,960 It has an interface that you can use over HTTP to get lots of really cool information out of it. 21 00:01:56,700 --> 00:02:08,720 The reason I wanted to give this talk was because I like integrating things and making tools and this is a really powerful way to do that for Wi-Fi and other types of stuff that Kismet does. 22 00:02:08,720 --> 00:02:11,340 So I figured people here might be into it. 23 00:02:13,340 --> 00:02:16,240 Like I said, it's an HTTP interface. 24 00:02:16,460 --> 00:02:18,080 You make requests to it. 25 00:02:18,080 --> 00:02:22,640 So you can ask it for its status about the host system. 26 00:02:22,640 --> 00:02:30,060 You can ask for status about specific devices and it gives you back lots and lots of JSON, which you can then parse and do fun things with. 27 00:02:31,740 --> 00:02:37,420 My favorite feature of the REST API is actually that you can get PCAP over HTTP. 28 00:02:37,420 --> 00:02:42,600 I'll talk about that later, but extremely powerful integration opportunities there. 29 00:02:42,660 --> 00:02:47,400 And it's also, for an open source project, it is extremely well documented. 30 00:02:47,400 --> 00:02:56,660 The guy that writes Kismet, Dragorn, obviously put a lot of time into documenting this REST API, which makes it a lot easier to use. 31 00:02:58,680 --> 00:03:13,380 Like ZeroChaos said, I kind of, my introduction to the Kismet REST API was the program shootout that he wrote that needed to be refactored because they changed the, Kismet changed significantly a couple of years ago. 32 00:03:14,360 --> 00:03:19,820 And I kind of just wanted to learn new things and help this group out, because like I said, I'm addicted to WCTF. 33 00:03:19,880 --> 00:03:23,940 So I'm actually taking time away from it to tell you this. 34 00:03:25,700 --> 00:03:26,200 Right. 35 00:03:26,200 --> 00:03:27,600 So this was kind of a funny story. 36 00:03:27,600 --> 00:03:30,780 So I'm a C++ programmer. 37 00:03:30,780 --> 00:03:39,080 And so when this idea, when the shootout needed to be refactored, it was written in Ruby and nobody programs in Ruby. 38 00:03:39,080 --> 00:03:44,660 So I wanted to rewrite it in C++ and make a Kismet plugin because that was like kind of the old school way of doing it. 39 00:03:44,960 --> 00:03:48,980 So I went into Dragorn's Discord and talked to him and it was like, you know, what's the best way to do this? 40 00:03:48,980 --> 00:03:50,940 And he was like, don't, don't write a plugin. 41 00:03:51,020 --> 00:03:52,280 Just use the REST API. 42 00:03:52,280 --> 00:03:53,600 Everything you need is right there. 43 00:03:53,940 --> 00:03:57,280 I kept trying to write a plugin though, because I don't know. 44 00:03:57,280 --> 00:03:58,120 I don't know why. 45 00:03:58,640 --> 00:04:01,940 So I wasted a lot of time, realized writing Kismet plugins is hard. 46 00:04:01,940 --> 00:04:03,440 There are good reasons to do that. 47 00:04:03,440 --> 00:04:10,580 If you're adding a new file or a new, I don't know, you want to add something to the packet chain or whatever, for everything else, use the REST API. 48 00:04:10,580 --> 00:04:12,180 So it's kind of a lesson learned. 49 00:04:12,360 --> 00:04:13,460 Trust Dragorn. 50 00:04:13,700 --> 00:04:15,520 Use simple APIs when possible. 51 00:04:16,620 --> 00:04:18,740 Anyway, it ended up working. 52 00:04:19,160 --> 00:04:20,820 This is what Shootout looks like. 53 00:04:20,820 --> 00:04:29,400 I'm not going to go too much into what Shootout does and what it looks like, but I am going to talk about how it works because it's very relevant to the talk. 54 00:04:29,840 --> 00:04:34,460 I think, I think the village people are going to go into how to use it and what it does later. 55 00:04:37,000 --> 00:04:44,160 So basically, Shootout, you give it a list of data sources for Kismet. 56 00:04:44,420 --> 00:04:50,620 And using the REST API, it grabs packet counters for all of them and kind of compares them. 57 00:04:50,700 --> 00:04:53,560 So when you first start up, obviously it's got to connect. 58 00:04:53,840 --> 00:04:57,300 It's got to make sure that the interfaces that you told it to look for are actually there. 59 00:04:57,300 --> 00:05:02,540 And if they're not, well, if they're there but they're not enabled, it will enable them for you. 60 00:05:03,720 --> 00:05:13,620 And then it just goes into a loop forever and ever and grabs the device JSON and looks at the packet counters and compares the received packet count for each device. 61 00:05:13,620 --> 00:05:15,260 So it tunes them all to the same channel. 62 00:05:15,260 --> 00:05:21,920 So the idea is given some initial offset, they should all be seeing the same number of packets. 63 00:05:22,500 --> 00:05:30,320 So it gives you a super non-scientific rough idea of monitor mode performance for Wi-Fi cards. 64 00:05:30,680 --> 00:05:37,440 Anyway, the way you make all that stuff happen is using the REST API endpoints. 65 00:05:38,160 --> 00:05:43,520 So they have kind of a general format where, you know, it's some URI, right? 66 00:05:43,520 --> 00:05:48,200 So you're going like HTTP and then usually local host, 2501. 67 00:05:48,640 --> 00:05:49,680 And then some topic. 68 00:05:49,680 --> 00:05:51,340 I just kind of made that word up there. 69 00:05:51,400 --> 00:05:54,340 Like either system or devices or something else. 70 00:05:55,400 --> 00:05:58,340 Criteria, I also kind of made that up and shoved that in there. 71 00:05:58,340 --> 00:06:00,720 Like some of the topics have filters. 72 00:06:00,880 --> 00:06:04,140 So you can filter by a key or by a MAC address. 73 00:06:04,140 --> 00:06:05,420 We'll talk about that more later. 74 00:06:05,640 --> 00:06:06,980 And then a serialization. 75 00:06:06,980 --> 00:06:12,240 So the primary serialization you're going to use, if you're interested in this, is probably JSON. 76 00:06:12,400 --> 00:06:15,680 There's also EKJSON, which I have no idea what that is. 77 00:06:15,680 --> 00:06:16,720 It's some big data thing. 78 00:06:16,720 --> 00:06:18,000 I don't do that. 79 00:06:18,420 --> 00:06:23,340 And then there's PrettyJSON, which, you know, makes the JSON have new lines in it. 80 00:06:24,940 --> 00:06:26,600 So some examples. 81 00:06:26,660 --> 00:06:28,400 I mentioned the system status. 82 00:06:28,820 --> 00:06:30,340 There's actually a ton of data in there. 83 00:06:30,340 --> 00:06:33,160 Like if you run it on a laptop, it gives you like your battery life. 84 00:06:33,160 --> 00:06:35,400 It gives you CPU temperature. 85 00:06:35,480 --> 00:06:39,240 For this crazy laptop, it actually tells me the temperature of my internal Wi-Fi card. 86 00:06:39,240 --> 00:06:39,800 It's cool. 87 00:06:41,120 --> 00:06:45,940 The device status, basically there's two ways to look at that. 88 00:06:45,940 --> 00:06:47,460 You can see it by key or by MAC. 89 00:06:47,460 --> 00:06:48,560 Again, we'll get into it later. 90 00:06:48,560 --> 00:06:54,020 But, you know, you give Kismet via this URI a MAC address and it gives you back all the JSON. 91 00:06:54,440 --> 00:06:56,760 Data source status is actually how we do shootout. 92 00:06:56,760 --> 00:06:58,600 So that's pulling for each. 93 00:06:59,160 --> 00:07:05,020 Each data source has its own big JSON object and you get that back each time you access this URI. 94 00:07:06,040 --> 00:07:09,180 Location is something that I haven't messed with too much, but I'm really interested in. 95 00:07:09,180 --> 00:07:18,880 So you may already know that Kismet can take data from GPSD, can take NMEA 0183 data over the network or something like that. 96 00:07:20,280 --> 00:07:29,920 If you don't have one of those fancy things, you can also tell Kismet where it is by sending a command to that location endpoint, which is sort of neat. 97 00:07:29,920 --> 00:07:43,280 So if you were running Kismet in some place where you don't have normal GPS, so you have some fancy GPS that doesn't do that stuff, you could still do this integration entirely using the REST API without having to write crazy fancy code. 98 00:07:43,620 --> 00:07:46,520 And then, like I said, my favorite thing, getting PCAP. 99 00:07:47,940 --> 00:07:57,140 The device JSON is like 400 lines or something if you shove it in a sublime and pretty JSON it. 100 00:07:58,000 --> 00:07:59,180 It's a lot of data. 101 00:07:59,180 --> 00:08:01,140 So there's a lot of detail in there. 102 00:08:01,980 --> 00:08:05,580 The thing that I'm usually looking at is received signal strength. 103 00:08:05,580 --> 00:08:07,940 He just calls it last signal, I think. 104 00:08:08,080 --> 00:08:09,360 But there's tons of stuff in there. 105 00:08:09,360 --> 00:08:14,800 There's round robin databases for signal strength and packet counts and all kinds of stuff. 106 00:08:15,820 --> 00:08:17,240 So here's an example. 107 00:08:17,880 --> 00:08:19,260 I'm going to move this a little bit. 108 00:08:20,400 --> 00:08:26,140 So this is one of the tools that I kind of whipped up just to show what the REST API can do. 109 00:08:26,560 --> 00:08:27,900 So I'm running Kismet. 110 00:08:28,360 --> 00:08:32,440 And you guys, you ever see one of these? 111 00:08:32,440 --> 00:08:35,300 This is an ESP8266. 112 00:08:35,300 --> 00:08:37,380 It's like an IOT microcontroller. 113 00:08:37,800 --> 00:08:39,600 It's basically an Arduino with Wi-Fi. 114 00:08:39,980 --> 00:08:48,880 This one happens to be serving up an access point called WCTF underscore king of the hill, which may have significance to those people. 115 00:08:49,640 --> 00:08:54,400 Interestingly, there was so many people connected to this fake king of the hill that it was crashing. 116 00:08:54,400 --> 00:08:56,060 So hopefully it's not crashed right now. 117 00:08:56,200 --> 00:09:01,680 Anyway, the KRRSSI tool uses the Kismet REST API based on this Mac. 118 00:09:01,680 --> 00:09:02,840 So I'm feeding it. 119 00:09:03,400 --> 00:09:04,560 Wow, that's small. 120 00:09:05,060 --> 00:09:05,840 You'll have to trust me. 121 00:09:05,840 --> 00:09:07,260 I'm giving it a Mac address. 122 00:09:07,740 --> 00:09:12,860 And then basically it's just showing you this shitty little bar of received signal strength. 123 00:09:12,860 --> 00:09:17,040 So if I go over here or cover this up or something, you should see the signal strength go down. 124 00:09:17,320 --> 00:09:26,000 And if I get closer to my little TP link fancy card, it's turning red, which is, you know, more signal. 125 00:09:26,700 --> 00:09:28,320 So that's how that works. 126 00:09:28,320 --> 00:09:29,280 Really simple tool. 127 00:09:29,280 --> 00:09:33,180 It's just polling the REST API at 1 hertz using that device endpoint. 128 00:09:36,240 --> 00:09:46,140 Another slightly more sophisticated version of the RSSI tool does the same thing, but instead of using... so that last tool used a scalar field in the REST API. 129 00:09:46,140 --> 00:09:51,900 So it's just telling you this is instantaneously the last signal strength that I saw for the Mac address you just gave me. 130 00:09:52,060 --> 00:09:59,620 There's also a round robin database in there that gives you 60 seconds worth of that data, obviously with one second interval. 131 00:09:59,620 --> 00:10:03,000 So I made a tool to use that instead. 132 00:10:03,520 --> 00:10:05,180 And it gives you this pretty little graph. 133 00:10:05,880 --> 00:10:20,700 And you can kind of... you probably can't read it, but on the screen it's showing you the big vector that... these programs are written in Python and there's a cool JSON library for Python that basically turns raw JSON into Python dictionaries, which is super convenient. 134 00:10:21,340 --> 00:10:25,160 So I'm just dumping out that dictionary there to show you the received signal strength. 135 00:10:25,360 --> 00:10:29,680 And then I'm feeding that to pi plot, which is, you know, doing fancy things. 136 00:10:29,920 --> 00:10:33,960 So again, it's kind of harder to see... oh, yeah, okay, it's not harder to see. 137 00:10:34,020 --> 00:10:36,120 The signal got stronger when I made it close. 138 00:10:36,540 --> 00:10:40,820 So anyway, that's KR, RSSI and RSSI2. 139 00:10:41,380 --> 00:10:44,900 So those use the REST API to look at signal strength. 140 00:10:45,980 --> 00:10:47,040 But there's more. 141 00:10:47,260 --> 00:10:55,060 So in addition to just kind of passively polling for stuff, you can send commands to Kismet over the same API. 142 00:10:55,760 --> 00:10:57,200 Again, it's all in JSON. 143 00:10:57,440 --> 00:10:59,880 So two examples up here. 144 00:11:00,120 --> 00:11:01,280 You can add a data source. 145 00:11:01,280 --> 00:11:03,080 Remember how I was talking about with shootout? 146 00:11:03,840 --> 00:11:14,280 Like it would be a pain if I wanted to test, say, 30 Wi-Fi cards, and for each one of those I had to test, I needed to go into the web UI and click on that source to enable it. 147 00:11:14,280 --> 00:11:15,380 That would get annoying. 148 00:11:15,620 --> 00:11:18,420 So shootout adds them all for you. 149 00:11:18,420 --> 00:11:27,500 So basically this add data source or this add source.CMD endpoint takes an interface Kismet knows about, turns it into a data source. 150 00:11:27,700 --> 00:11:32,460 And then the set channel endpoint, similarly, you know, sets a channel. 151 00:11:32,460 --> 00:11:35,440 You can also set hopping and hop rate and other things like that. 152 00:11:35,820 --> 00:11:37,720 Like I said before, it's really well documented. 153 00:11:37,720 --> 00:11:38,540 Google it. 154 00:11:40,640 --> 00:11:43,900 Here's an example that actually kind of solves a practical problem. 155 00:11:43,900 --> 00:11:46,520 So if, actually, I'll show you this first. 156 00:11:46,640 --> 00:11:57,600 Have any of you, hopefully you're using Kismet, have any of you seen this issue where, like, you go into the web GUI and you click lock and then you click on a channel and it, like, doesn't actually do that? 157 00:11:57,600 --> 00:12:00,740 It, like, lights up for a second and then goes back to whatever channel it was on. 158 00:12:00,740 --> 00:12:01,540 Super annoying. 159 00:12:01,540 --> 00:12:11,860 So to overcome that, I use the REST API to make a little program that lets me change to a different channel. 160 00:12:11,860 --> 00:12:17,020 So right now I'm going to change TTUH is my little Wi-Fi adapter up here. 161 00:12:17,020 --> 00:12:18,500 I'm going to change it to channel 6. 162 00:12:18,500 --> 00:12:18,880 Cool. 163 00:12:18,880 --> 00:12:19,480 Done. 164 00:12:20,760 --> 00:12:24,940 I'm going to go back to 1 because that's where my fake king of the hill is. 165 00:12:25,860 --> 00:12:29,880 Anyway, that's really convenient if you're having that issue. 166 00:12:29,920 --> 00:12:32,360 And it's also exactly how shootout works. 167 00:12:34,760 --> 00:12:38,840 If those would be beneficial to you all, they're on my GitHub, it's there. 168 00:12:40,060 --> 00:12:43,780 If you don't feel like, I don't know, typing that out or something, just come ask me. 169 00:12:45,900 --> 00:12:48,960 So DragWorm put a lot of work into this. 170 00:12:49,880 --> 00:12:57,140 A feature like this, like, you would only add something like this if you were really thinking hard about how somebody would use this API. 171 00:12:57,480 --> 00:13:04,260 Field selection lets you limit the amount of JSON you get back. 172 00:13:04,260 --> 00:13:12,340 So I said before, and I kind of showed a little snippet of it, the JSON you get back from the Kismet REST API, like for a device, is like 400 lines. 173 00:13:12,740 --> 00:13:21,620 Serializing anything via some text-based mechanism like XML or JSON is hugely inefficient in terms of bandwidth. 174 00:13:22,200 --> 00:13:29,340 So field selection lets you tell Kismet, I want the device JSON, but I really only care about this one field. 175 00:13:30,320 --> 00:13:37,600 And you can do that by using a command, just like the command I showed you before, or you can actually just tack some stuff onto the URL to filter it. 176 00:13:38,400 --> 00:13:48,860 So when you use command-based selection, basically you just make a command that looks like this that has a fields property and you shove all the fields you want into an array and boom, that's it. 177 00:13:48,860 --> 00:13:50,220 Kismet gives you back what you want. 178 00:13:51,200 --> 00:13:59,380 When you do it via URI, that's probably really hard for you to read, but you can trust me that after device.json, there's a bunch of fields tacked onto the end. 179 00:13:59,380 --> 00:14:03,000 So they do the same thing, they're just slightly different. 180 00:14:04,440 --> 00:14:05,480 Right, PCAP. 181 00:14:05,480 --> 00:14:13,520 So the sort of powerful thing you can do with the REST API is this allpackets.pcapng. 182 00:14:13,720 --> 00:14:20,260 That is every packet that PCAP is, sorry, that Kismet is seeing, no matter how many sources you have. 183 00:14:20,260 --> 00:14:24,640 So you're going to get lots of packets, like if you're over there with 30 Wi-Fi cards and stuff. 184 00:14:25,920 --> 00:14:30,620 You can limit that to one data source, which I don't know why you would do that, but you can do it. 185 00:14:30,940 --> 00:14:34,480 And the really powerful thing is you can limit it by device. 186 00:14:35,200 --> 00:14:45,980 So I can tell Kismet, no matter how many devices I have, no matter how many data sources I have, I can tell it, I want the PCAP, but only from this thing. 187 00:14:46,500 --> 00:14:55,520 Which is incredibly powerful when you're playing that game and there's people with, you know, fake challenges and there's tons of Wi-Fi. 188 00:14:55,520 --> 00:14:58,860 Like if you were to open up that all packets over there, it would probably just crash Wireshark. 189 00:14:58,860 --> 00:15:00,200 There's too much. 190 00:15:00,600 --> 00:15:05,260 So anyway, before I get to that, I'll show you what that looks like. 191 00:15:07,100 --> 00:15:08,980 So hopefully this works. 192 00:15:11,220 --> 00:15:14,280 Instead of using Python, I'm just using curl right from the command line. 193 00:15:14,280 --> 00:15:15,620 So this is kind of a one liner. 194 00:15:15,620 --> 00:15:19,580 I'm logging into Kismet, I'm telling it I want devices by key. 195 00:15:20,280 --> 00:15:22,420 You can get that key from the web user interface. 196 00:15:22,420 --> 00:15:23,560 You can copy paste it. 197 00:15:24,240 --> 00:15:28,660 And then slash PCAP and slash the key again for some reason, .PCAPNG. 198 00:15:28,820 --> 00:15:32,780 And you can pipe that to Wireshark and tell it to read from standard input. 199 00:15:33,480 --> 00:15:35,280 And then magic happens. 200 00:15:35,500 --> 00:15:43,340 This is just the traffic from this little device right here, even though there's lots and lots of traffic. 201 00:15:43,340 --> 00:15:48,560 I keep pointing over there because that's where the game is happening and those guys are doing all kinds of crazy things, making more traffic. 202 00:15:49,500 --> 00:15:51,860 But Kismet filtered this for me, which is really cool. 203 00:15:52,760 --> 00:15:55,700 Especially if you're looking for that needle in a haystack. 204 00:15:55,700 --> 00:15:59,820 You're looking for one emitter in a sea of other emitters. 205 00:15:59,820 --> 00:16:03,000 This is a really powerful integration tool. 206 00:16:04,640 --> 00:16:05,620 No, I don't want to save it. 207 00:16:05,620 --> 00:16:06,300 I don't care. 208 00:16:07,300 --> 00:16:07,800 Okay. 209 00:16:08,800 --> 00:16:16,180 There are some advanced points, end points that honestly I haven't looked at that much, but I wanted to mention because they seem really cool to me. 210 00:16:17,460 --> 00:16:20,000 Views is kind of like a database view thing. 211 00:16:20,100 --> 00:16:27,720 I haven't used it, so I don't know how it works, but you can combine different sets of data and filter them by defining these views. 212 00:16:28,340 --> 00:16:30,220 Points of interest sounds kind of cool to me. 213 00:16:30,220 --> 00:16:37,580 There's a way you can send a command to that end point and tell it right now at this moment in time, something super interesting to me happened. 214 00:16:38,140 --> 00:16:54,620 So Kismet is logging all this stuff to an SQLite database, so you can go back in time after your post-event analysis or if you're up late in the hotel room trying to get more flags, you can go back and look and see, hey, what time did that thing that doesn't happen that often happen? 215 00:16:55,880 --> 00:16:56,880 And then Kismet DB. 216 00:16:56,880 --> 00:16:58,080 I mentioned PCAP. 217 00:16:58,320 --> 00:17:05,980 I don't have a demo for this, unfortunately, but another really powerful thing with Kismet REST API and PCAP is you can go back in time. 218 00:17:06,220 --> 00:17:18,200 So the curl kind of one-liner piping to Pyreshark, piping to Wireshark that I showed you is real-time data ingest for all sources for the filter selection that I picked. 219 00:17:19,480 --> 00:17:27,820 You can go back and you can tell Kismet I want all the PCAP between this date timestamp and this other date timestamp, which I also think is really cool. 220 00:17:30,380 --> 00:17:38,120 Again, like I said in the beginning, the reason I think this is interesting is because there's a lot of bad APIs out there. 221 00:17:38,120 --> 00:17:39,480 There's tons of bad code. 222 00:17:39,740 --> 00:17:41,840 There's tons of poorly documented code. 223 00:17:43,120 --> 00:17:44,740 This is not those things. 224 00:17:44,740 --> 00:17:54,780 It's really good and I think there's lots of opportunity to make new tools and to integrate Kismet with, you know, whatever kind of system you can dream up that cares about Wi-Fi. 225 00:17:55,720 --> 00:17:56,860 So that's it. 226 00:17:56,860 --> 00:17:57,820 That's my talk. 227 00:17:59,080 --> 00:18:00,560 Hope you guys get something out of that. 228 00:18:00,560 --> 00:18:01,340 Kismet is cool. 229 00:18:01,340 --> 00:18:02,280 Please use it. 230 00:18:02,800 --> 00:18:03,560 Thanks.