WEBVTT

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:11.160
Ted's just some random dude who hangs out here and on our Discord.

00:11.260 --> 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.

00:21.000 --> 00:24.640
So do you think maybe you could, like, anybody want to help?

00:24.640 --> 00:27.380
And he's like, oh yeah, sure, I want to do that.

00:27.380 --> 00:30.320
And then he wrote the whole bloody thing and sent it to me.

00:30.320 --> 00:33.420
And I'm like, hey, cool, this works great.

00:33.500 --> 00:34.900
Let's use this.

00:34.900 --> 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.

00:48.340 --> 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.

00:59.060 --> 01:02.080
So listen to Ted, no last name here.

01:08.000 --> 01:09.160
Hi.

01:10.300 --> 01:11.840
Hey, I'm Ted.

01:14.400 --> 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.

01:26.020 --> 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.

01:35.280 --> 01:39.420
If you don't already know what Kismet is and you're in this room, you should Google it.

01:39.420 --> 01:40.520
Kismet is good.

01:42.660 --> 01:44.800
Kismet happens to have a REST API.

01:46.300 --> 01:49.860
I think technically it's a REST-like API, but whatever.

01:50.280 --> 01:55.960
It has an interface that you can use over HTTP to get lots of really cool information out of it.

01:56.700 --> 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.

02:08.720 --> 02:11.340
So I figured people here might be into it.

02:13.340 --> 02:16.240
Like I said, it's an HTTP interface.

02:16.460 --> 02:18.080
You make requests to it.

02:18.080 --> 02:22.640
So you can ask it for its status about the host system.

02:22.640 --> 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.

02:31.740 --> 02:37.420
My favorite feature of the REST API is actually that you can get PCAP over HTTP.

02:37.420 --> 02:42.600
I'll talk about that later, but extremely powerful integration opportunities there.

02:42.660 --> 02:47.400
And it's also, for an open source project, it is extremely well documented.

02:47.400 --> 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.

02:58.680 --> 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.

03:14.360 --> 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.

03:19.880 --> 03:23.940
So I'm actually taking time away from it to tell you this.

03:25.700 --> 03:26.200
Right.

03:26.200 --> 03:27.600
So this was kind of a funny story.

03:27.600 --> 03:30.780
So I'm a C++ programmer.

03:30.780 --> 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.

03:39.080 --> 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.

03:44.960 --> 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?

03:48.980 --> 03:50.940
And he was like, don't, don't write a plugin.

03:51.020 --> 03:52.280
Just use the REST API.

03:52.280 --> 03:53.600
Everything you need is right there.

03:53.940 --> 03:57.280
I kept trying to write a plugin though, because I don't know.

03:57.280 --> 03:58.120
I don't know why.

03:58.640 --> 04:01.940
So I wasted a lot of time, realized writing Kismet plugins is hard.

04:01.940 --> 04:03.440
There are good reasons to do that.

04:03.440 --> 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.

04:10.580 --> 04:12.180
So it's kind of a lesson learned.

04:12.360 --> 04:13.460
Trust Dragorn.

04:13.700 --> 04:15.520
Use simple APIs when possible.

04:16.620 --> 04:18.740
Anyway, it ended up working.

04:19.160 --> 04:20.820
This is what Shootout looks like.

04:20.820 --> 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.

04:29.840 --> 04:34.460
I think, I think the village people are going to go into how to use it and what it does later.

04:37.000 --> 04:44.160
So basically, Shootout, you give it a list of data sources for Kismet.

04:44.420 --> 04:50.620
And using the REST API, it grabs packet counters for all of them and kind of compares them.

04:50.700 --> 04:53.560
So when you first start up, obviously it's got to connect.

04:53.840 --> 04:57.300
It's got to make sure that the interfaces that you told it to look for are actually there.

04:57.300 --> 05:02.540
And if they're not, well, if they're there but they're not enabled, it will enable them for you.

05:03.720 --> 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.

05:13.620 --> 05:15.260
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:37.440
Anyway, the way you make all that stuff happen is using the REST API endpoints.

05:38.160 --> 05:43.520
So they have kind of a general format where, you know, it's some URI, right?

05:43.520 --> 05:48.200
So you're going like HTTP and then usually local host, 2501.

05:48.640 --> 05:49.680
And then some topic.

05:49.680 --> 05:51.340
I just kind of made that word up there.

05:51.400 --> 05:54.340
Like either system or devices or something else.

05:55.400 --> 05:58.340
Criteria, I also kind of made that up and shoved that in there.

05:58.340 --> 06:00.720
Like some of the topics have filters.

06:00.880 --> 06:04.140
So you can filter by a key or by a MAC address.

06:04.140 --> 06:05.420
We'll talk about that more later.

06:05.640 --> 06:06.980
And then a serialization.

06:06.980 --> 06:12.240
So the primary serialization you're going to use, if you're interested in this, is probably JSON.

06:12.400 --> 06:15.680
There's also EKJSON, which I have no idea what that is.

06:15.680 --> 06:16.720
It's some big data thing.

06:16.720 --> 06:18.000
I don't do that.

06:18.420 --> 06:23.340
And then there's PrettyJSON, which, you know, makes the JSON have new lines in it.

06:24.940 --> 06:26.600
So some examples.

06:26.660 --> 06:28.400
I mentioned the system status.

06:28.820 --> 06:30.340
There's actually a ton of data in there.

06:30.340 --> 06:33.160
Like if you run it on a laptop, it gives you like your battery life.

06:33.160 --> 06:35.400
It gives you CPU temperature.

06:35.480 --> 06:39.240
For this crazy laptop, it actually tells me the temperature of my internal Wi-Fi card.

06:39.240 --> 06:39.800
It's cool.

06:41.120 --> 06:45.940
The device status, basically there's two ways to look at that.

06:45.940 --> 06:47.460
You can see it by key or by MAC.

06:47.460 --> 06:48.560
Again, we'll get into it later.

06:48.560 --> 06:54.020
But, you know, you give Kismet via this URI a MAC address and it gives you back all the JSON.

06:54.440 --> 06:56.760
Data source status is actually how we do shootout.

06:56.760 --> 06:58.600
So that's pulling for each.

06:59.160 --> 07:05.020
Each data source has its own big JSON object and you get that back each time you access this URI.

07:06.040 --> 07:09.180
Location is something that I haven't messed with too much, but I'm really interested in.

07:09.180 --> 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.

07:20.280 --> 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.

07:29.920 --> 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.

07:43.620 --> 07:46.520
And then, like I said, my favorite thing, getting PCAP.

07:47.940 --> 07:57.140
The device JSON is like 400 lines or something if you shove it in a sublime and pretty JSON it.

07:58.000 --> 07:59.180
It's a lot of data.

07:59.180 --> 08:01.140
So there's a lot of detail in there.

08:01.980 --> 08:05.580
The thing that I'm usually looking at is received signal strength.

08:05.580 --> 08:07.940
He just calls it last signal, I think.

08:08.080 --> 08:09.360
But there's tons of stuff in there.

08:09.360 --> 08:14.800
There's round robin databases for signal strength and packet counts and all kinds of stuff.

08:15.820 --> 08:17.240
So here's an example.

08:17.880 --> 08:19.260
I'm going to move this a little bit.

08:20.400 --> 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.

08:26.560 --> 08:27.900
So I'm running Kismet.

08:28.360 --> 08:32.440
And you guys, you ever see one of these?

08:32.440 --> 08:35.300
This is an ESP8266.

08:35.300 --> 08:37.380
It's like an IOT microcontroller.

08:37.800 --> 08:39.600
It's basically an Arduino with Wi-Fi.

08:39.980 --> 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.

08:49.640 --> 08:54.400
Interestingly, there was so many people connected to this fake king of the hill that it was crashing.

08:54.400 --> 08:56.060
So hopefully it's not crashed right now.

08:56.200 --> 09:01.680
Anyway, the KRRSSI tool uses the Kismet REST API based on this Mac.

09:01.680 --> 09:02.840
So I'm feeding it.

09:03.400 --> 09:04.560
Wow, that's small.

09:05.060 --> 09:05.840
You'll have to trust me.

09:05.840 --> 09:07.260
I'm giving it a Mac address.

09:07.740 --> 09:12.860
And then basically it's just showing you this shitty little bar of received signal strength.

09:12.860 --> 09:17.040
So if I go over here or cover this up or something, you should see the signal strength go down.

09:17.320 --> 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.

09:26.700 --> 09:28.320
So that's how that works.

09:28.320 --> 09:29.280
Really simple tool.

09:29.280 --> 09:33.180
It's just polling the REST API at 1 hertz using that device endpoint.

09:36.240 --> 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.

09:46.140 --> 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.

09:52.060 --> 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.

09:59.620 --> 10:03.000
So I made a tool to use that instead.

10:03.520 --> 10:05.180
And it gives you this pretty little graph.

10:05.880 --> 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.

10:21.340 --> 10:25.160
So I'm just dumping out that dictionary there to show you the received signal strength.

10:25.360 --> 10:29.680
And then I'm feeding that to pi plot, which is, you know, doing fancy things.

10:29.920 --> 10:33.960
So again, it's kind of harder to see... oh, yeah, okay, it's not harder to see.

10:34.020 --> 10:36.120
The signal got stronger when I made it close.

10:36.540 --> 10:40.820
So anyway, that's KR, RSSI and RSSI2.

10:41.380 --> 10:44.900
So those use the REST API to look at signal strength.

10:45.980 --> 10:47.040
But there's more.

10:47.260 --> 10:55.060
So in addition to just kind of passively polling for stuff, you can send commands to Kismet over the same API.

10:55.760 --> 10:57.200
Again, it's all in JSON.

10:57.440 --> 10:59.880
So two examples up here.

11:00.120 --> 11:01.280
You can add a data source.

11:01.280 --> 11:03.080
Remember how I was talking about with shootout?

11:03.840 --> 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.

11:14.280 --> 11:15.380
That would get annoying.

11:15.620 --> 11:18.420
So shootout adds them all for you.

11:18.420 --> 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.

11:27.700 --> 11:32.460
And then the set channel endpoint, similarly, you know, sets a channel.

11:32.460 --> 11:35.440
You can also set hopping and hop rate and other things like that.

11:35.820 --> 11:37.720
Like I said before, it's really well documented.

11:37.720 --> 11:38.540
Google it.

11:40.640 --> 11:43.900
Here's an example that actually kind of solves a practical problem.

11:43.900 --> 11:46.520
So if, actually, I'll show you this first.

11:46.640 --> 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?

11:57.600 --> 12:00.740
It, like, lights up for a second and then goes back to whatever channel it was on.

12:00.740 --> 12:01.540
Super annoying.

12:01.540 --> 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.

12:11.860 --> 12:17.020
So right now I'm going to change TTUH is my little Wi-Fi adapter up here.

12:17.020 --> 12:18.500
I'm going to change it to channel 6.

12:18.500 --> 12:18.880
Cool.

12:18.880 --> 12:19.480
Done.

12:20.760 --> 12:24.940
I'm going to go back to 1 because that's where my fake king of the hill is.

12:25.860 --> 12:29.880
Anyway, that's really convenient if you're having that issue.

12:29.920 --> 12:32.360
And it's also exactly how shootout works.

12:34.760 --> 12:38.840
If those would be beneficial to you all, they're on my GitHub, it's there.

12:40.060 --> 12:43.780
If you don't feel like, I don't know, typing that out or something, just come ask me.

12:45.900 --> 12:48.960
So DragWorm put a lot of work into this.

12:49.880 --> 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.

12:57.480 --> 13:04.260
Field selection lets you limit the amount of JSON you get back.

13:04.260 --> 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.

13:12.740 --> 13:21.620
Serializing anything via some text-based mechanism like XML or JSON is hugely inefficient in terms of bandwidth.

13:22.200 --> 13:29.340
So field selection lets you tell Kismet, I want the device JSON, but I really only care about this one field.

13:30.320 --> 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.

13:38.400 --> 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.

13:48.860 --> 13:50.220
Kismet gives you back what you want.

13:51.200 --> 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.

13:59.380 --> 14:03.000
So they do the same thing, they're just slightly different.

14:04.440 --> 14:05.480
Right, PCAP.

14:05.480 --> 14:13.520
So the sort of powerful thing you can do with the REST API is this allpackets.pcapng.

14:13.720 --> 14:20.260
That is every packet that PCAP is, sorry, that Kismet is seeing, no matter how many sources you have.

14:20.260 --> 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.

14:25.920 --> 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.

14:30.940 --> 14:34.480
And the really powerful thing is you can limit it by device.

14:35.200 --> 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.

14:46.500 --> 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.

14:55.520 --> 14:58.860
Like if you were to open up that all packets over there, it would probably just crash Wireshark.

14:58.860 --> 15:00.200
There's too much.

15:00.600 --> 15:05.260
So anyway, before I get to that, I'll show you what that looks like.

15:07.100 --> 15:08.980
So hopefully this works.

15:11.220 --> 15:14.280
Instead of using Python, I'm just using curl right from the command line.

15:14.280 --> 15:15.620
So this is kind of a one liner.

15:15.620 --> 15:19.580
I'm logging into Kismet, I'm telling it I want devices by key.

15:20.280 --> 15:22.420
You can get that key from the web user interface.

15:22.420 --> 15:23.560
You can copy paste it.

15:24.240 --> 15:28.660
And then slash PCAP and slash the key again for some reason, .PCAPNG.

15:28.820 --> 15:32.780
And you can pipe that to Wireshark and tell it to read from standard input.

15:33.480 --> 15:35.280
And then magic happens.

15:35.500 --> 15:43.340
This is just the traffic from this little device right here, even though there's lots and lots of traffic.

15:43.340 --> 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.

15:49.500 --> 15:51.860
But Kismet filtered this for me, which is really cool.

15:52.760 --> 15:55.700
Especially if you're looking for that needle in a haystack.

15:55.700 --> 15:59.820
You're looking for one emitter in a sea of other emitters.

15:59.820 --> 16:03.000
This is a really powerful integration tool.

16:04.640 --> 16:05.620
No, I don't want to save it.

16:05.620 --> 16:06.300
I don't care.

16:07.300 --> 16:07.800
Okay.

16:08.800 --> 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.

16:17.460 --> 16:20.000
Views is kind of like a database view thing.

16:20.100 --> 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.

16:28.340 --> 16:30.220
Points of interest sounds kind of cool to me.

16:30.220 --> 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.

16:38.140 --> 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?

16:55.880 --> 16:56.880
And then Kismet DB.

16:56.880 --> 16:58.080
I mentioned PCAP.

16:58.320 --> 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.

17:06.220 --> 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.

17:19.480 --> 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.

17:30.380 --> 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.

17:38.120 --> 17:39.480
There's tons of bad code.

17:39.740 --> 17:41.840
There's tons of poorly documented code.

17:43.120 --> 17:44.740
This is not those things.

17:44.740 --> 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.

17:55.720 --> 17:56.860
So that's it.

17:56.860 --> 17:57.820
That's my talk.

17:59.080 --> 18:00.560
Hope you guys get something out of that.

18:00.560 --> 18:01.340
Kismet is cool.

18:01.340 --> 18:02.280
Please use it.

18:02.800 --> 18:03.560
Thanks.

