start	end	text
0	1280	Hello and welcome.
1280	2700	My name is Mike Ryan.
2700	11640	I'm the founder of Ice9 Consulting, and in this video, I'll cover a new tool I've developed for Bluetooth sniffing with software-defined radios, as well as some background and theory on how I built it.
11780	14280	Before I get into that, I'll introduce my company.
14300	20400	Ice9 Consulting is a boutique consulting firm that specializes in Bluetooth, IoT, and embedded security and development.
20400	27180	For more info, you can email info at ice9.us, and full contact info will be available in a few slides.
27200	30300	I'll open with a question I get asked a lot.
30380	31940	How do I sniff Bluetooth?
32280	34600	It seems like something that should be easy, right?
34620	38240	Like, we've been sniffing Wi-Fi for as long as we've had Wi-Fi.
38260	39940	So how about Wireshark?
39940	44100	It's certainly my go-to for sniffing Wi-Fi and Ethernet, so what about Bluetooth?
44680	50520	As many of you probably know, if you go into Wireshark today and look for Bluetooth, you won't find anything.
50740	55940	At most, if you're on Linux, you might find the btmon interface, but that's not true Bluetooth sniffing.
55940	58300	But that's all about to change.
58320	66820	As of this talk, I'm releasing a new tool that integrates with Wireshark and works with most popular software-defined radios, and here's how it works.
66920	70540	You open up Wireshark, scroll down your interface list.
70700	75660	For each supported software-defined radio you have attached, you should see an entry for Ice9 Bluetooth.
76080	82540	You can click the little gear icon to change some settings, then smash that start button, and voila, you've got Bluetooth packets.
82540	84660	Yes, it really is that simple.
84740	93940	And the best news yet, if you have a HackRF, a BladeRF, or a Usurp B200 or B210, you can finally use it in Wireshark to sniff some Bluetooth.
94120	100760	I'm pleased to release the Ice9 Bluetooth sniffer, available immediately from the URL at the bottom of the slide.
100760	102140	Here's what it can do.
102140	108120	It can detect BLE advertising packets and decode BLE data packets on any channel promiscuously.
108140	113200	It can identify classic Bluetooth laps, and I'm working on adding more features in this space.
113560	121160	With the current hardware, you can listen on up to 56 channels simultaneously, though in practice your CPU will probably limit you to fewer.
121360	126140	For a benchmark, my M1 Macs can listen to 36 channels in real time.
126380	129300	Later in the talk, I'll cover how I'm trying to increase that.
129300	135960	It's written in Portable C, its only dependency other than the SDR libraries is LiquidDSP, and it runs on Mac and Linux.
136020	139900	In principle, it should build and run fine on Windows, but that's not really my bag.
139900	142440	I will gladly accept contributions in this space.
142440	144620	I've also included my contact info.
144760	145680	And that's it!
145680	150260	If you're just here to sniff Bluetooth, follow the instructions to install the software and away you go.
150260	160620	For the rest of you who want to dig a little deeper, I will now take this opportunity to segue into the real title of this talk, Everything I Wish I Had Known About Software-Defined Radios Since 2013.
160720	165820	I picked 2013 because that's when I got my first real SDR, a HackRF Jawbreaker.
166380	169360	I fired up that bad boy and did all the usual things.
169360	176420	More or less the Hello World of SDR applications, I fired up GQRX and tuned the SDR to the middle of the Broadcast FM band here in the states.
176800	178400	Now, this is pretty nifty.
178400	182380	You can watch about 20 stations play on in real time and click on them to listen.
182480	188340	Eagle-eyed viewers may even be able to spot some digital sidebands of the in-band on-channel HD radio stations.
188400	194320	However, as cool as this is, I knew it was only scratching the surface of what software-defined radios are capable of.
194360	197760	So, I took the next logical step and fired up GNU Radio.
197760	201100	I made a handful of tame flow graphs similar to the one pictured.
201220	206420	However, whenever I really tried to start decoding the signals, I kept running into the same issue.
206420	212580	The flow graphs, blog posts, and YouTube tutorials always got a little... intense, I guess is the word I would use.
212580	218680	They always started out comprehensible enough, but by the end, they'd always end up looking like this picture of Valent Sieber.
218880	221540	Now, I don't mean to denigrate GNU Radio.
221540	223760	It's an excellent tool in capable hands.
223960	230840	This is almost certainly a me problem, but I find when I have problems, sometimes other people have the same problems.
230840	233460	I didn't study digital signal processing in school.
233460	235360	I'm not really a radio guy by training.
235360	238160	I know enough math to be dangerous, and I can sling code.
238160	241100	I was able to figure this stuff out, and I bet you can too.
241120	243880	In order to do so, let's start from the very basics.
244440	247120	What, exactly, is RF?
247240	249640	Borderline philosophical question, right?
249820	251340	Well, that's simple enough.
251340	253700	It's a burst of energy at a given frequency.
253700	258500	That's probably not the most useful definition, so what is it exactly?
258500	261220	If you're watching this talk right now, you're looking at it.
261220	262000	Literally.
262000	264760	Visible light is extremely high frequency RF.
264760	266780	We're talking hundreds of terahertz.
266780	271580	When visible light hits our optic nerves, they emit signals that our brain uses to create images.
271580	274700	We're interested in much lower frequency RF, though.
274700	280020	Let's say about 50 megahertz to 6 gigahertz, which just so happens to be the range of our SDRs.
280160	284440	Let's build a model of a simple broadcast RF system so we have something to talk about.
284740	287740	It all starts with an audio source, like a microphone.
287780	292720	That's wired into some kind of broadcast tower that emits tons of RF on a specific frequency.
292940	300760	That RF travels through the air to the antenna on some kind of radio, like a boombox, where the signal is picked up, amplified, and converted back into sound.
300760	303280	Now let's consider that RF flying through the air.
303320	307500	What if, instead of a boombox, we attached our antenna to a software-defined radio?
307500	311140	When we capture with the SDR, it spits out digital IQ.
311340	312920	What is that exactly?
313220	317860	Well, by way of analogy, let's consider another commonly digitized signal, sound.
317860	319920	Sound is a compression wave through the air.
319920	323100	Air molecules strike a membrane inside a microphone's transducer.
323100	329440	The movement of that membrane is converted to a digital signal, sampled periodically, and we're left with a digital audio file.
329500	333820	In this regard, you can think of a software-defined radio as a microphone for RF.
334160	336740	Armed with that knowledge, how do we interpret the data?
337060	340140	One simple way is to look at the signals in the frequency domain.
340140	343580	This is a spectrogram of someone saying a few words into a microphone.
343640	347160	Time is on the x-axis, and frequency in hertz is on the y-axis.
347340	353500	Simply looking at this is enough for us to glean some patterns, such as the low-frequency voice sounds and the high-frequency fricatives.
353640	358440	You can immediately imagine approaches you might take to processing this data when presented this way.
358600	365100	Let's look at the broadcast FM spectrum, that's 88 megahertz to 108 megahertz, in the frequency domain as well.
365100	369900	Once again, time is on the x-axis, and frequency in megahertz, this time, is on the y.
369900	374220	Aside from the range on the y-axis, it looks quite similar to the previous spectrogram.
374240	385880	Each bright squiggly line is an FM radio station, and in fact, if we zoom in on a few of these, you can see that this frequency domain representation of the RF signal looks an awful lot like a time domain representation of an audio signal.
386000	389560	Hmm, I wonder if this is what they meant by frequency modulation.
390240	392320	Okay, okay, okay, enough background.
392320	394440	This is a talk about sniffing Bluetooth, right?
394440	396160	So let's sniff some Bluetooth.
396260	399600	Step 0, not depicted here, is to find some software.
399960	403420	GQRX or SDR-Sharp are good options depending on your platform.
403520	407160	Step 1, tune your radio to somewhere around 2400 megahertz.
407320	409220	2427 is a good choice.
409360	412220	Step 2, set your sample rate as high as it'll go.
412340	415160	A higher sample rate means you will capture more channels.
415360	417980	Finally, smash that capture button and let her rip.
417980	420140	Give it a few seconds and stop the capture.
420280	423180	Open up your capture and InSpectrum, and there you go.
423300	426040	Each one of these red blobs is a Bluetooth packet.
426040	429480	What's more is that you can clearly see they're organized into channels.
429480	432420	Remember, frequency is on the y-axis in this spectrogram.
432500	436380	For the sake of keeping things manageable, let's target a single channel for sniffing.
436380	438780	In order to do that, we must do two things.
438800	447620	First, in this capture, this particular channel is centered at about 0.5 megahertz, and we need to move it down to 0 megahertz for the rest of our algorithms to work.
447740	452960	Once we've moved it down to 0 megahertz, we have to filter out all the other channels that we're not interested in.
453980	456240	Cool, so how do we do that?
456400	459220	First, moving a radio signal around is very simple.
459220	462200	Let's say your signal of interest is at x megahertz.
462200	468000	In order to move it down to 0 megahertz, you simply multiply it by a sine wave at negative x megahertz.
468000	473400	With that taken care of, we can filter out all the frequencies we're not interested in using a low -pass filter.
473660	479220	Typically, at this point, we also decimate the signal to throw away redundant information and make it easier to work with.
479220	483080	What we are left with is a single channel, filtered and ready for demodulation.
484420	486740	Let's look at our filtered centered channel.
486740	492920	Bluetooth is a bursty protocol, which means it doesn't broadcast continuously, but instead sends data in periodic packets.
492940	494620	What does this mean for us?
494620	497720	This means that we can't leave our demodulator running all the time.
497720	503020	Otherwise, 99% of the time we'd be demodulating noise, and that could lead to false detections of packets.
503300	505380	Let's zoom in on a single Bluetooth packet.
505440	509080	We need a way to detect the presence of this packet against the background noise.
509160	513100	One possible way of doing this is to plot the amplitude of the signal over time.
513160	517320	What you'll notice is that when a packet is present, the amplitude goes up by a lot.
517400	520760	One very simple way of approaching this is to then draw a line at some value.
520760	522220	Let's call it squelch.
522280	527860	When the amplitude is below the squelch, we know there's probably noise on the channel so we don't even attempt to demodulate.
528040	535540	Once the amplitude goes above the squelch, or breaks squelch as the jargon goes, we know some burst of RF energy is present on our channel.
535580	541780	Not only that, we can also detect when the amplitude goes below squelch, and after a short timeout we know the burst is over.
541780	546560	This gives us bursts as well as burst lengths, which will be important later, so remember that.
546840	547280	Neato!
547280	548380	We have bursts.
548380	550960	Let's dive a step deeper into demodulating them.
551060	552840	In Spectrum makes this super easy.
552940	557600	Just right click on the spectrogram, point to add derived plot, and click add frequency plot.
557720	561440	This will add some lines to the spectrogram that you can move around to center on the burst.
561440	565340	Be sure to adjust the bandwidth of the filter by making it taller or shorter as necessary.
565340	572400	Once you've done that, in the frequency plot below you'll see what is obviously some kind of digital signal that you could probably decode by eyeball if necessary.
572400	575920	But we don't need eyeballs for this, we have computers to do our bidding.
575940	578180	Let's look at the raw demodulated data.
578380	583020	In Spectrum you can right click on the frequency plot and click export samples to file.
583020	585440	Load up the samples in your favorite graphing software.
585440	586640	I'm using GNUplot.
586640	592660	If you plot them as a time series you get something that, hey, looks exactly like that demodulated signal from in Spectrum.
592800	596220	Now the y-axis on this chart is a value in some strange units.
596220	603340	I think it might be radians per sample or something, but essentially it's proportional to the frequency offset used in the frequency shift keying modulation.
603540	610040	First thing you might notice upon taking a closer look is that the symbols are not centered about zero, they're slightly below zero.
610040	619280	This is called the carrier frequency offset, and it exists because there's some very slight offset between the center frequency of my radio and the center frequency of the transmitter's radio.
619280	621940	Before demodulating we'll have to correct for that.
623240	628460	Next you might notice that the values range from approximately negative 0.2 to 0.2.
628460	630500	This is our FSK deviation.
630560	634840	For our purposes it would be most convenient if the values range from negative 1 to 1.
634840	639000	Let's look into how we correct for carrier frequency offset and frequency deviation.
639200	643500	I searched the literature and honestly didn't come up with a lot of good options for how to approach this.
643500	648760	Back in 2016 Michael Osman presented a really interesting talk on whole packet clock recovery.
648800	654080	As part of this research he published what he calls the median method, and I have taken that and improved upon it.
654380	657500	Thus I present to you the improved median method.
657580	661340	You take the first n points and bucket them into positive and negative values.
661340	663980	If either of those groups is empty reject the packet.
664200	669380	We find the max as the median of the positive points and the min as the median of the negative points.
669540	672220	Our midpoint is the average of the max and min values.
672220	674060	This is our carrier frequency offset.
674280	679580	What we call the scaling factor is half the distance from the midpoint to the max, or the half height of our signal.
679600	681400	This is our FSK deviation.
681700	685580	First we subtract the midpoint from all of the points, centering them about 0.
685620	690280	Finally we divide all the points by our scaling factor, which scales them from negative 1 to 1.
690280	693060	We are left with a normalized corrected packet.
693060	696460	It's centered about 0 and the values swing from roughly negative 1 to 1.
696460	697920	This we can work with.
698260	702060	Any signal processing textbook will tell you that the next step is clock recovery.
702060	709180	This is the process for recovering the original signal clock and phase so that you know exactly when to sample the data so it's in the exact middle of a symbol.
709180	713800	There are a bunch of approaches to do this, including the aforementioned talk by Michael Osman.
714060	716860	Myself, I decided to completely punt.
716920	721200	I finagled things so that the data we process is 2 samples per symbol at this point.
721200	724980	This means we can use every other sample as our symbol or bit value.
725040	729000	The packets are short enough and the clocks are close enough that this works fine for our use case.
729060	733560	That said, if you have a bigger brain than I do, check out the polyphase symbol synchronization method.
733700	739360	Okay, bada bing bada boom, we've turned our digitized analog signal into a pile of bits.
739400	742640	Here's our real Bluetooth packet turned into 1s and 0s.
742640	744340	There's only one slight problem.
744340	746540	We don't know exactly where it begins.
746540	748060	How do we even interpret this data?
748060	749760	For that, we turn to the spec.
749760	753760	The Bluetooth core spec gives us this table as the format of a BLE packet.
753920	760240	You can see they always begin with an 8-bit preamble, which is 010101 or 101010.
760600	763000	Following that is a 32-bit access address.
763000	769580	This value is fixed for advertising packets, and for connections, it's a random value shared by the two parties when they establish the connection.
770000	774600	Following that is a short header, a data field, and a 24-bit CRC for error protection.
774860	779720	If we were building a regular Bluetooth transceiver instead of trying to sniff Bluetooth, our job would be easy.
779720	784900	We would know the value of the access address either because we were part of a connection or we were on an advertising channel.
784900	792040	This means we could search the bitstream for that 32-bit value and know with high fidelity that the remainder of a packet destined for us would follow.
792600	794980	But we're making a promiscuous sniffer.
794980	802080	We want to be able to capture all packets even if we don't have a priori knowledge of their access addresses, so this approach won't work for us.
802080	806520	You might be looking at the preamble and thinking, why not just search for those 2-bit patterns?
806700	808860	Again, this won't work.
808860	811660	Those values are very short and susceptible to noise.
811660	814920	You'd get a ton of false positives and false negatives with this approach.
815040	817100	Instead, I took a novel approach.
817160	818660	Let's zoom in on the header.
818660	821040	The second half of it is a length field.
821220	826660	What if we compare this header field to the length of the burst, since that's a value we know from earlier in the processing chain?
826660	828840	Here's an illustration of the approach.
828840	832500	Pictured is our packet, and let's say the burst length is 78 bits.
832660	835560	First, we assume the packet starts at the beginning of the burst.
835560	841360	You can see the 101010 preamble, followed by our candidate 32-bit access address.
841600	844480	After this is the header, with an 8-bit candidate length.
844720	847600	Let's say our first candidate length is 138 bits.
847600	849360	And note that these values are bogus.
849360	852720	Don't try to compare them to the packet above, because I just made them up.
852800	855140	So our first candidate length is 138 bits.
855140	857120	How does that compare to our burst length?
857200	860160	It's much longer, so that's probably not correct.
860160	862640	This is unlikely to be the start of the packet.
863700	867080	Now we move the start of our packet forward one bit.
867100	874380	Here again we have our preamble, our candidate 32-bit access address shifted over by one bit, and our candidate length shifted over by one bit.
874640	879480	In this case, the candidate length is 74 bits, pretty close to our 78 bits.
879480	880920	Let's remember this one.
880980	885540	For the sake of completeness, let's move forward one more bit and see what the candidate length is.
885540	888380	If we do that, our length comes up as 15.
888520	893160	Compared to 78, that's way too short, so this is not the correct offset for our packet.
893180	896100	That only leaves us with a second case we considered.
896280	901280	This means we know the start of the packet, and our candidate access address is probably valid.
901500	904940	We can decode the rest of the packet and stuff it into PCAP.
904940	907120	Boom, open that up in Wireshark.
907180	910360	Well hold your dang horses, that's not what I showed at the beginning of the talk.
910360	912720	I promised interface lists and buttons.
913260	914740	Enter extcap.
914740	920220	This is a little-known feature of Wireshark that was introduced in 2013 by these two clowns.
920220	926240	Mike Kershaw, who you may know as Dragorn of Kismet fame, as well as yours truly, Mike Ryan, the Bluetooth expert.
926280	928740	These pictures are what we looked like in 2013.
929020	930740	This is what we look like today.
931140	941320	In the intervening, oh my god, nine years, the code has been made a core part of Wireshark and has been available for quite some time for anyone who wants to implement custom interfaces.
941480	942940	It's extremely simple.
942940	950880	You just follow the specification for implementing a handful of command line flags, output PCAP into a pipe, and you get Wireshark support for free.
950880	954500	This feature is really well documented, so I won't go into details here.
954680	959060	If you have something that produces PCAP that you want to add to Wireshark, give this a look.
959360	960920	Anyway, that's that.
960920	962140	Bluetooth and Wireshark.
962140	963500	Talk over, right?
963760	965200	Well, kinda.
965200	970280	That's the hardest part done with, but remember earlier, I said we were only going to look at one channel.
970280	972220	I promised up to 56.
972840	974160	Remember this?
974160	976800	We could just do this 56 times in a row, right?
976800	978140	Once for each channel.
978440	981540	Well, yes we could, but it would be incredibly slow.
981540	984860	I hate to break it to you, but this image is a bunch of lies.
984880	988300	Very few modern digital communication systems work this way.
988640	997040	Let's go back to our image of the Bluetooth spectrum and let me be possibly the first to introduce you to an amazing and incredible tool, the polyphase channelizer.
997180	1003440	At its most basic level, it splits the spectrum into equally sized channels and allows you to process them in parallel.
1003440	1008920	It's built out of polyphase filters, as the name might suggest, and those are completely bonkers.
1008960	1013380	I can only barely wrap my head around how they work, and they're totally worth looking into further.
1013440	1018460	Check out Fred Harris's lectures and his book on multi-rate signal processing to have your mind blown.
1019180	1023940	This finally allows us to get to the overall architecture of the Ice9 Bluetooth sniffer.
1024460	1029840	It begins with nMHz of RF, where n can be anywhere from 4 to 56.
1030040	1036240	This gets fed into a polyphase channelizer, which I've configured to spit out n streams that are 2MHz wide.
1036660	1039620	Remember how I mentioned two samples per symbol earlier?
1039660	1041420	This is where it comes from.
1041420	1049000	These streams are fed into n burst catchers, each running in its own thread, that watch the signal amplitude and mark the beginning and end of bursts.
1049100	1053360	Those bursts are fed into a queue that is serviced by a single burst processor thread.
1053400	1058020	This is where the FSK demodulation, Bluetooth detection, and PCAP stuffing happen.
1058020	1059840	From there, we got Bluetooth.
1060280	1062520	Now, some comments on this architecture.
1062660	1067500	First, you may be looking at this single burst processor and thinking, why not have a few more of those?
1067640	1073080	I kept an eye on that queue, and even under very heavy load, it never fills up, so that's not our bottleneck.
1073080	1078860	Instead, the issue is over here in the polyphase channelizer, and specifically in there, the FFT.
1079020	1085140	This is not something that trivially paralyzes over threads, so your single core performance will be the limiting factor.
1085200	1091660	The good news is that this is something that is extremely amenable to GPU acceleration, and that's something I've been actively looking into.
1092060	1094360	I'll leave you with some parting thoughts.
1094420	1098720	Remember the carrier frequency offset and FSK deviation that we corrected for?
1098760	1103020	These are physical properties of the transmitter that can be considered a leakage channel.
1103020	1106520	If you plot them on a scatter plot, a few things become obvious.
1106560	1115080	First, if you look at just the purple crosses, the classic Bluetooth packets, you can see near the top there's one cluster, as well as another cluster much lower.
1115240	1120720	This implies that there were at least two distinct classic Bluetooth devices transmitting when this data was collected.
1121100	1128060	Similarly, looking at the BLE packets, you can see one cluster here, another here, and a longer potential cluster over here.
1128300	1132820	There are obvious privacy implications in this, and I'm not the first person to make this observation.
1133280	1138920	A very interesting paper just came out in the IEEE Symposium on Security and Privacy covering this very topic.
1139120	1143480	It's not plumbed out for general use, but if you want to experiment with this, the code is available.
1143740	1146260	Finally, a few pieces of related work.
1146260	1149220	First is Jiaoxian Jun's BLE Sniffer.
1149240	1153580	This one is a single-channel sniffer more akin to an Ubertooth or NRF sniffer.
1153860	1159580	That said, it's very capable and totally worth a look if you have BLE sniffing needs and a HackRF or BladeRF.
1159680	1164020	Next up is the original GR Bluetooth, which isn't very good and I don't recommend.
1164160	1169700	However , it's the first open-source Bluetooth sniffer for SDR that I'm aware of, so it at least deserves a shout.
1170020	1177820	Last up is a paper by Cominelli et al that uses a sniffer architecture very similar to mine and makes use of GPU acceleration in the channelizer.
1178020	1183200	As I said, this is something I really want to do, and if you're interested, contributions are extremely welcome.
1183380	1197080	No work is done in a vacuum, and this work in particular could not have been done without the RFHackers Sanctuary and DEFCON, who put on this event, as well as Michael Ostman, Rob Gilduta, Jared Boone, Tal, and The Liquid DSP Project.
1197080	1204240	Greets, of course, to their eBay Red team, Cousin Nico and all the other cousins, Sammy, Dragorn, Dominic Stupid, and all the other flat ducks.
1204240	1207240	And, of course, thank you, the viewer.
1207340	1211060	Here's the info once again, I'll just recap the features quickly.
1211240	1217780	IceDyne Bluetooth Sniffer can sniff BLE advertising and data packets promiscuously, but it does not yet follow connections.
1217980	1223500	It can recover laps from classic Bluetooth packets and sniff up to 56 channels simultaneously.
1223660	1226960	It's written in Portable C and runs on Linux and macOS.
1227180	1231280	Currently, it supports HackerRF, BladerRF, and Usurp B200 series.
1231340	1235420	If your favorite SDR is not on that list, let me borrow the hardware and we'll make it happen.
1235520	1241040	Find me on Twitter at mpeg4codec, email me at info at ice9.us, and thanks for watching.
