WEBVTT

00:09.760 --> 00:11.860
Hello, my name is Dominic Spill.

00:12.080 --> 00:13.520
This is Mike Kershaw.

00:14.240 --> 00:16.380
This is going to be quite a quick talk.

00:17.020 --> 00:22.240
We submitted this as a 20-minute talk and they've given us an hour, so you've all got a coffee break in like 25 minutes' time.

00:23.600 --> 00:27.860
This is an idea we came up with a couple of... you've been talking about it for about 18 months?

00:27.860 --> 00:33.000
Yeah, I complained about it for a long time, and then Dominic finally went and did something about it.

00:33.420 --> 00:34.240
Where are the speakers?

00:34.440 --> 00:35.540
Over there.

00:35.540 --> 00:37.780
Alright, then everyone shut the hell up!

00:40.280 --> 00:44.020
Go outside if you want to talk, otherwise you can stand here and listen to me.

00:44.640 --> 00:46.440
I would recommend going outside.

00:47.180 --> 00:49.160
So, yeah, carry on.

00:49.160 --> 00:58.880
So, yeah, I came up with the idea probably about 18 months, 2 years ago, and then didn't bother doing anything with it until finally I asked Dominic enough to actually write the code.

00:58.920 --> 01:00.720
This is what we call the Kershaw method.

01:01.180 --> 01:01.980
Delegation.

01:01.980 --> 01:12.780
Yeah, so basically we want to solve driver issues with all sorts of devices, but in this case specifically 802.11.

01:13.420 --> 01:21.100
USB devices such as this one, or all the ones that you can see being used around CTF and things like that.

01:21.100 --> 01:27.780
And we want to try and solve some problems and open up some platforms to, you know, other platforms to Kismet and Aircrack and that sort of stuff.

01:29.360 --> 01:35.620
I'm Dominic Spill, I work for Great Scott Gadgets writing open source software and working on some hardware stuff.

01:35.620 --> 01:42.460
I'm really bad at hardware, so this project is based on me trying to avoid hardware by writing it in software.

01:45.220 --> 01:49.080
I'm Mike Kershaw, I do Kismet and I work for Blackphone.

01:51.100 --> 01:52.300
There we go.

01:54.760 --> 01:57.920
In case anyone missed that, Mike Kershaw wrote Kismet.

01:57.940 --> 02:01.460
Loads of times people don't recognize who he is, so this is what his face looks like.

02:01.700 --> 02:06.380
You owe him five bucks if you've ever been using Kismet and found it useful.

02:06.620 --> 02:07.920
You should give him five dollars.

02:08.200 --> 02:09.820
You don't have to give me five dollars.

02:09.820 --> 02:10.940
Make it rain.

02:11.580 --> 02:14.820
Okay, so 802.11 monitor mode.

02:14.820 --> 02:16.040
This is probably more your thing?

02:16.040 --> 02:16.680
Sure.

02:17.620 --> 02:20.300
So it requires drivers that support monitor mode obviously.

02:20.300 --> 02:21.880
Works really well in Linux.

02:22.440 --> 02:24.500
It doesn't work really well in anything else.

02:24.540 --> 02:28.800
OSX, there's some stuff that works with USB cards.

02:28.800 --> 02:34.980
There's some ways sometimes to put the internal card in monitor mode, but Apple keeps changing that and breaking it.

02:35.300 --> 02:37.920
There's nothing really good in Android.

02:38.060 --> 02:39.540
There's some solutions on Windows.

02:39.540 --> 02:41.760
They tend to be commercial and about 900 bucks.

02:42.400 --> 02:45.480
So, you know, how do we deal with these problems?

02:47.880 --> 02:51.520
So this led me to have a question a couple years ago about Android.

02:51.520 --> 02:54.520
Which is, can you write a device driver in Java?

02:54.520 --> 02:55.860
Or is that just stupid?

02:55.860 --> 02:57.280
This question is not an or.

02:57.280 --> 02:59.400
The answer is yes to both.

03:00.520 --> 03:02.680
So I did it the dumb way.

03:02.680 --> 03:04.100
You can see Android PCAP.

03:04.100 --> 03:05.200
It's in the Google market.

03:05.200 --> 03:08.080
There's links to the get code on the Kismet site.

03:08.360 --> 03:10.640
You can port kernel drivers to Java.

03:10.640 --> 03:13.400
The Android Java layer is basically libUSB.

03:13.400 --> 03:20.840
You just have to convert all the kernel USB functions and do them in Java.

03:20.840 --> 03:22.400
It's freaking terrible.

03:22.440 --> 03:24.780
I would not recommend doing this.

03:26.340 --> 03:29.040
It involves a lot of things like that.

03:32.560 --> 03:37.520
Some fun things that you discover doing this is Wi-Fi cards do really weird shit.

03:37.860 --> 03:51.820
The 8187, for example, if anyone does hardware and is aware of the SPI protocol, the 80211 or the 8187 drivers do SPI over USB per packet.

03:52.460 --> 03:54.580
Bit high, clock high, USB right.

03:54.580 --> 03:55.880
Clock low, USB right.

03:55.880 --> 03:57.960
Bit low, clock high, USB right.

03:57.960 --> 03:58.780
Repeat.

03:58.920 --> 04:01.000
It's insane.

04:01.220 --> 04:06.560
Timing can definitely be an issue trying to configure these things from an Android app with no extra permissions.

04:06.560 --> 04:09.300
That really doesn't expect to be doing this nonsense.

04:09.920 --> 04:13.280
The other thing about this is we've already got a working implementation.

04:13.600 --> 04:22.700
It seems like a really stupid thing to go and take an existing implementation and just try and copy the whole thing, bugs and all, into another language just to run a different system.

04:23.020 --> 04:29.620
You should be able to compile the code for both or something like that, but it's the limitations of Android and most of Android.

04:29.620 --> 04:37.640
In this case, I was targeting Android, but the same thing would apply to using random cards that work great in Linux on Windows or on OS X.

04:37.640 --> 04:44.940
So we figured we might as well leverage the fact that they all work in Linux and try and make them work for other platforms through that.

04:45.060 --> 04:48.700
Yeah, so the problem is, you know, doing it the dumb way doesn't scale.

04:48.840 --> 04:53.480
So that code supports the 8187 with a couple of the main tuner chips and a couple of the EEPROMs on it.

04:53.480 --> 04:55.140
It doesn't work with anything else.

04:55.680 --> 04:59.560
Anything else is going to be, you know, 5 to 20,000 lines of code.

05:00.120 --> 05:05.160
Plus you have to figure out how to do the firmware loading, which is another 20,000 lines of code for most of the modern cards.

05:06.140 --> 05:09.460
For every card out there and every new chipset that comes out.

05:09.460 --> 05:10.100
No thanks.

05:10.300 --> 05:11.780
I'm not doing that.

05:12.000 --> 05:12.520
Right.

05:12.740 --> 05:15.380
And, you know, our time is relatively expensive.

05:15.620 --> 05:24.340
So we were thinking if we could buy a little bit of hardware to fix this, then potentially that would be worth more than the time it would take to port the driver.

05:24.600 --> 05:29.160
So we found some hardware we liked, and we'll come on to that in a minute.

05:29.160 --> 05:33.000
But basically we're going to use a piece of hardware and build an abstraction layer.

05:33.000 --> 05:35.200
So there's already a library called LawCon.

05:35.200 --> 05:37.580
It's by Mike and Josh Wright.

05:38.060 --> 05:40.800
It's called... it's loss of radio connectivity.

05:41.140 --> 05:45.460
And what it does is abstract away the differences between those cards.

05:45.460 --> 05:49.360
So you don't have to worry about which driver you're talking to, how it works.

05:49.360 --> 05:52.440
You just say, open me an interface, give me monitor mode, something like that.

05:52.440 --> 05:55.360
And it abstracts all that away as long as you're running on Linux.

05:55.360 --> 05:59.280
So that doesn't solve our problem for Android or for Windows or anything like that.

05:59.280 --> 06:10.860
It only solves it if you want to simplify the code inside of Kismet or Aircrack or something like that to save those programs having to worry about the differences between drivers.

06:11.280 --> 06:16.680
So this seems like a pretty good abstraction layer, and if we're going to build a new one, we may as well build it on top of that.

06:19.740 --> 06:24.420
A lot of people are using USB devices for this, so we may as well carry on using USB.

06:24.420 --> 06:26.140
It's incredibly prolific.

06:26.260 --> 06:27.200
It's everywhere.

06:27.200 --> 06:28.340
These things are cheap.

06:28.340 --> 06:29.900
This was like 30 bucks.

06:30.200 --> 06:35.780
So we just decided to extend the USB interface and modify it slightly on the fly.

06:35.780 --> 06:41.440
So what we need is a USB man-in-the-middle device to do this, and luckily I wrote one.

06:41.860 --> 06:51.440
It's called USB proxy, and I gave a talk about it at B-Sides a couple of days ago, where I was doing things with USB mass storage like flash drives.

06:51.440 --> 07:00.680
In this case, we're doing very similar things, using exactly the same library to proxy USB traffic between the two sides of our piece of hardware.

07:01.480 --> 07:03.980
It's a C++ framework.

07:04.180 --> 07:07.360
It connects using libusb to a device.

07:07.360 --> 07:27.360
It uses GadgetFS, which is part of the Linux kernel, to present a USB device as a file system, and then we're using this Lorkon library to attach ourselves to the Athros chip in this case, but whatever, it's abstracted, and we're going to mirror those calls across USB.

07:28.880 --> 07:31.620
So this is kind of what USB proxy looks like.

07:31.620 --> 07:34.280
This is my opportunity to pimp my own project.

07:34.560 --> 07:38.740
We just have a device on one side, a host on the other, and we can relay traffic across the middle.

07:38.740 --> 07:41.880
We can inject packets, and we can remove them into the USB layer.

07:41.880 --> 07:46.060
For this project, all we're doing is that center line across the middle of the slide.

07:46.100 --> 07:47.860
We're not injecting anything.

07:47.860 --> 07:49.160
We're not filtering any packets.

07:49.380 --> 07:52.380
We're just relaying stuff back and forwards.

07:54.420 --> 07:59.080
And the hardware we're using is the BeagleBone Black, and I'm going to touch it and hope everything doesn't stop working.

07:59.160 --> 08:00.440
It looks like this.

08:00.700 --> 08:06.980
It is a single board computer from a company called CircuitCode, but they use a TI chip.

08:07.240 --> 08:09.840
It's kind of TI's answer to the Pi, I guess.

08:09.840 --> 08:11.780
It's kind of like a Raspberry Pi.

08:11.780 --> 08:14.880
It's got more capabilities in some regards.

08:15.020 --> 08:16.560
It's got less capabilities in others.

08:16.560 --> 08:18.600
But it's basically equivalent to a Pi.

08:18.600 --> 08:20.120
It's about the same price, about $40.

08:20.740 --> 08:21.980
It's a bit faster.

08:21.980 --> 08:22.960
It's got some really nice features.

08:22.960 --> 08:24.260
I prefer it to the Pi.

08:24.260 --> 08:26.360
I find the Pi relatively useless for what I want to do.

08:26.520 --> 08:33.080
But the one key thing it's got that the Pi doesn't have, and that's what makes this application work, is a USB device port.

08:33.080 --> 08:44.000
So from user space Linux code on the BeagleBone, I can write a device in software, plug it into another host, and it appears as a USB device.

08:44.120 --> 08:49.160
So they use this to appear as a file system, they use it to appear as a network device, and things like that.

08:49.160 --> 08:56.420
In our case, we're going to appear as our custom USB device to provide 802.11 monitor mode and things like that.

08:57.900 --> 08:59.860
Oh, and I like it because it's open source hardware.

08:59.860 --> 09:00.680
I'd forgotten about that.

09:00.680 --> 09:05.400
You can go and download the schematics and the getters and stuff like that.

09:07.920 --> 09:09.220
I hadn't seen you there.

09:15.160 --> 09:17.960
And we're using GadgetFS, as I said before.

09:18.040 --> 09:23.340
All this does is it just lets us write to a file system as if they're USB endpoints.

09:23.340 --> 09:29.340
Did anyone see the USB talk yesterday by Jesse Michael and Mickey something?

09:29.620 --> 09:32.320
They were basically talking about the structure of USB.

09:32.460 --> 09:36.880
You don't really need to worry about this at all because we've written the code for you.

09:40.580 --> 09:42.020
You've modified my slides.

09:42.020 --> 09:42.700
I have.

09:44.420 --> 09:53.520
We just kind of write to a file system as if it's an endpoint so we can receive data by reading and writing files, which means that I don't have to care about how USB works.

09:53.520 --> 09:56.640
I don't have to care about checksums and packet headers and any of that stuff.

09:56.740 --> 09:58.740
I can just go, here's some data.

09:59.220 --> 10:03.840
So on one hand, I'm talking to a radio library that gives me raw bytes.

10:03.840 --> 10:09.880
And on the other hand, I've got a file, and I can just write those raw bytes straight to that file, and they'll appear on the USB interface at the other end.

10:09.880 --> 10:12.020
So it's actually really nice and simple.

10:13.040 --> 10:15.080
And then look at the radio library we're using.

10:15.120 --> 10:21.600
And this abstracts away anything that we'd have to care about to do with different chipsets and different devices.

10:21.600 --> 10:32.300
As long as Linux supports it, and it has Montemo and raw frame injection and that sort of stuff, this will let us just talk to it with a common API.

10:32.300 --> 10:37.480
So we don't have to worry about, is it an Athros chip, is it an RTL something, something, something.

10:37.480 --> 10:45.420
Yeah, and it also lets us, you know, right now all the main drivers in Linux support RadioTap, but it's always possible that's going to change and whatnot.

10:45.420 --> 10:49.280
And Lortan abstracts out those headers so we can get the signal levels.

10:49.280 --> 10:54.160
And then we'll send the raw headers on to the other device, but they won't have to necessarily pay attention to it.

10:54.160 --> 10:59.520
And we even split it up so that if you're writing code to receive packets, you don't even have to care about the header format.

10:59.520 --> 11:03.460
It just tells you, skip this many bytes in and you get the raw header full of the packet.

11:03.460 --> 11:07.520
You don't have to care if it's PPI or RadioTap or Prism 2 or whatever the hell.

11:10.580 --> 11:12.640
So this is the point at which I was going to do a demo.

11:13.680 --> 11:16.040
It should be noted that it doesn't work.

11:16.840 --> 11:19.620
The word may in this sentence is incorrect.

11:19.620 --> 11:20.820
It doesn't work.

11:21.600 --> 11:24.360
But I'm going to at least show you kind of what happens.

11:24.360 --> 11:26.780
There's some very simple settings that we can do.

11:26.780 --> 11:32.780
It turns out, actually, we're capturing the radio data, capturing the packets on the BeagleBone.

11:32.840 --> 11:43.500
And as we pull them across the BeagleBone to write them out to the file system to send them over, the code segfaults because I'm terrible at pointer arithmetic.

11:43.560 --> 11:46.300
And this morning was not the time to rewrite that bit of code.

11:46.780 --> 11:49.280
So I'm really sorry, but I can't show packet snipping.

11:49.280 --> 11:51.280
But I will try to show it doing something.

11:51.960 --> 11:53.540
It's conceptually functional.

11:53.540 --> 11:55.280
It's just practically screwed up.

11:55.280 --> 11:55.640
All

12:00.460 --> 12:03.120
right.

12:05.400 --> 12:10.360
Well, this projector is not entirely on the right screen, is it?

12:11.980 --> 12:14.700
Let me increase my font size for you.

12:18.900 --> 12:21.220
And, yeah.

12:25.520 --> 12:26.720
Sorry.

12:27.780 --> 12:30.660
I may not be as prepared as other speakers.

12:30.660 --> 12:31.840
Ugh.

12:46.300 --> 12:46.820
So...

12:47.360 --> 12:50.780
Oh, you should also note that the code doesn't exit cleanly.

12:50.780 --> 12:54.940
So I can only do this once, and then I have to play around, like, killing things.

12:54.940 --> 12:55.480
Okay.

12:55.480 --> 12:59.560
So I just wrote a quick tool called USB, man in the middle.

12:59.580 --> 13:03.880
And it's going to use our specific device proxy here.

13:03.880 --> 13:07.500
It's called deviceproxy.11.

13:07.720 --> 13:11.660
And the config file literally just tells it which interface to use.

13:11.660 --> 13:15.800
There's only one on this system anyway, but it just tells it, use WLAN0.

13:17.100 --> 13:17.500
So...

13:17.500 --> 13:18.560
Huh.

13:18.580 --> 13:19.700
Let's hope this works.

13:20.340 --> 13:23.480
So what you can see, I'm going to wander and point...

13:23.480 --> 13:25.360
No, that's going to scratch the video, isn't it?

13:25.360 --> 13:27.060
I'm going to point with a mouse pointer.

13:27.640 --> 13:31.460
So what you can see is we opened up a USB device.

13:32.800 --> 13:36.120
It's using the Mac 802.11 driver.

13:36.160 --> 13:37.580
It's got WLAN0.

13:37.580 --> 13:39.920
And then it's just...

13:39.920 --> 13:43.760
The host tries to set the configuration on my USB device.

13:44.000 --> 13:45.700
Which doesn't do anything.

13:45.780 --> 13:48.060
And then we start sniffing packets.

13:48.220 --> 13:51.720
And here, we've sniffed a 197-byte header.

13:51.800 --> 13:53.060
Is that true?

13:53.440 --> 13:58.060
Okay, we've sniffed a 197-byte header with no data, which sounds like a beacon.

13:58.480 --> 14:01.780
And then we've written it to the other side.

14:02.240 --> 14:05.020
And... let's see if this does anything.

14:11.990 --> 14:13.190
No, it doesn't.

14:13.490 --> 14:16.890
So what we try and do is we then copy that over to the other side.

14:16.890 --> 14:18.610
To write over to the host system.

14:18.730 --> 14:20.910
And that's when the code just sort of dies.

14:20.910 --> 14:21.730
And nothing happens.

14:21.730 --> 14:22.950
And nothing to see here.

14:22.950 --> 14:26.430
But what we are able to do is do things like set the time out on the device.

14:26.430 --> 14:27.030
And read it back.

14:27.030 --> 14:30.290
And open the WLAN0 on capture interface.

14:30.430 --> 14:32.810
And we're that far away.

14:32.970 --> 14:36.630
If our talk had been an hour later, we probably still wouldn't have any working code.

14:36.630 --> 14:38.710
But we would have been a little bit closer.

14:38.710 --> 14:44.570
And that's pretty much the thing we've been working on for the past, well, four hours.

14:46.550 --> 14:48.270
And we think it's kind of a fun concept.

14:48.270 --> 14:50.990
And so we want to take the opportunity to just kind of talk to people about it.

14:50.990 --> 14:52.870
We're really sorry it doesn't work yet.

14:53.710 --> 14:56.090
But we did manage to hook it up to an Android tablet.

14:57.270 --> 15:01.870
And again, if I use the mouse pointer wherever it's gone.

15:01.870 --> 15:02.710
There it is.

15:02.790 --> 15:05.370
You can see it's connected to a .11 proxy.

15:06.790 --> 15:11.230
And in the logs, it's picking up stuff coming off the device.

15:11.810 --> 15:16.010
There's no way we can hook our Android tablet to the projector to show you this working.

15:16.190 --> 15:18.730
But, you know, it's got channel hopping enabled.

15:18.730 --> 15:21.150
And it can read the functionality from the wireless device.

15:21.150 --> 15:24.130
And we can report that to Android PCAP.

15:24.290 --> 15:26.810
And then we can start capturing packets.

15:26.810 --> 15:28.790
And then we can upload them to...

15:30.130 --> 15:31.750
Anything you can share to.

15:31.750 --> 15:33.970
You can upload it to CloudShark and get a live decode that way.

15:33.970 --> 15:36.390
Or we can copy it over to a host and rumble our shark.

15:36.390 --> 15:40.290
Or you can copy it to a host and throw it into aircraft or whatever you want to do.

15:40.290 --> 15:48.550
Another key part of this is that the same code that makes it work on Android means it'll work on Windows with a little USB the same way the UberTooth does.

15:48.550 --> 15:51.950
It'll work on Mac the same way that the UberTooth does.

15:52.070 --> 15:58.970
So we've taken it from porting 10,000 lines of code per random Wi-Fi card driver to...

15:59.930 --> 16:00.930
Well, here you go.

16:00.930 --> 16:10.650
Yeah, the amount of code needed to talk USB on Android, and that includes all the class-wrapper crap to plug into the Android PCAP GUI that I have, is 250 lines of code.

16:10.650 --> 16:14.250
Yeah, so we've dropped to a factor of...

16:14.250 --> 16:16.090
We'll try that sentence again.

16:16.150 --> 16:18.230
We've dropped the size of the code by a factor of 10.

16:18.230 --> 16:19.070
More than that.

16:19.070 --> 16:20.090
And more than that.

16:20.170 --> 16:23.170
And just for this one file.

16:23.170 --> 16:29.110
And that one interface will cover anything that supports... any Wi-Fi driver that's supported on Linux.

16:29.110 --> 16:32.550
So it's not just, oh, we've got a new device and it uses less code.

16:32.550 --> 16:35.350
We've got a new device and it covers all the existing devices.

16:35.690 --> 16:39.530
And once this code works, which is really soon...

16:39.530 --> 16:48.270
Once this code works, all of the supported Linux HL2.11 devices will work on Android.

16:48.270 --> 16:51.790
And someone can write some libUSB code for Windows and it'll work on Windows.

16:51.790 --> 16:54.990
And it just becomes a much, much easier way to do it.

16:54.990 --> 16:59.010
And the only thing that it costs is $40 for the BeagleByBlack.

16:59.010 --> 17:00.130
If you can get hold of one.

17:01.290 --> 17:03.030
We're also looking at porting it to...

17:03.030 --> 17:04.910
I mean, the code is generic.

17:04.910 --> 17:07.070
It's written for... targeted to Linux.

17:07.150 --> 17:12.690
So if you find another piece of embedded hardware with a USB device port on it, it'll work for that as well.

17:12.690 --> 17:14.370
So there's an Olmec's Lime.

17:15.050 --> 17:17.070
And I'm trying to remember some of the others.

17:17.150 --> 17:19.870
There are a whole bunch of different boards.

17:19.870 --> 17:22.250
And they're all in the, like, under $50 range.

17:22.250 --> 17:28.590
And so one of them, paired with a Wi-Fi device, will enable you to use Android or Windows or OS X.

17:28.750 --> 17:30.650
And I think that's mostly our project.

17:30.890 --> 17:33.010
So I want to thank Josh Wright and Mike Lussman.

17:33.270 --> 17:36.230
Because Josh Wright helped you write the Lorca library.

17:36.330 --> 17:41.110
And Mike Lussman continues to pay me, even though I work on things that have nothing to do with making any money.

17:41.510 --> 17:43.030
So thank you, Mike Lussman.

17:43.030 --> 17:43.610
Thank you.

17:55.500 --> 17:56.260
That's fine.

18:00.300 --> 18:01.760
I'm going to run down to you in a second.

