start	end	text
9760	16380	Hello, my name is Dominic Spill. This is Mike Kershaw. This is going to be quite a quick talk.
17020	22240	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.
23600	27860	This is an idea we came up with a couple of... you've been talking about it for about 18 months?
27860	33000	Yeah, I complained about it for a long time, and then Dominic finally went and did something about it.
33420	34240	Where are the speakers?
34440	35540	Over there.
35540	37780	Alright, then everyone shut the hell up!
40280	44020	Go outside if you want to talk, otherwise you can stand here and listen to me.
44640	46440	I would recommend going outside.
47180	49160	So, yeah, carry on.
49160	55260	So, yeah, I came up with the idea probably about 18 months, 2 years ago, and then didn't bother doing anything with it
55260	58880	until finally I asked Dominic enough to actually write the code.
58920	60720	This is what we call the Kershaw method.
61180	61980	Delegation.
61980	72780	Yeah, so basically we want to solve driver issues with all sorts of devices, but in this case specifically 802.11.
73420	81100	USB devices such as this one, or all the ones that you can see being used around CTF and things like that.
81100	87780	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.
89360	95620	I'm Dominic Spill, I work for Great Scott Gadgets writing open source software and working on some hardware stuff.
95620	102460	I'm really bad at hardware, so this project is based on me trying to avoid hardware by writing it in software.
105220	109080	I'm Mike Kershaw, I do Kismet and I work for Blackphone.
111100	112300	There we go.
114760	117920	In case anyone missed that, Mike Kershaw wrote Kismet.
117940	121460	Loads of times people don't recognize who he is, so this is what his face looks like.
121700	126380	You owe him five bucks if you've ever been using Kismet and found it useful.
126620	127920	You should give him five dollars.
128200	129820	You don't have to give me five dollars.
129820	130940	Make it rain.
131580	134820	Okay, so 802.11 monitor mode.
134820	136040	This is probably more your thing?
136040	136680	Sure.
137620	140300	So it requires drivers that support monitor mode obviously.
140300	141880	Works really well in Linux.
142440	144500	It doesn't work really well in anything else.
144540	148800	OSX, there's some stuff that works with USB cards.
148800	154980	There's some ways sometimes to put the internal card in monitor mode, but Apple keeps changing that and breaking it.
155300	157920	There's nothing really good in Android.
158060	159540	There's some solutions on Windows.
159540	161760	They tend to be commercial and about 900 bucks.
162400	165480	So, you know, how do we deal with these problems?
167880	171520	So this led me to have a question a couple years ago about Android.
171520	174520	Which is, can you write a device driver in Java?
174520	175860	Or is that just stupid?
175860	177280	This question is not an or.
177280	179400	The answer is yes to both.
180520	182680	So I did it the dumb way.
182680	184100	You can see Android PCAP.
184100	185200	It's in the Google market.
185200	188080	There's links to the get code on the Kismet site.
188360	190640	You can port kernel drivers to Java.
190640	193400	The Android Java layer is basically libUSB.
193400	200840	You just have to convert all the kernel USB functions and do them in Java.
200840	202400	It's freaking terrible.
202440	204780	I would not recommend doing this.
206340	209040	It involves a lot of things like that.
212560	217520	Some fun things that you discover doing this is Wi-Fi cards do really weird shit.
217860	223160	The 8187, for example, if anyone does hardware and is aware of the SPI protocol,
224840	231820	the 80211 or the 8187 drivers do SPI over USB per packet.
232460	234580	Bit high, clock high, USB right.
234580	235880	Clock low, USB right.
235880	237960	Bit low, clock high, USB right.
237960	238780	Repeat.
238920	241000	It's insane.
241220	246560	Timing can definitely be an issue trying to configure these things from an Android app with no extra permissions.
246560	249300	That really doesn't expect to be doing this nonsense.
249920	253280	The other thing about this is we've already got a working implementation.
253600	262700	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.
263020	269620	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.
269620	277640	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.
277640	284940	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.
285060	288700	Yeah, so the problem is, you know, doing it the dumb way doesn't scale.
288840	293480	So that code supports the 8187 with a couple of the main tuner chips and a couple of the EEPROMs on it.
293480	295140	It doesn't work with anything else.
295680	299560	Anything else is going to be, you know, 5 to 20,000 lines of code.
300120	305160	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.
306140	309460	For every card out there and every new chipset that comes out.
309460	311780	No thanks. I'm not doing that.
312000	315380	Right. And, you know, our time is relatively expensive.
315620	324340	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.
324600	329160	So we found some hardware we liked, and we'll come on to that in a minute.
329160	333000	But basically we're going to use a piece of hardware and build an abstraction layer.
333000	337580	So there's already a library called LawCon. It's by Mike and Josh Wright.
338060	340800	It's called... it's loss of radio connectivity.
341140	345460	And what it does is abstract away the differences between those cards.
345460	349360	So you don't have to worry about which driver you're talking to, how it works.
349360	352440	You just say, open me an interface, give me monitor mode, something like that.
352440	355360	And it abstracts all that away as long as you're running on Linux.
355360	359280	So that doesn't solve our problem for Android or for Windows or anything like that.
359280	367500	It only solves it if you want to simplify the code inside of Kismet or Aircrack or something like that
367500	370860	to save those programs having to worry about the differences between drivers.
371280	376680	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.
379740	384420	A lot of people are using USB devices for this, so we may as well carry on using USB.
384420	387200	It's incredibly prolific. It's everywhere.
387200	389900	These things are cheap. This was like 30 bucks.
390200	395780	So we just decided to extend the USB interface and modify it slightly on the fly.
395780	401440	So what we need is a USB man-in-the-middle device to do this, and luckily I wrote one.
401860	407880	It's called USB proxy, and I gave a talk about it at B-Sides a couple of days ago,
407880	411440	where I was doing things with USB mass storage like flash drives.
411440	417940	In this case, we're doing very similar things, using exactly the same library to proxy USB traffic
417940	420680	between the two sides of our piece of hardware.
421480	427360	It's a C++ framework. It connects using libusb to a device.
427360	434220	It uses GadgetFS, which is part of the Linux kernel, to present a USB device as a file system,
434220	442200	and then we're using this Lorkon library to attach ourselves to the Athros chip in this case,
442200	447360	but whatever, it's abstracted, and we're going to mirror those calls across USB.
448880	454280	So this is kind of what USB proxy looks like. This is my opportunity to pimp my own project.
454560	458740	We just have a device on one side, a host on the other, and we can relay traffic across the middle.
458740	461880	We can inject packets, and we can remove them into the USB layer.
461880	466060	For this project, all we're doing is that center line across the middle of the slide.
466100	472380	We're not injecting anything. We're not filtering any packets. We're just relaying stuff back and forwards.
474420	479080	And the hardware we're using is the BeagleBone Black, and I'm going to touch it and hope everything doesn't stop working.
479160	486980	It looks like this. It is a single board computer from a company called CircuitCode, but they use a TI chip.
487240	489840	It's kind of TI's answer to the Pi, I guess.
489840	496560	It's kind of like a Raspberry Pi. It's got more capabilities in some regards. It's got less capabilities in others.
496560	498600	But it's basically equivalent to a Pi.
498600	502960	It's about the same price, about $40. It's a bit faster. It's got some really nice features.
502960	506360	I prefer it to the Pi. I find the Pi relatively useless for what I want to do.
506520	513080	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.
513080	524000	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.
524120	529160	So they use this to appear as a file system, they use it to appear as a network device, and things like that.
529160	536420	In our case, we're going to appear as our custom USB device to provide 802.11 monitor mode and things like that.
537900	540680	Oh, and I like it because it's open source hardware. I'd forgotten about that.
540680	545400	You can go and download the schematics and the getters and stuff like that.
547920	549220	I hadn't seen you there.
555160	563340	And we're using GadgetFS, as I said before. All this does is it just lets us write to a file system as if they're USB endpoints.
563340	569340	Did anyone see the USB talk yesterday by Jesse Michael and Mickey something?
569620	572320	They were basically talking about the structure of USB.
572460	576880	You don't really need to worry about this at all because we've written the code for you.
580580	582020	You've modified my slides.
582020	582700	I have.
584420	590960	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,
590960	596640	which means that I don't have to care about how USB works. I don't have to care about checksums and packet headers and any of that stuff.
596740	598740	I can just go, here's some data.
599220	603840	So on one hand, I'm talking to a radio library that gives me raw bytes.
603840	609880	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.
609880	612020	So it's actually really nice and simple.
613040	615080	And then look at the radio library we're using.
615120	621600	And this abstracts away anything that we'd have to care about to do with different chipsets and different devices.
621600	632300	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.
632300	637480	So we don't have to worry about, is it an Athros chip, is it an RTL something, something, something.
637480	645420	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.
645420	649280	And Lortan abstracts out those headers so we can get the signal levels.
649280	654160	And then we'll send the raw headers on to the other device, but they won't have to necessarily pay attention to it.
654160	659520	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.
659520	663460	It just tells you, skip this many bytes in and you get the raw header full of the packet.
663460	667520	You don't have to care if it's PPI or RadioTap or Prism 2 or whatever the hell.
670580	672640	So this is the point at which I was going to do a demo.
673680	676040	It should be noted that it doesn't work.
676840	680820	The word may in this sentence is incorrect. It doesn't work.
681600	684360	But I'm going to at least show you kind of what happens.
684360	686780	There's some very simple settings that we can do.
686780	692780	It turns out, actually, we're capturing the radio data, capturing the packets on the BeagleBone.
692840	703500	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.
703560	706300	And this morning was not the time to rewrite that bit of code.
706780	711280	So I'm really sorry, but I can't show packet snipping. But I will try to show it doing something.
711960	715280	It's conceptually functional. It's just practically screwed up.
715280	723120	All right.
725400	730360	Well, this projector is not entirely on the right screen, is it?
731980	734700	Let me increase my font size for you.
738900	741220	And, yeah.
745520	746720	Sorry.
747780	750660	I may not be as prepared as other speakers.
750660	751840	Ugh.
766300	766820	So...
767360	770780	Oh, you should also note that the code doesn't exit cleanly.
770780	774940	So I can only do this once, and then I have to play around, like, killing things.
774940	779560	Okay. So I just wrote a quick tool called USB, man in the middle.
779580	783880	And it's going to use our specific device proxy here.
783880	787500	It's called deviceproxy.11.
787720	791660	And the config file literally just tells it which interface to use.
791660	795800	There's only one on this system anyway, but it just tells it, use WLAN0.
797100	797500	So...
797500	799700	Huh. Let's hope this works.
800340	803480	So what you can see, I'm going to wander and point...
803480	805360	No, that's going to scratch the video, isn't it?
805360	807060	I'm going to point with a mouse pointer.
807640	811460	So what you can see is we opened up a USB device.
812800	816120	It's using the Mac 802.11 driver.
816160	817580	It's got WLAN0.
817580	819920	And then it's just...
819920	823760	The host tries to set the configuration on my USB device.
824000	825700	Which doesn't do anything.
825780	828060	And then we start sniffing packets.
828220	831720	And here, we've sniffed a 197-byte header.
831800	833060	Is that true?
833440	838060	Okay, we've sniffed a 197-byte header with no data, which sounds like a beacon.
838480	841780	And then we've written it to the other side.
842240	845020	And... let's see if this does anything.
851990	853190	No, it doesn't.
853490	856890	So what we try and do is we then copy that over to the other side.
856890	858610	To write over to the host system.
858730	860910	And that's when the code just sort of dies.
860910	861730	And nothing happens.
861730	862950	And nothing to see here.
862950	866430	But what we are able to do is do things like set the time out on the device.
866430	867030	And read it back.
867030	870290	And open the WLAN0 on capture interface.
870430	872810	And we're that far away.
872970	876630	If our talk had been an hour later, we probably still wouldn't have any working code.
876630	878710	But we would have been a little bit closer.
878710	884570	And that's pretty much the thing we've been working on for the past, well, four hours.
886550	888270	And we think it's kind of a fun concept.
888270	890990	And so we want to take the opportunity to just kind of talk to people about it.
890990	892870	We're really sorry it doesn't work yet.
893710	896090	But we did manage to hook it up to an Android tablet.
897270	901870	And again, if I use the mouse pointer wherever it's gone.
901870	902710	There it is.
902790	905370	You can see it's connected to a .11 proxy.
906790	911230	And in the logs, it's picking up stuff coming off the device.
911810	916010	There's no way we can hook our Android tablet to the projector to show you this working.
916190	918730	But, you know, it's got channel hopping enabled.
918730	921150	And it can read the functionality from the wireless device.
921150	924130	And we can report that to Android PCAP.
924290	926810	And then we can start capturing packets.
926810	928790	And then we can upload them to...
930130	931750	Anything you can share to.
931750	933970	You can upload it to CloudShark and get a live decode that way.
933970	936390	Or we can copy it over to a host and rumble our shark.
936390	940290	Or you can copy it to a host and throw it into aircraft or whatever you want to do.
940290	948550	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.
948550	951950	It'll work on Mac the same way that the UberTooth does.
952070	958970	So we've taken it from porting 10,000 lines of code per random Wi-Fi card driver to...
959930	960930	Well, here you go.
960930	970650	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.
970650	974250	Yeah, so we've dropped to a factor of...
974250	976090	We'll try that sentence again.
976150	978230	We've dropped the size of the code by a factor of 10.
978230	979070	More than that.
979070	980090	And more than that.
980170	983170	And just for this one file.
983170	989110	And that one interface will cover anything that supports... any Wi-Fi driver that's supported on Linux.
989110	992550	So it's not just, oh, we've got a new device and it uses less code.
992550	995350	We've got a new device and it covers all the existing devices.
995690	999530	And once this code works, which is really soon...
999530	1008270	Once this code works, all of the supported Linux HL2.11 devices will work on Android.
1008270	1011790	And someone can write some libUSB code for Windows and it'll work on Windows.
1011790	1014990	And it just becomes a much, much easier way to do it.
1014990	1019010	And the only thing that it costs is $40 for the BeagleByBlack.
1019010	1020130	If you can get hold of one.
1021290	1023030	We're also looking at porting it to...
1023030	1027070	I mean, the code is generic. It's written for... targeted to Linux.
1027150	1032690	So if you find another piece of embedded hardware with a USB device port on it, it'll work for that as well.
1032690	1034370	So there's an Olmec's Lime.
1035050	1037070	And I'm trying to remember some of the others.
1037150	1039870	There are a whole bunch of different boards.
1039870	1042250	And they're all in the, like, under $50 range.
1042250	1048590	And so one of them, paired with a Wi-Fi device, will enable you to use Android or Windows or OS X.
1048750	1050650	And I think that's mostly our project.
1050890	1053010	So I want to thank Josh Wright and Mike Lussman.
1053270	1056230	Because Josh Wright helped you write the Lorca library.
1056330	1061110	And Mike Lussman continues to pay me, even though I work on things that have nothing to do with making any money.
1061510	1063030	So thank you, Mike Lussman.
1063030	1063610	Thank you.
1075500	1076260	That's fine.
1080300	1081760	I'm going to run down to you in a second.
