[00:00.000 --> 00:05.920] And I would like to give a short introduction to my good friend Ted NoLastName here. [00:06.900 --> 00:12.400] Ted's just some random dude who hangs out here and on our Discord. And I said, [00:12.400 --> 00:18.760] man, I really want to reimplement this thing that Draghorn wrote for old Kismet in new Kismet, [00:18.760 --> 00:24.640] but I suck at programming. So do you think maybe you could, like, anybody want to help? [00:24.640 --> 00:29.840] And he's like, oh yeah, sure, I want to do that. And then he wrote the whole bloody thing and sent [00:29.840 --> 00:36.220] it to me. And I'm like, hey, cool, this works great. Let's use this. So not only is he giving [00:36.360 --> 00:42.120] a talk about that and some other fun stuff that he's done, we're using his tool that he wrote [00:42.120 --> 00:47.360] because I begged for somebody, anybody to write it for our gear talk to talk about how we select [00:47.360 --> 00:55.060] gear. So yeah, Kismet is an amazing tool and it's got an amazing REST interface and you can [00:55.060 --> 01:01.020] apparently spend a few hours and make several really neat things. So listen to Ted, no last [01:01.020 --> 01:19.800] name here. Hi. Hey, I'm Ted. I started doing wireless capture the flag with these guys about a [01:19.800 --> 01:28.260] year ago at B-Sides DC and I kind of have been addicted ever since. So yeah, I'm Ted, this is my [01:28.260 --> 01:36.860] first time at DEF CON, be gentle, but it's not a Ted talk. If you don't already know what Kismet [01:36.860 --> 01:43.980] is and you're in this room, you should Google it. Kismet is good. Kismet happens to have a REST [01:43.980 --> 01:51.680] API. I think technically it's a REST-like API, but whatever. It has an interface that you can [01:51.680 --> 01:58.140] use over HTTP to get lots of really cool information out of it. The reason I wanted to give [01:58.140 --> 02:04.200] this talk was because I like integrating things and making tools and this is a really powerful [02:04.200 --> 02:10.060] way to do that for Wi-Fi and other types of stuff that Kismet does. So I figured people here [02:10.060 --> 02:20.240] might be into it. Like I said, it's an HTTP interface. You make requests to it. So you can ask [02:20.240 --> 02:25.080] it for its status about the host system. You can ask for status about specific devices and it [02:25.080 --> 02:32.220] gives you back lots and lots of JSON, which you can then parse and do fun things with. My [02:32.220 --> 02:37.860] favorite feature of the REST API is actually that you can get PCAP over HTTP. I'll talk about [02:37.860 --> 02:43.720] that later, but extremely powerful integration opportunities there. And it's also, for an [02:43.720 --> 02:48.720] open source project, it is extremely well documented. The guy that writes Kismet, [02:48.720 --> 02:55.520] Dragorn, obviously put a lot of time into documenting this REST API, which makes it a lot [02:55.520 --> 03:05.380] easier to use. Like ZeroChaos said, I kind of, my introduction to the Kismet REST API was the [03:05.380 --> 03:11.100] program shootout that he wrote that needed to be refactored because they changed the, Kismet [03:11.100 --> 03:16.620] changed significantly a couple of years ago. And I kind of just wanted to learn new things and [03:16.620 --> 03:21.960] help this group out, because like I said, I'm addicted to WCTF. So I'm actually taking time [03:21.960 --> 03:30.780] away from it to tell you this. Right. So this was kind of a funny story. So I'm a C++ programmer. [03:30.780 --> 03:36.560] And so when this idea, when the shootout needed to be refactored, it was written in Ruby and [03:37.720 --> 03:42.560] nobody programs in Ruby. So I wanted to rewrite it in C++ and make a Kismet plugin because that [03:42.560 --> 03:46.960] was like kind of the old school way of doing it. So I went into Dragorn's Discord and talked to [03:46.960 --> 03:50.160] him and it was like, you know, what's the best way to do this? And he was like, don't, don't [03:50.160 --> 03:54.800] write a plugin. Just use the REST API. Everything you need is right there. I kept trying to write [03:54.880 --> 04:00.280] a plugin though, because I don't know. I don't know why. So I wasted a lot of time, realized [04:00.280 --> 04:04.520] writing Kismet plugins is hard. There are good reasons to do that. If you're adding a new file [04:04.520 --> 04:09.200] or a new, I don't know, you want to add something to the packet chain or whatever, for everything [04:09.200 --> 04:14.800] else, use the REST API. So it's kind of a lesson learned. Trust Dragorn. Use simple APIs when [04:14.800 --> 04:21.580] possible. Anyway, it ended up working. This is what Shootout looks like. I'm not going to go too [04:21.580 --> 04:27.460] much into what Shootout does and what it looks like, but I am going to talk about how it works [04:27.460 --> 04:32.600] because it's very relevant to the talk. I think, I think the village people are going to go into [04:32.600 --> 04:42.780] how to use it and what it does later. So basically, Shootout, you give it a list of data [04:42.780 --> 04:49.480] sources for Kismet. And using the REST API, it grabs packet counters for all of them and kind [04:49.480 --> 04:54.580] of compares them. So when you first start up, obviously it's got to connect. It's got to make [04:54.580 --> 04:58.360] sure that the interfaces that you told it to look for are actually there. And if they're not, [04:59.140 --> 05:04.240] well, if they're there but they're not enabled, it will enable them for you. And then it just [05:04.240 --> 05:09.220] goes into a loop forever and ever and grabs the device JSON and looks at the packet counters and [05:09.220 --> 05:15.260] compares the received packet count for each device. So it tunes them all to the same channel. [05:15.260 --> 05:21.920] So the idea is given some initial offset, they should all be seeing the same number of packets. [05:22.500 --> 05:30.320] So it gives you a super non-scientific rough idea of monitor mode performance for Wi-Fi cards. [05:30.680 --> 05:38.900] Anyway, the way you make all that stuff happen is using the REST API endpoints. So they have kind [05:38.900 --> 05:45.640] of a general format where, you know, it's some URI, right? So you're going like HTTP and then [05:45.640 --> 05:51.800] usually local host, 2501. And then some topic. I just kind of made that word up there. Like either [05:51.800 --> 05:57.860] system or devices or something else. Criteria, I also kind of made that up and shoved that in [05:57.860 --> 06:04.220] there. Like some of the topics have filters. So you can filter by a key or by a MAC address. We'll [06:04.220 --> 06:09.900] talk about that more later. And then a serialization. So the primary serialization you're [06:09.900 --> 06:14.920] going to use, if you're interested in this, is probably JSON. There's also EKJSON, which I have [06:14.920 --> 06:19.620] no idea what that is. It's some big data thing. I don't do that. And then there's PrettyJSON, [06:19.620 --> 06:27.560] which, you know, makes the JSON have new lines in it. So some examples. I mentioned the system [06:27.560 --> 06:31.920] status. There's actually a ton of data in there. Like if you run it on a laptop, it gives you [06:31.920 --> 06:37.020] like your battery life. It gives you CPU temperature. For this crazy laptop, it actually [06:37.020 --> 06:44.320] tells me the temperature of my internal Wi-Fi card. It's cool. The device status, basically [06:44.320 --> 06:48.060] there's two ways to look at that. You can see it by key or by MAC. Again, we'll get into it [06:48.060 --> 06:53.380] later. But, you know, you give Kismet via this URI a MAC address and it gives you back all the [06:53.380 --> 06:59.760] JSON. Data source status is actually how we do shootout. So that's pulling for each. Each data [06:59.760 --> 07:06.440] source has its own big JSON object and you get that back each time you access this URI. Location [07:06.440 --> 07:10.960] is something that I haven't messed with too much, but I'm really interested in. So you may already [07:10.960 --> 07:17.940] know that Kismet can take data from GPSD, can take NMEA 0183 data over the network or something [07:17.940 --> 07:25.060] like that. If you don't have one of those fancy things, you can also tell Kismet where it is by [07:25.060 --> 07:31.940] sending a command to that location endpoint, which is sort of neat. So if you were running Kismet in [07:31.940 --> 07:36.780] some place where you don't have normal GPS, so you have some fancy GPS that doesn't do that stuff, [07:36.780 --> 07:42.120] you could still do this integration entirely using the REST API without having to write crazy [07:42.120 --> 07:50.800] fancy code. And then, like I said, my favorite thing, getting PCAP. The device JSON is like 400 [07:50.800 --> 07:59.720] lines or something if you shove it in a sublime and pretty JSON it. It's a lot of data. So there's [07:59.800 --> 08:05.580] a lot of detail in there. The thing that I'm usually looking at is received signal strength. [08:05.580 --> 08:09.440] He just calls it last signal, I think. But there's tons of stuff in there. There's [08:09.440 --> 08:14.800] round robin databases for signal strength and packet counts and all kinds of stuff. [08:15.820 --> 08:22.220] So here's an example. I'm going to move this a little bit. So this is one of the tools that I [08:22.220 --> 08:30.600] kind of whipped up just to show what the REST API can do. So I'm running Kismet. And you guys, [08:31.160 --> 08:38.220] you ever see one of these? This is an ESP8266. It's like an IOT microcontroller. It's basically [08:38.220 --> 08:44.740] an Arduino with Wi-Fi. This one happens to be serving up an access point called WCTF underscore [08:44.740 --> 08:51.640] king of the hill, which may have significance to those people. Interestingly, there was so many [08:51.640 --> 08:54.940] people connected to this fake king of the hill that it was crashing. So hopefully it's not [08:54.940 --> 09:01.820] crashed right now. Anyway, the KRRSSI tool uses the Kismet REST API based on this Mac. So I'm [09:01.820 --> 09:08.060] feeding it. Wow, that's small. You'll have to trust me. I'm giving it a Mac address. And then [09:08.060 --> 09:13.740] basically it's just showing you this shitty little bar of received signal strength. So if I go over [09:13.740 --> 09:18.240] here or cover this up or something, you should see the signal strength go down. And if I get closer [09:18.240 --> 09:27.820] to my little TP link fancy card, it's turning red, which is, you know, more signal. So that's how [09:27.820 --> 09:32.360] that works. Really simple tool. It's just polling the REST API at 1 hertz using that device [09:32.360 --> 09:41.440] endpoint. Another slightly more sophisticated version of the RSSI tool does the same thing, but [09:41.440 --> 09:47.060] instead of using... so that last tool used a scalar field in the REST API. So it's just telling you [09:47.060 --> 09:51.900] this is instantaneously the last signal strength that I saw for the Mac address you just gave me. [09:52.060 --> 09:57.680] There's also a round robin database in there that gives you 60 seconds worth of that data, [09:58.160 --> 10:04.080] obviously with one second interval. So I made a tool to use that instead. And it gives you this [10:04.080 --> 10:08.860] pretty little graph. And you can kind of... you probably can't read it, but on the screen it's [10:08.860 --> 10:15.100] showing you the big vector that... these programs are written in Python and there's a cool JSON [10:15.100 --> 10:19.920] library for Python that basically turns raw JSON into Python dictionaries, which is super [10:19.920 --> 10:24.460] convenient. So I'm just dumping out that dictionary there to show you the received signal [10:24.460 --> 10:31.200] strength. And then I'm feeding that to pi plot, which is, you know, doing fancy things. So again, [10:31.200 --> 10:34.900] it's kind of harder to see... oh, yeah, okay, it's not harder to see. The signal got stronger [10:34.900 --> 10:43.960] when I made it close. So anyway, that's KR, RSSI and RSSI2. So those use the REST API to look at [10:43.960 --> 10:51.780] signal strength. But there's more. So in addition to just kind of passively polling for stuff, [10:51.780 --> 10:59.320] you can send commands to Kismet over the same API. Again, it's all in JSON. So two examples up [10:59.320 --> 11:04.260] here. You can add a data source. Remember how I was talking about with shootout? Like it would [11:04.260 --> 11:10.640] be a pain if I wanted to test, say, 30 Wi-Fi cards, and for each one of those I had to test, [11:10.640 --> 11:15.380] I needed to go into the web UI and click on that source to enable it. That would get annoying. [11:15.620 --> 11:23.080] So shootout adds them all for you. So basically this add data source or this add source.CMD [11:23.080 --> 11:28.620] endpoint takes an interface Kismet knows about, turns it into a data source. And then the set [11:28.620 --> 11:34.100] channel endpoint, similarly, you know, sets a channel. You can also set hopping and hop rate [11:34.100 --> 11:38.540] and other things like that. Like I said before, it's really well documented. Google it. [11:40.640 --> 11:45.660] Here's an example that actually kind of solves a practical problem. So if, actually, I'll show [11:45.660 --> 11:51.480] you this first. Have any of you, hopefully you're using Kismet, have any of you seen this issue [11:51.480 --> 11:56.520] where, like, you go into the web GUI and you click lock and then you click on a channel and it, [11:56.520 --> 11:59.680] like, doesn't actually do that? It, like, lights up for a second and then goes back to whatever [11:59.680 --> 12:09.280] channel it was on. Super annoying. So to overcome that, I use the REST API to make a little program [12:09.280 --> 12:15.800] that lets me change to a different channel. So right now I'm going to change TTUH is my little [12:15.800 --> 12:21.820] Wi-Fi adapter up here. I'm going to change it to channel 6. Cool. Done. I'm going to go back to 1 [12:21.820 --> 12:28.760] because that's where my fake king of the hill is. Anyway, that's really convenient if you're [12:28.760 --> 12:36.800] having that issue. And it's also exactly how shootout works. If those would be beneficial to [12:36.800 --> 12:42.300] you all, they're on my GitHub, it's there. If you don't feel like, I don't know, typing that out [12:42.300 --> 12:51.380] or something, just come ask me. So DragWorm put a lot of work into this. A feature like this, [12:51.380 --> 12:55.800] like, you would only add something like this if you were really thinking hard about how somebody [12:55.800 --> 13:04.840] would use this API. Field selection lets you limit the amount of JSON you get back. So I said [13:04.840 --> 13:09.480] before, and I kind of showed a little snippet of it, the JSON you get back from the Kismet REST [13:09.480 --> 13:17.680] API, like for a device, is like 400 lines. Serializing anything via some text-based mechanism [13:17.680 --> 13:24.840] like XML or JSON is hugely inefficient in terms of bandwidth. So field selection lets you tell [13:24.840 --> 13:31.540] Kismet, I want the device JSON, but I really only care about this one field. And you can do that by [13:31.540 --> 13:35.640] using a command, just like the command I showed you before, or you can actually just tack some [13:35.640 --> 13:42.620] stuff onto the URL to filter it. So when you use command-based selection, basically you just make [13:42.720 --> 13:46.660] a command that looks like this that has a fields property and you shove all the fields you want [13:46.660 --> 13:52.740] into an array and boom, that's it. Kismet gives you back what you want. When you do it via URI, [13:52.740 --> 13:57.240] that's probably really hard for you to read, but you can trust me that after device.json, [13:57.240 --> 14:02.240] there's a bunch of fields tacked onto the end. So they do the same thing, they're just slightly [14:02.240 --> 14:11.760] different. Right, PCAP. So the sort of powerful thing you can do with the REST API is this [14:11.760 --> 14:19.160] allpackets.pcapng. That is every packet that PCAP is, sorry, that Kismet is seeing, no matter how [14:19.160 --> 14:23.020] many sources you have. So you're going to get lots of packets, like if you're over there with [14:23.020 --> 14:29.400] 30 Wi-Fi cards and stuff. You can limit that to one data source, which I don't know why you [14:29.400 --> 14:35.380] would do that, but you can do it. And the really powerful thing is you can limit it by device. So [14:35.380 --> 14:42.480] I can tell Kismet, no matter how many devices I have, no matter how many data sources I have, I [14:42.480 --> 14:49.320] can tell it, I want the PCAP, but only from this thing. Which is incredibly powerful when you're [14:49.320 --> 14:55.520] playing that game and there's people with, you know, fake challenges and there's tons of Wi-Fi. [14:55.520 --> 14:58.200] Like if you were to open up that all packets over there, it would probably just crash [14:58.200 --> 15:04.580] Wireshark. There's too much. So anyway, before I get to that, I'll show you what that looks [15:04.580 --> 15:13.760] like. So hopefully this works. Instead of using Python, I'm just using curl right from the [15:13.760 --> 15:18.100] command line. So this is kind of a one liner. I'm logging into Kismet, I'm telling it I want [15:18.100 --> 15:24.260] devices by key. You can get that key from the web user interface. You can copy paste it. And [15:24.260 --> 15:29.620] then slash PCAP and slash the key again for some reason, .PCAPNG. And you can pipe that to [15:29.620 --> 15:37.940] Wireshark and tell it to read from standard input. And then magic happens. This is just the [15:37.940 --> 15:43.380] traffic from this little device right here, even though there's lots and lots of traffic. I [15:43.380 --> 15:46.460] keep pointing over there because that's where the game is happening and those guys are doing [15:46.460 --> 15:50.860] all kinds of crazy things, making more traffic. But Kismet filtered this for me, which is [15:50.860 --> 15:56.340] really cool. Especially if you're looking for that needle in a haystack. You're looking for [15:57.720 --> 16:04.960] one emitter in a sea of other emitters. This is a really powerful integration tool. No, I [16:04.960 --> 16:11.580] don't want to save it. I don't care. Okay. There are some advanced points, end points that [16:12.060 --> 16:15.520] honestly I haven't looked at that much, but I wanted to mention because they seem really cool [16:15.520 --> 16:21.460] to me. Views is kind of like a database view thing. I haven't used it, so I don't know how it [16:21.460 --> 16:27.720] works, but you can combine different sets of data and filter them by defining these views. [16:28.340 --> 16:31.860] Points of interest sounds kind of cool to me. There's a way you can send a command to that [16:31.860 --> 16:36.880] end point and tell it right now at this moment in time, something super interesting to me [16:36.880 --> 16:43.340] happened. So Kismet is logging all this stuff to an SQLite database, so you can go back in [16:43.340 --> 16:47.780] time after your post-event analysis or if you're up late in the hotel room trying to get more [16:47.780 --> 16:53.340] flags, you can go back and look and see, hey, what time did that thing that doesn't happen [16:53.340 --> 16:59.540] that often happen? And then Kismet DB. I mentioned PCAP. I don't have a demo for this, [16:59.540 --> 17:04.820] unfortunately, but another really powerful thing with Kismet REST API and PCAP is you can go [17:04.820 --> 17:12.220] back in time. So the curl kind of one-liner piping to Pyreshark, piping to Wireshark that I [17:12.220 --> 17:17.420] showed you is real-time data ingest for all sources for the filter selection that I [17:17.420 --> 17:24.160] picked. You can go back and you can tell Kismet I want all the PCAP between this date [17:24.160 --> 17:31.140] timestamp and this other date timestamp, which I also think is really cool. Again, like I [17:31.140 --> 17:36.500] said in the beginning, the reason I think this is interesting is because there's a lot of [17:36.500 --> 17:41.840] bad APIs out there. There's tons of bad code. There's tons of poorly documented code. [17:43.120 --> 17:46.940] This is not those things. It's really good and I think there's lots of opportunity to make [17:46.940 --> 17:53.440] new tools and to integrate Kismet with, you know, whatever kind of system you can dream up [17:53.440 --> 18:00.300] that cares about Wi-Fi. So that's it. That's my talk. Hope you guys get something out of [18:00.300 --> 18:03.560] that. Kismet is cool. Please use it. Thanks.