And I would like to give a short introduction to my good friend Ted NoLastName here. Ted's just some random dude who hangs out here and on our Discord. 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. So do you think maybe you could, like, anybody want to help? And he's like, oh yeah, sure, I want to do that. And then he wrote the whole bloody thing and sent it to me. And I'm like, hey, cool, this works great. Let's use this. 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. 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. So listen to Ted, no last name here. Hi. Hey, I'm Ted. 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. So yeah, I'm Ted, this is my first time at DEF CON, be gentle, but it's not a Ted talk. If you don't already know what Kismet is and you're in this room, you should Google it. Kismet is good. Kismet happens to have a REST API. I think technically it's a REST-like API, but whatever. It has an interface that you can use over HTTP to get lots of really cool information out of it. 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. So I figured people here might be into it. Like I said, it's an HTTP interface. You make requests to it. So you can ask it for its status about the host system. 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. My favorite feature of the REST API is actually that you can get PCAP over HTTP. I'll talk about that later, but extremely powerful integration opportunities there. And it's also, for an open source project, it is extremely well documented. 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. 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. And I kind of just wanted to learn new things and help this group out, because like I said, I'm addicted to WCTF. So I'm actually taking time away from it to tell you this. Right. So this was kind of a funny story. So I'm a C++ programmer. And so when this idea, when the shootout needed to be refactored, it was written in Ruby and nobody programs in Ruby. 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. 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? And he was like, don't, don't write a plugin. Just use the REST API. Everything you need is right there. I kept trying to write a plugin though, because I don't know. I don't know why. So I wasted a lot of time, realized writing Kismet plugins is hard. There are good reasons to do that. 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. So it's kind of a lesson learned. Trust Dragorn. Use simple APIs when possible. Anyway, it ended up working. This is what Shootout looks like. 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. I think, I think the village people are going to go into how to use it and what it does later. So basically, Shootout, you give it a list of data sources for Kismet. And using the REST API, it grabs packet counters for all of them and kind of compares them. So when you first start up, obviously it's got to connect. It's got to make sure that the interfaces that you told it to look for are actually there. And if they're not, well, if they're there but they're not enabled, it will enable them for you. 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. So it tunes them all to the same channel. So the idea is given some initial offset, they should all be seeing the same number of packets. So it gives you a super non-scientific rough idea of monitor mode performance for Wi-Fi cards. Anyway, the way you make all that stuff happen is using the REST API endpoints. So they have kind of a general format where, you know, it's some URI, right? So you're going like HTTP and then usually local host, 2501. And then some topic. I just kind of made that word up there. Like either system or devices or something else. Criteria, I also kind of made that up and shoved that in there. Like some of the topics have filters. So you can filter by a key or by a MAC address. We'll talk about that more later. And then a serialization. So the primary serialization you're going to use, if you're interested in this, is probably JSON. There's also EKJSON, which I have no idea what that is. It's some big data thing. I don't do that. And then there's PrettyJSON, which, you know, makes the JSON have new lines in it. So some examples. I mentioned the system status. There's actually a ton of data in there. Like if you run it on a laptop, it gives you like your battery life. It gives you CPU temperature. For this crazy laptop, it actually tells me the temperature of my internal Wi-Fi card. It's cool. The device status, basically there's two ways to look at that. You can see it by key or by MAC. Again, we'll get into it later. But, you know, you give Kismet via this URI a MAC address and it gives you back all the JSON. Data source status is actually how we do shootout. So that's pulling for each. Each data source has its own big JSON object and you get that back each time you access this URI. Location is something that I haven't messed with too much, but I'm really interested in. So you may already know that Kismet can take data from GPSD, can take NMEA 0183 data over the network or something like that. 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. 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. And then, like I said, my favorite thing, getting PCAP. The device JSON is like 400 lines or something if you shove it in a sublime and pretty JSON it. It's a lot of data. So there's a lot of detail in there. The thing that I'm usually looking at is received signal strength. He just calls it last signal, I think. But there's tons of stuff in there. There's round robin databases for signal strength and packet counts and all kinds of stuff. So here's an example. I'm going to move this a little bit. So this is one of the tools that I kind of whipped up just to show what the REST API can do. So I'm running Kismet. And you guys, you ever see one of these? This is an ESP8266. It's like an IOT microcontroller. It's basically an Arduino with Wi-Fi. This one happens to be serving up an access point called WCTF underscore king of the hill, which may have significance to those people. Interestingly, there was so many people connected to this fake king of the hill that it was crashing. So hopefully it's not crashed right now. Anyway, the KRRSSI tool uses the Kismet REST API based on this Mac. So I'm feeding it. Wow, that's small. You'll have to trust me. I'm giving it a Mac address. And then basically it's just showing you this shitty little bar of received signal strength. So if I go over here or cover this up or something, you should see the signal strength go down. And if I get closer to my little TP link fancy card, it's turning red, which is, you know, more signal. So that's how that works. Really simple tool. It's just polling the REST API at 1 hertz using that device endpoint. 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. So it's just telling you this is instantaneously the last signal strength that I saw for the Mac address you just gave me. There's also a round robin database in there that gives you 60 seconds worth of that data, obviously with one second interval. So I made a tool to use that instead. And it gives you this pretty little graph. 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. So I'm just dumping out that dictionary there to show you the received signal strength. And then I'm feeding that to pi plot, which is, you know, doing fancy things. So again, it's kind of harder to see... oh, yeah, okay, it's not harder to see. The signal got stronger when I made it close. So anyway, that's KR, RSSI and RSSI2. So those use the REST API to look at signal strength. But there's more. So in addition to just kind of passively polling for stuff, you can send commands to Kismet over the same API. Again, it's all in JSON. So two examples up here. You can add a data source. Remember how I was talking about with shootout? 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. That would get annoying. So shootout adds them all for you. So basically this add data source or this add source.CMD endpoint takes an interface Kismet knows about, turns it into a data source. And then the set channel endpoint, similarly, you know, sets a channel. You can also set hopping and hop rate and other things like that. Like I said before, it's really well documented. Google it. Here's an example that actually kind of solves a practical problem. So if, actually, I'll show you this first. 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? It, like, lights up for a second and then goes back to whatever channel it was on. Super annoying. So to overcome that, I use the REST API to make a little program that lets me change to a different channel. So right now I'm going to change TTUH is my little Wi-Fi adapter up here. I'm going to change it to channel 6. Cool. Done. I'm going to go back to 1 because that's where my fake king of the hill is. Anyway, that's really convenient if you're having that issue. And it's also exactly how shootout works. If those would be beneficial to you all, they're on my GitHub, it's there. If you don't feel like, I don't know, typing that out or something, just come ask me. So DragWorm put a lot of work into this. 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. Field selection lets you limit the amount of JSON you get back. 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. Serializing anything via some text-based mechanism like XML or JSON is hugely inefficient in terms of bandwidth. So field selection lets you tell Kismet, I want the device JSON, but I really only care about this one field. 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. 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. Kismet gives you back what you want. 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. So they do the same thing, they're just slightly different. Right, PCAP. So the sort of powerful thing you can do with the REST API is this allpackets.pcapng. That is every packet that PCAP is, sorry, that Kismet is seeing, no matter how many sources you have. So you're going to get lots of packets, like if you're over there with 30 Wi-Fi cards and stuff. You can limit that to one data source, which I don't know why you would do that, but you can do it. And the really powerful thing is you can limit it by device. 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. 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. Like if you were to open up that all packets over there, it would probably just crash Wireshark. There's too much. So anyway, before I get to that, I'll show you what that looks like. So hopefully this works. Instead of using Python, I'm just using curl right from the command line. So this is kind of a one liner. I'm logging into Kismet, I'm telling it I want devices by key. You can get that key from the web user interface. You can copy paste it. And then slash PCAP and slash the key again for some reason, .PCAPNG. And you can pipe that to Wireshark and tell it to read from standard input. And then magic happens. This is just the traffic from this little device right here, even though there's lots and lots of traffic. 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. But Kismet filtered this for me, which is really cool. Especially if you're looking for that needle in a haystack. You're looking for one emitter in a sea of other emitters. This is a really powerful integration tool. No, I don't want to save it. I don't care. Okay. 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. Views is kind of like a database view thing. 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. Points of interest sounds kind of cool to me. 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. 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? And then Kismet DB. I mentioned PCAP. 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. 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. 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. 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. There's tons of bad code. There's tons of poorly documented code. This is not those things. 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. So that's it. That's my talk. Hope you guys get something out of that. Kismet is cool. Please use it. Thanks.