start	end	text
0	5920	And I would like to give a short introduction to my good friend Ted NoLastName here.
6900	12400	Ted's just some random dude who hangs out here and on our Discord. And I said,
12400	18760	man, I really want to reimplement this thing that Draghorn wrote for old Kismet in new Kismet,
18760	24640	but I suck at programming. So do you think maybe you could, like, anybody want to help?
24640	29840	And he's like, oh yeah, sure, I want to do that. And then he wrote the whole bloody thing and sent
29840	36220	it to me. And I'm like, hey, cool, this works great. Let's use this. So not only is he giving
36360	42120	a talk about that and some other fun stuff that he's done, we're using his tool that he wrote
42120	47360	because I begged for somebody, anybody to write it for our gear talk to talk about how we select
47360	55060	gear. So yeah, Kismet is an amazing tool and it's got an amazing REST interface and you can
55060	61020	apparently spend a few hours and make several really neat things. So listen to Ted, no last
61020	79800	name here. Hi. Hey, I'm Ted. I started doing wireless capture the flag with these guys about a
79800	88260	year ago at B-Sides DC and I kind of have been addicted ever since. So yeah, I'm Ted, this is my
88260	96860	first time at DEF CON, be gentle, but it's not a Ted talk. If you don't already know what Kismet
96860	103980	is and you're in this room, you should Google it. Kismet is good. Kismet happens to have a REST
103980	111680	API. I think technically it's a REST-like API, but whatever. It has an interface that you can
111680	118140	use over HTTP to get lots of really cool information out of it. The reason I wanted to give
118140	124200	this talk was because I like integrating things and making tools and this is a really powerful
124200	130060	way to do that for Wi-Fi and other types of stuff that Kismet does. So I figured people here
130060	140240	might be into it. Like I said, it's an HTTP interface. You make requests to it. So you can ask
140240	145080	it for its status about the host system. You can ask for status about specific devices and it
145080	152220	gives you back lots and lots of JSON, which you can then parse and do fun things with. My
152220	157860	favorite feature of the REST API is actually that you can get PCAP over HTTP. I'll talk about
157860	163720	that later, but extremely powerful integration opportunities there. And it's also, for an
163720	168720	open source project, it is extremely well documented. The guy that writes Kismet,
168720	175520	Dragorn, obviously put a lot of time into documenting this REST API, which makes it a lot
175520	185380	easier to use. Like ZeroChaos said, I kind of, my introduction to the Kismet REST API was the
185380	191100	program shootout that he wrote that needed to be refactored because they changed the, Kismet
191100	196620	changed significantly a couple of years ago. And I kind of just wanted to learn new things and
196620	201960	help this group out, because like I said, I'm addicted to WCTF. So I'm actually taking time
201960	210780	away from it to tell you this. Right. So this was kind of a funny story. So I'm a C++ programmer.
210780	216560	And so when this idea, when the shootout needed to be refactored, it was written in Ruby and
217720	222560	nobody programs in Ruby. So I wanted to rewrite it in C++ and make a Kismet plugin because that
222560	226960	was like kind of the old school way of doing it. So I went into Dragorn's Discord and talked to
226960	230160	him and it was like, you know, what's the best way to do this? And he was like, don't, don't
230160	234800	write a plugin. Just use the REST API. Everything you need is right there. I kept trying to write
234880	240280	a plugin though, because I don't know. I don't know why. So I wasted a lot of time, realized
240280	244520	writing Kismet plugins is hard. There are good reasons to do that. If you're adding a new file
244520	249200	or a new, I don't know, you want to add something to the packet chain or whatever, for everything
249200	254800	else, use the REST API. So it's kind of a lesson learned. Trust Dragorn. Use simple APIs when
254800	261580	possible. Anyway, it ended up working. This is what Shootout looks like. I'm not going to go too
261580	267460	much into what Shootout does and what it looks like, but I am going to talk about how it works
267460	272600	because it's very relevant to the talk. I think, I think the village people are going to go into
272600	282780	how to use it and what it does later. So basically, Shootout, you give it a list of data
282780	289480	sources for Kismet. And using the REST API, it grabs packet counters for all of them and kind
289480	294580	of compares them. So when you first start up, obviously it's got to connect. It's got to make
294580	298360	sure that the interfaces that you told it to look for are actually there. And if they're not,
299140	304240	well, if they're there but they're not enabled, it will enable them for you. And then it just
304240	309220	goes into a loop forever and ever and grabs the device JSON and looks at the packet counters and
309220	315260	compares the received packet count for each device. So it tunes them all to the same channel.
315260	321920	So the idea is given some initial offset, they should all be seeing the same number of packets.
322500	330320	So it gives you a super non-scientific rough idea of monitor mode performance for Wi-Fi cards.
330680	338900	Anyway, the way you make all that stuff happen is using the REST API endpoints. So they have kind
338900	345640	of a general format where, you know, it's some URI, right? So you're going like HTTP and then
345640	351800	usually local host, 2501. And then some topic. I just kind of made that word up there. Like either
351800	357860	system or devices or something else. Criteria, I also kind of made that up and shoved that in
357860	364220	there. Like some of the topics have filters. So you can filter by a key or by a MAC address. We'll
364220	369900	talk about that more later. And then a serialization. So the primary serialization you're
369900	374920	going to use, if you're interested in this, is probably JSON. There's also EKJSON, which I have
374920	379620	no idea what that is. It's some big data thing. I don't do that. And then there's PrettyJSON,
379620	387560	which, you know, makes the JSON have new lines in it. So some examples. I mentioned the system
387560	391920	status. There's actually a ton of data in there. Like if you run it on a laptop, it gives you
391920	397020	like your battery life. It gives you CPU temperature. For this crazy laptop, it actually
397020	404320	tells me the temperature of my internal Wi-Fi card. It's cool. The device status, basically
404320	408060	there's two ways to look at that. You can see it by key or by MAC. Again, we'll get into it
408060	413380	later. But, you know, you give Kismet via this URI a MAC address and it gives you back all the
413380	419760	JSON. Data source status is actually how we do shootout. So that's pulling for each. Each data
419760	426440	source has its own big JSON object and you get that back each time you access this URI. Location
426440	430960	is something that I haven't messed with too much, but I'm really interested in. So you may already
430960	437940	know that Kismet can take data from GPSD, can take NMEA 0183 data over the network or something
437940	445060	like that. If you don't have one of those fancy things, you can also tell Kismet where it is by
445060	451940	sending a command to that location endpoint, which is sort of neat. So if you were running Kismet in
451940	456780	some place where you don't have normal GPS, so you have some fancy GPS that doesn't do that stuff,
456780	462120	you could still do this integration entirely using the REST API without having to write crazy
462120	470800	fancy code. And then, like I said, my favorite thing, getting PCAP. The device JSON is like 400
470800	479720	lines or something if you shove it in a sublime and pretty JSON it. It's a lot of data. So there's
479800	485580	a lot of detail in there. The thing that I'm usually looking at is received signal strength.
485580	489440	He just calls it last signal, I think. But there's tons of stuff in there. There's
489440	494800	round robin databases for signal strength and packet counts and all kinds of stuff.
495820	502220	So here's an example. I'm going to move this a little bit. So this is one of the tools that I
502220	510600	kind of whipped up just to show what the REST API can do. So I'm running Kismet. And you guys,
511160	518220	you ever see one of these? This is an ESP8266. It's like an IOT microcontroller. It's basically
518220	524740	an Arduino with Wi-Fi. This one happens to be serving up an access point called WCTF underscore
524740	531640	king of the hill, which may have significance to those people. Interestingly, there was so many
531640	534940	people connected to this fake king of the hill that it was crashing. So hopefully it's not
534940	541820	crashed right now. Anyway, the KRRSSI tool uses the Kismet REST API based on this Mac. So I'm
541820	548060	feeding it. Wow, that's small. You'll have to trust me. I'm giving it a Mac address. And then
548060	553740	basically it's just showing you this shitty little bar of received signal strength. So if I go over
553740	558240	here or cover this up or something, you should see the signal strength go down. And if I get closer
558240	567820	to my little TP link fancy card, it's turning red, which is, you know, more signal. So that's how
567820	572360	that works. Really simple tool. It's just polling the REST API at 1 hertz using that device
572360	581440	endpoint. Another slightly more sophisticated version of the RSSI tool does the same thing, but
581440	587060	instead of using... so that last tool used a scalar field in the REST API. So it's just telling you
587060	591900	this is instantaneously the last signal strength that I saw for the Mac address you just gave me.
592060	597680	There's also a round robin database in there that gives you 60 seconds worth of that data,
598160	604080	obviously with one second interval. So I made a tool to use that instead. And it gives you this
604080	608860	pretty little graph. And you can kind of... you probably can't read it, but on the screen it's
608860	615100	showing you the big vector that... these programs are written in Python and there's a cool JSON
615100	619920	library for Python that basically turns raw JSON into Python dictionaries, which is super
619920	624460	convenient. So I'm just dumping out that dictionary there to show you the received signal
624460	631200	strength. And then I'm feeding that to pi plot, which is, you know, doing fancy things. So again,
631200	634900	it's kind of harder to see... oh, yeah, okay, it's not harder to see. The signal got stronger
634900	643960	when I made it close. So anyway, that's KR, RSSI and RSSI2. So those use the REST API to look at
643960	651780	signal strength. But there's more. So in addition to just kind of passively polling for stuff,
651780	659320	you can send commands to Kismet over the same API. Again, it's all in JSON. So two examples up
659320	664260	here. You can add a data source. Remember how I was talking about with shootout? Like it would
664260	670640	be a pain if I wanted to test, say, 30 Wi-Fi cards, and for each one of those I had to test,
670640	675380	I needed to go into the web UI and click on that source to enable it. That would get annoying.
675620	683080	So shootout adds them all for you. So basically this add data source or this add source.CMD
683080	688620	endpoint takes an interface Kismet knows about, turns it into a data source. And then the set
688620	694100	channel endpoint, similarly, you know, sets a channel. You can also set hopping and hop rate
694100	698540	and other things like that. Like I said before, it's really well documented. Google it.
700640	705660	Here's an example that actually kind of solves a practical problem. So if, actually, I'll show
705660	711480	you this first. Have any of you, hopefully you're using Kismet, have any of you seen this issue
711480	716520	where, like, you go into the web GUI and you click lock and then you click on a channel and it,
716520	719680	like, doesn't actually do that? It, like, lights up for a second and then goes back to whatever
719680	729280	channel it was on. Super annoying. So to overcome that, I use the REST API to make a little program
729280	735800	that lets me change to a different channel. So right now I'm going to change TTUH is my little
735800	741820	Wi-Fi adapter up here. I'm going to change it to channel 6. Cool. Done. I'm going to go back to 1
741820	748760	because that's where my fake king of the hill is. Anyway, that's really convenient if you're
748760	756800	having that issue. And it's also exactly how shootout works. If those would be beneficial to
756800	762300	you all, they're on my GitHub, it's there. If you don't feel like, I don't know, typing that out
762300	771380	or something, just come ask me. So DragWorm put a lot of work into this. A feature like this,
771380	775800	like, you would only add something like this if you were really thinking hard about how somebody
775800	784840	would use this API. Field selection lets you limit the amount of JSON you get back. So I said
784840	789480	before, and I kind of showed a little snippet of it, the JSON you get back from the Kismet REST
789480	797680	API, like for a device, is like 400 lines. Serializing anything via some text-based mechanism
797680	804840	like XML or JSON is hugely inefficient in terms of bandwidth. So field selection lets you tell
804840	811540	Kismet, I want the device JSON, but I really only care about this one field. And you can do that by
811540	815640	using a command, just like the command I showed you before, or you can actually just tack some
815640	822620	stuff onto the URL to filter it. So when you use command-based selection, basically you just make
822720	826660	a command that looks like this that has a fields property and you shove all the fields you want
826660	832740	into an array and boom, that's it. Kismet gives you back what you want. When you do it via URI,
832740	837240	that's probably really hard for you to read, but you can trust me that after device.json,
837240	842240	there's a bunch of fields tacked onto the end. So they do the same thing, they're just slightly
842240	851760	different. Right, PCAP. So the sort of powerful thing you can do with the REST API is this
851760	859160	allpackets.pcapng. That is every packet that PCAP is, sorry, that Kismet is seeing, no matter how
859160	863020	many sources you have. So you're going to get lots of packets, like if you're over there with
863020	869400	30 Wi-Fi cards and stuff. You can limit that to one data source, which I don't know why you
869400	875380	would do that, but you can do it. And the really powerful thing is you can limit it by device. So
875380	882480	I can tell Kismet, no matter how many devices I have, no matter how many data sources I have, I
882480	889320	can tell it, I want the PCAP, but only from this thing. Which is incredibly powerful when you're
889320	895520	playing that game and there's people with, you know, fake challenges and there's tons of Wi-Fi.
895520	898200	Like if you were to open up that all packets over there, it would probably just crash
898200	904580	Wireshark. There's too much. So anyway, before I get to that, I'll show you what that looks
904580	913760	like. So hopefully this works. Instead of using Python, I'm just using curl right from the
913760	918100	command line. So this is kind of a one liner. I'm logging into Kismet, I'm telling it I want
918100	924260	devices by key. You can get that key from the web user interface. You can copy paste it. And
924260	929620	then slash PCAP and slash the key again for some reason, .PCAPNG. And you can pipe that to
929620	937940	Wireshark and tell it to read from standard input. And then magic happens. This is just the
937940	943380	traffic from this little device right here, even though there's lots and lots of traffic. I
943380	946460	keep pointing over there because that's where the game is happening and those guys are doing
946460	950860	all kinds of crazy things, making more traffic. But Kismet filtered this for me, which is
950860	956340	really cool. Especially if you're looking for that needle in a haystack. You're looking for
957720	964960	one emitter in a sea of other emitters. This is a really powerful integration tool. No, I
964960	971580	don't want to save it. I don't care. Okay. There are some advanced points, end points that
972060	975520	honestly I haven't looked at that much, but I wanted to mention because they seem really cool
975520	981460	to me. Views is kind of like a database view thing. I haven't used it, so I don't know how it
981460	987720	works, but you can combine different sets of data and filter them by defining these views.
988340	991860	Points of interest sounds kind of cool to me. There's a way you can send a command to that
991860	996880	end point and tell it right now at this moment in time, something super interesting to me
996880	1003340	happened. So Kismet is logging all this stuff to an SQLite database, so you can go back in
1003340	1007780	time after your post-event analysis or if you're up late in the hotel room trying to get more
1007780	1013340	flags, you can go back and look and see, hey, what time did that thing that doesn't happen
1013340	1019540	that often happen? And then Kismet DB. I mentioned PCAP. I don't have a demo for this,
1019540	1024820	unfortunately, but another really powerful thing with Kismet REST API and PCAP is you can go
1024820	1032220	back in time. So the curl kind of one-liner piping to Pyreshark, piping to Wireshark that I
1032220	1037420	showed you is real-time data ingest for all sources for the filter selection that I
1037420	1044160	picked. You can go back and you can tell Kismet I want all the PCAP between this date
1044160	1051140	timestamp and this other date timestamp, which I also think is really cool. Again, like I
1051140	1056500	said in the beginning, the reason I think this is interesting is because there's a lot of
1056500	1061840	bad APIs out there. There's tons of bad code. There's tons of poorly documented code.
1063120	1066940	This is not those things. It's really good and I think there's lots of opportunity to make
1066940	1073440	new tools and to integrate Kismet with, you know, whatever kind of system you can dream up
1073440	1080300	that cares about Wi-Fi. So that's it. That's my talk. Hope you guys get something out of
1080300	1083560	that. Kismet is cool. Please use it. Thanks.
