Code Monkey home page Code Monkey logo

raccoon's Introduction

Raccoon BLE Sniffer

Raccoon is an open-source Bluetooth Low Energy Sniffer that consists of firmware for the Nordic nRF5x SoCs and a Python command line tool. It can follow connection request on all three advertisement channels by using three sniffer devices.

Supported Devices

Raccoon was successfully tested on:

Dependencies

The firmware requires the regular ARM-EABI-NONE toolchain. The Python command line tool was develop on Python 3 and requires the pySerial module It requires the nRF5 SDK. If not installed locally, the build system can automatically download it into the project folder.

Build

With the dependencies in place, run make in the main project folder. Make will download the nRF5 SDK if needed.

Flash

Flashing depends on the used device.

Nordic DKs

Go to the correct folder:

  • nRF51 DK: firmware/nrf/pca10028/armgcc
  • nRF52 DK: firmware/nrf/pca10040/armgcc
  • nRF52840 DK: firmware/nrf/pca10056/armgcc

Run make flash

Nordic nRF52840 Dongle

The nRF52840 Dongle comes with a MBR and a Bootloader that supports firmware update via DFU mode. Here, we use the nRFConnect for Desktop tool:

  • Download and install nRFConnect For Desktop
  • Start nRF Connect and select Programmer
  • Enter Bootloader mode by pressing RESET button - the red LED starts pulsing
  • Select your device in the 'Select Device' pop-up in the upper left
  • Add Hex file: firmware/nrf/pca10059/armgcc/_build/nrf52840_xxaa.hex
  • Press 'Write'
  • After successful write, the warning 'Nordic DFU Trigger Interface was not found' is shown. That's ok - Raccoon was flashed and is ready

Adafruit Bluefruit LE Friend

There's no support to update via the BLE DFU. However, the LE Friend provides the regular SWD interface to upload the firmware with an JTAG/SWD programmer (e.g. a ST-Link or a SEGGER J-Link). Config files for OpenOCD are provided int the firmware/nrf/blefriend32 folder.

Makderdiary nRF52840 MDK

Drag-n-drop the hex file firmware/nrf/nrf52840_mdk/armgcc/_build/nrf52840_xxaa.hex to the disk drive named DAPLink of the board, and then Raccoon will be ready.

Makerdiary nRF52840 MDK USB Dongle

Follow the guide - Programming the nRF52840 MDK USB Dongle to flash the firmware firmware/nrf/nrf52840_mdk_usb_dongle/armgcc/_build/nrf52840_xxaa.hex.

Makerdiary Pitya Go

Follow the guide - How to Program Pitaya Go to flash the firmware firmware/nrf/pitaya_go/armgcc/_build/nrf52840_xxaa.hex.

Setup

When running raccoon.py for the first time, it will create a template config file 'config.py' that lists all serial ports. Please edit config.py and uncomment the lines that refer to Raccoon sniffer device.

Usage

After configuration, start raccoon.py. It will list found devices and wait for a connection request. It will follow the first connection request. To follow only a specific device, you can set a BD_ADDR (MAC) filter with the --addr option.

During scanning, unique advertisements will be listed and a counter displays the total number of received devices. After connect, the number of Connection Events and the number of non-empty data packets are shown.

Example run:

$ pyclient/raccoon.py
[+] Config: output trace.pcap (pcap)
[-] Sniffer #0: port /dev/cu.usbmodem0006816168181, baud 1000000, rtscts 1, channel 37, version 9957-dirty
[+]  1. 00:1a:7d:da:71:01         ADV_IND  -46 dBm, Name: 'LE Counter', UUID16: FF10
[+]  2. 04:52:c7:f8:6e:57         ADV_IND  -97 dBm, UUID16: FEBE
[+]  3. 5e:5e:fe:16:21:19    ADV_SCAN_IND -102 dBm, UUID16: FE9F
[+]  4. 00:21:3c:ac:f7:38         ADV_IND  -56 dBm, UUID128: 200c9a66-0800-9e96-e211-818a400b0998
[+]  5. 1f:3a:8b:7a:e6:b8 ADV_NONCONN_IND  -97 dBm,
[+] CONNECTION 4a:dc:5a:84:78:fb -> 00:1a:7d:da:71:01 -- aa af9aaa9a, interval 30.00 ms, timeout_us 720.00 ms, latency 0
[+] TERMINATE, disconnect
[+] Restart sniffer on channel #37
[+]

Thanks for using raccoon

Status and Outlook

General

The current version allow to follow all Bluetooth 4.x connections. Optional supported features:

  • LE Data Length Extension (DLE).
  • Channel Selection Algorithm #2 (CSA #2) - only partially working yet

Security

Encrypted connections are not supported yet. Sniffing encrypted connections requires the Long Term Key/Link Key to be present on the sniffer hardware.

For LE Legacy Connections, the link key can be retrieved using crackle if the pairing is observed.

To use Raccon with crackle, select packet format 'crackle' and then use crackle as descriped on the recorded .pcap trace: crackle -i trace.pcap -o decrypted.pcap

LE 2M/Coded PHY

Logging connections with 2-MBit PHY or Coded PHY is not implemented yet.

Throughput

The UART of the nRF5x devices only support a maximal baudrate of 1 mbps. This is not enough when the connection intervals are fully used. The new nRF52840 Dongle (PCA10059) supports the USD Device mode, which should be fast enough to even capture LE 2M PHY at max speed.

raccoon's People

Contributors

mringwal avatar seanburford avatar xiongyihui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raccoon's Issues

nRF52840 Dongle

hi, is it possible to install your firmware on an nRF52840 Dongle to sniff ble tags nearby?
after uploading your firmware is it possible to use the nRF52840 Dongle via the linux hcitool command?

support for new NRF52832 board

Hi,
I have a NRF52832 Sparkfun breakout board and a NRF52832 MDK. Would like to add support for either of these so that I can use it to sniff the other (maybe the breakout is easier). Could you give me a few pointers on how to port the firmware to these? I have looked at the files for each board and it seem there's some autogenerated header files.

Thanks!

pca10059 don't restart sniffing after following a connection

After following a connection, the LED on the pca10059 doesn't start flashing again.

Looking at raccoon.py, the restart CMD_SNIFF_CHANNEL only sends a 19 byte payload, compared to the 20 byte payload during initial setup. It omits the min RSSI value. Increasing this packet to 20 bytes and providing the same min RSSI value results in happy LEDs and, by the look of things, ongoing packet capture.

Targeting the nRF51822-based CJMCU-8223

The generic CJMCU-8223 board uses an nRF51822, the same as the Adafruit blefriend32 boards. The Nordic sniffer firmware used on the pre-flashed Adafruit sniffer dongle works fine on the 8223 (both v1 and v2) but unfortunately, some of the UART flow control pins set up by the official firmware aren't broken out on the 8223, so I decided to give Raccoon a shot.

I thought it would be as simple as modifying firmware/nrf/blefriend32/config/custom_board.h to set the LED and UART pins I'd like, compile, flash, everything would work (considering it's the same chip) but Raccoon firmware immediately traps in a HardFault when building and flashing unmodified from git:

> halt
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x21000003 pc: 0x0000097e msp: 0x20007fe0

Flashing with openocd -f flash_blefriend32.cfg:

Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
WARNING: interface/stlink-v2.cfg is deprecated, please switch to interface/stlink.cfg
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1000 kHz
Info : STLINK V2J29S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.304653
Info : nrf51.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : starting gdb server for nrf51.cpu on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0x0000093c msp: 0x20008000
Info : nRF51822-QFAA(build code: H2) 256kB Flash, 16kB RAM
Info : Mass erase completed.
Info : A reset or power cycle is required if the flash was protected before.
target halted due to debug-request, current mode: Thread 
xPSR: 0xc1000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Warn : Adding extra erase range, 0x00007d6c .. 0x00007fff
** Programming Finished **
** Verify Started **
** Verified OK **

Please let me know what additional information you need, or additional things I should try. I'm not very experienced with the arm toolchain (and on-chip debugging) so any help would be greatly appreciated.

Fedora 36
arm-none-eabi-binutils-cs-1:2.37-4.fc36.x86_64
arm-none-eabi-gcc-cs-1:11.1.0-2.fc36.x86_64
arm-none-eabi-gcc-cs-c++-1:11.1.0-2.fc36.x86_64
arm-none-eabi-newlib-4.1.0-4.fc36.noarch

not seeing connections

Hi,

Thanks for providing such a great tool :-)

I'm using the makerdiary nRF52840 MDK USB dongle, replaced the UF2 bootloader
with the Open bootloader, and wrote nrf52840_xxaa.hex to it using nRF Connect.

My config.py:

   { 'port':'/dev/ttyACM0', 'baud':1000000, 'rtscts':1 }
]

Some sample output (addresses edited a bit):

[+] Config: output trace.pcap (pcap), min rssi -80 dBm- filter: f3:ca:88:12:34:56
[-] Sniffer #0: port /dev/ttyACM0, baud 1000000, rtscts 1, channel 37, version 
[+]  1. 5a:96:8b:00:00:00         ADV_IND  -49 dBm, 
[+]  2. f3:ca:88:12:34:56         ADV_IND  -54 dBm, Name: 'KL-TNS-88123456'
[+]  3. 54:a2:0a:00:00:00         ADV_IND  -53 dBm, 
[+]  4. f3:ca:88:12:34:56        SCAN_RSP  -53 dBm, UUID16: 0001
[+]  5. 54:a2:0a:00:00:00        SCAN_RSP  -53 dBm, 
[+]  6. 5a:96:8b:00:00:00        SCAN_RSP  -41 dBm, 
[+]  7. 74:34:34:00:00:00    ADV_SCAN_IND  -80 dBm, UUID16: FE9F
[+]  8. 74:34:34:00:00:00        SCAN_RSP  -80 dBm, 
[+] 
Thanks for using raccoon.

The f3:ca:88 device is a motion sensor. I connect to it using an iPhone app,
but the connection is not captured. Do you have any idea what could be the issue?

Thanks :-)

Struct pack throw exception for negative timestamp

When using multiple raccoon devices, it happens that read time on a device result in a negative timestamp.

delta_ts = timestamp_log_us - last_timestamp_us

For that, pack function of struct is bad formatted

payload_data = pack( '<BBBBHI', 10, flags, channel, rssi, ecount, delta ) + packet

It can be a signed int so line become:
payload_data = pack( '<BBBBHi', 10, flags, channel, rssi, ecount, delta ) + packet

nRF52840 stuck in Bootloader after flashing

Hi there,
I've flashed the hex file successfully following the README using nrfConnect but the dongle still loads the bootloader (pulsing red LED), not the application, although it reports that the programmer found an application after reseting the dongle by replugging it. Also I can see that there is an application present via the GUI.
Any idea what is going on here?
Thx

No output when using Makerdiary Pitaya Go

Hi!

I followed your guides with no problem at all until I try to actually sniff packets, moment in which I get nothing.

My config at pyclient/config.py

# Raccoon BLE Sniffer Config

# Output format
# pick one of the following logging formats by uncommenting the format line

# PKLG format minimics HCI data to/from a Bluetooth Controller. It can be opened with Wireshark and Apple's PacketLogger
# format  = 'pklg'

# PCAP format uses Bluetooth BLE Trace format defined by libbt/Ubertooth for use with CrackLE. It can be opened with Wireshark
# format = 'crackle'

# PCAP format uses Bluetooth BLE Trace format defined by Nordic. It can be opened with Wireshark.
format = 'pcap'


# Available Sniffer devices
# List of detected serial ports, please uncomment your Raccoon BLE Sniffer devices
sniffers = [
#   { 'port':'/dev/ttyS0', 'baud':1000000, 'rtscts':1 },  # ttyS0 - PNP0501}
   { 'port':'/dev/ttyACM0', 'baud':1000000, 'rtscts':1 },  # raccoon nrf52840 dongle - USB VID:PID=1915:520F SER=000000000000 LOCATION=2-4.2:1.0}

]

Commands log

If I run raccoon just after plugging the board, I get this:

> 1 $ ./pyclient/raccoon.py 
[+] Config: output trace.pcap (pcap), min rssi -80 dBm
[!] Failed to connect to sniffer at port /dev/ttyACM0 with 1000000 baud
[!] No working sniffer found. Please connect sniffer and/or update config.py

And as soon as I wait just a little, I can connect with no more errors ... but also with no more information:

> 1 $ ./pyclient/raccoon.py 
[+] Config: output trace.pcap (pcap), min rssi -80 dBm

After seeing the commit flow, I will reference both @mringwal and @xiongyihui, as I think they may be the right two to be asked hehehe

Do you have some idea on how to continue? Tell me whatever you need to debug it :)

Thanks a lot in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.