• Stars
    star
    414
  • Rank 101,006 (Top 3 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Broadcom and Cypress firmware emulation for fuzzing and further full-stack debugging

alt text

Frankenstein provides a virtual environment to fuzz wireless firmwares. Firmwares can be hooked during runtime to extract their current state (i.e., xmitstate through InternalBlue). Then, they can be re-executed in a virtual environment for fuzzing. To do so, the firmware image needs to be reassembled to an ELF file that can be executed with QEMU. The firmware image reassembly is simplified by a web-based UI.

Frankenstein is currently optimized for the CYW20735 Bluetooth evaluation board. The slightly newer CYW20819 Bluetooth evaluation board is already partially supported. The port to the CYW20819 evaluation board is required due to CVE-2019-18614, which prevents further fuzzing of connection states such as music streaming or tethering. We are working on support for the Samsung Galaxy S10/S20β€”all of the European S10e/S10/S10+/Note 10/S20 models feature the same chip. If you already have symbols for one chip but are missing symbols for a chip that had similar compiler options, you might find using Polypyus before running BinDiff helpful.

Table of Contents

Basic Setup

This tool contains a web-based UI to configure the build. This includes management of symbols and memory dumps. The Makefile and linker scripts are generated automatically by the build system. The build system can be launched by the following command and navigating the browser to http://127.0.0.1:8000/

python3 manage.py runserver

The build system already contains symbols and an initial memory dump. You can browse through the available projects and the dump without having the actual hardware, IDA Pro or Ghidra database, etc. Symbols are truncated to the first 1k symbols, so do not worry if something you know does not show up in the list immediately.

Each firmware version is located in a different project stored in projects. A project contains the file project.json, which holds the symbol names and the memory layout including memory dumps. The available symbols can be used to generate patches in C as well as for firmware emulation. To build all patches and emulators for the CYW20735 evaluation board run:

make -C projects/CYW20735B1

In general, having the project built is sufficient to run emulation with QEMU. However, for fuzzing it can be quite interesting to hold the firmware at a different state and continue fuzzing from there. So, if you currently do not have any of our supported hardware, you can skip the xmitstate step later.

After rebuilding the project using make -C projects/CYW20735B1, the firmware state can be emulated, until the Idle thread is entered. For this, execute:

qemu-arm projects/CYW20735B1/gen/execute.exe

Or execute it from the web frontend and get even more insights:

alt text

Attaching the Firmware to a Host

The basic execute.exe ELF file does not communicate to the outside world. Thus, it terminates in the Idle thread. However, for fuzzing the firmware, it needs to be attached to a real host and obtain random "wireless" inputs.

We provide an additional patch in hci_attach.exe that abstracts the calling conventions for the Bluetooth Core Scheduler (BCS). The BCS normally takes inputs from the hardware registers that contain decoded packets from the physical layer. We replace the invocation of the interrupt handler bluetoothCoreInt_C that calls the BCS every 312.5Β΅s (1/2 Bluetooth clock cycle). This interrupt handler is now reading data from standard input (STDIN) of the Linux host. You can feed arbitrary inputs, i.e., data from /dev/urandom.

cat /dev/urandom | qemu-arm projects/CYW20735B1/gen/hci_attach.exe

Note that hci_attach.exe also calls the btattach command on the host, which is part of the Linux Bluez Bluetooth stack. Once you run this file, your host will have a new Bluetooth device. You can list the current devices with hciconfig. The hook to pass UART data from the emulated device to the Linux host is installed in the firmware functions uart_directWrite and similar functions.

Depending on the host's exact behavior, you might need to reset the chip immediately after starting QEMU. Otherwise, emulation will get stuck or segfault. On a current (September 2019) Debian testing, this is not done automatically by the host and can be done manually as follows:

hcitool -i hci1 cmd 0x03 0x03
    < HCI Command: ogf 0x03, ocf 0x0003, plen 0
    > HCI Event: 0x0e plen 4
      01 03 0C 00 

After successful reset, the emulation keeps running, which means that you will see a lot of output within short time on the terminal that started the hci_attach.exe. Now you can start actions on the host that cause interaction with the emulated Bluetooth firmware. For example, you can scan for Bluetooth LE devices:

hcitool -i hci1 lescan

If you open Wireshark while doing so, you will notice a lot of weird and invalid packets. Nonetheless, the scanning output will show a lot of devices with random addresses within short time, with some of these even returning mal-formatted names.

Reproducing CVEs

To trigger CVE-2019-11516, run hcitool -i hci1 scan and wait a couple of seconds to minutes.

Context switch idle -> lm
lr=0x02d12f lm_handleInqFHS(0x40)lr=0x02cc53 lc_handleInqResult(0x21fb1c)lr=0x041d91 inqfilter_isBdAddrRegistered(0x21fb24, 0x0);
lr=0x041dc3 inqfilter_registerBdAddr(0x21fb24, 0x0);
lr=0x041dfb bthci_event_SendInquiryResultEvent(0x21fb1c)lr=0x024e49 dynamic_memory_AllocateOrDie(0x19)Heap Corruption Detected
pool = 0x20d368
pool->size = 0x0180
free_chunk = 0x221c04
7f7fb0c9 | a3e4b4aa4242424242424242424242424242424242424242424242424242424242424242
    4242424242424242424242424242424242424242424242424242424242424242424242424242424
    2424242424242424242424242424242424242424242424242424242424242424242424242424242
    4242424242424242424242424242424242424242424242424242424242424242424242424242424
    2424242424242424242424242424242424242424242424242424242424242424242424242424242
    4242424242424242424242424242424242424242424242424242424242424242424242424242424
    2424242424242424242424242424242424242424242424242424242424242424242424242424242
    4242424242424242424242424242424242424242424242424242424242424242424242424242424
    2424242424242424242424242424242424242424242424242424242424242424242424242424242
    4242424242424242424242424242424242424242424242424242424242424242
qemu: uncaught target signal 11 (Segmentation fault) - core dumped

For debugging purposes, our heap sanitizer is currently writing 0x42 to released memory.

Now let's trigger CVE-2019-13916. As this vulnerability is within parsing of BLE PDUs, all you need to do is to successfully establish a connection to another LE device. If you connect to random addresses, this will succeed at some point in time. Usually, this takes a couple of minutes and in some cases the emulator crashes instead and you need to restart the emulation. Be patient!

while true; do hcitool -i hci1 lecc ca:fe:ba:be:13:37; done

This results in:

lr=0x08ee3d bcsulp_getPktLength(0x854cfecd, 0x0) = 0xfe;
lr=0x08ed33 bcsulp_getPktLength(0x05, 0x0) = 0x0;
lr=0x08ec11 bcsulp_getPktLength(0x05, 0x0) = 0x0;
lr=0x08ebc1 dhmulp_getTxBuffer(0x281704, 0x1b, 0x0148001b);
lr=0x041e95 bcsulp_getPktLength(0x854cfecd, 0x0) = 0xfe;
lr=0x08f115 bcsulp_procRxPayload(0x281618, 0x854cfecd)lr=0x08e9c3 bcsulp_getPktLength(0x854cfecd, 0x0) = 0xfe;
lr=0x08ea2f bcsulp_getPktLength(0x854cfecd, 0x0) = 0xfe;
lr=0x08ea4b utils_memcpy8(0x2232d0, 0x370c00, 0xfe)Heap Corruption Detected
pool = 0x20d38c
pool->block_start = 0x2232c0
pool->capacity = 0x0f
pool->size = 0x0108
free_chunk = 0x1010a9a8

qemu: uncaught target signal 11 (Segmentation fault) - core dumped

Dumping Custom States

To dump a custom state, the most important patch is patch/xmit_state.h. It generates re-executable firmware states. It is used in a custom InternalBlue extension internalBlueMod.py. If you are running on a native Linux and want to access the raw HCI device, you need superuser rights.

(sudo) python3 internalBlueMod.py

In this extension, we can run the following command to generate a re-executable state:

> xmitstate target_function

Depending on the target function, this might crash sometimes. Just try again. Once you successfully dumped a state, InternalBlue will finish with

[*] Received fuill firmware state

If the firmware crashes afterwards, you can ignore this.

Now, reload the web UI running on http://127.0.0.1:8000/. It will list your new dump in the Segment Groups view, i.e., internalBlue_09.24.2019_18.32.09. The most recent dump will automatically be set to the Active state. You can now build the project again.

If you were running InternalBlue with sudo, you might need to adjust access rights to the generated state. To do so, run:

sudo chown -R $USER:$USER projects/CYW20735B1/segment_groups/

Now, build the project again:

make -C projects/CYW20735B1

Live Heap Sanitizer

Run our customized InternalBlue script on real hardware:

(sudo) python3 internalBlueMod.py

Load the heap sanitizer patch on top:

> loadelf projects/CYW20735B1/gen/heap_sanitizer.patch

Now you will get detailed output about heap violations, i.e., caused by memcpy and the function which called it. Depending on what you debug, you might need to adjust the definitions in patch/heap_sanitizer.c.

Important Notes & Dependencies

Frankenstein depends on InternalBlue. Projects must be named by the chip descriptions in the InternalBlue firmware files. For example, internalblue/fw/fw_0x4208.py contains the firmware for the CYW20735 evaluation board and contains the identifier FW_NAME = "CYW20735B1". Thus, the Frankenstein project name is CYW20735B1.

For QEMU, you need to install the qemu-user package. Compilation of the project requires gcc-arm-none-eabi.

apt install qemu-user gcc-arm-none-eabi gcc-multilib

Tested with qemu-user (1:3.1+dfsg+8+deb10u2) and gcc-arm-none-eabi (15:7-2018-q2-6) and gcc-multilib (4:8.3.0-1).

The following Python 3 packets are required:

pip3 install django pyelftools==0.24

Tested with django-1.11.24.

We thank Anna Stichling for creating the Frankenstein logo.

More Repositories

1

opendrop

An open Apple AirDrop implementation written in Python
Python
8,426
star
2

openhaystack

Build your own 'AirTags' 🏷 today! Framework for tracking personal Bluetooth devices via Apple's massive Find My network.
Swift
7,719
star
3

nexmon

The C-based Firmware Patching Framework for Broadcom/Cypress WiFi Chips that enables Monitor Mode, Frame Injection and much more
C
2,319
star
4

AirGuard

Protect yourself from being tracked 🌍 by AirTags 🏷 and Find My accessories πŸ“
Kotlin
1,809
star
5

owl

An open Apple Wireless Direct Link (AWDL) implementation written in C
C
1,192
star
6

openwifipass

An open source implementation of Apple's Wi-Fi Password Sharing protocol in Python.
Python
789
star
7

mobisys2018_nexmon_software_defined_radio

Proof of concept project for operating Broadcom Wi-Fi chips as arbitrary signal transmitters similar to software-defined radios (SDRs)
Shell
749
star
8

internalblue

Bluetooth experimentation framework for Broadcom and Cypress chips.
Python
655
star
9

nexmon_csi

Channel State Information Extraction on Various Broadcom Wi-Fi Chips
C
286
star
10

toothpicker

Python
229
star
11

polypyus

Python
212
star
12

privatedrop

Practical Privacy-Preserving Authentication for Apple AirDrop
Swift
210
star
13

bcm-rpi3

DEPRECATED: Monitor Mode and Firmware patching framework for the Raspberry Pi 3, development moved to: https://github.com/seemoo-lab/nexmon
C
158
star
14

BTLEmap

Nmap for Bluetooth Low Energy
Swift
144
star
15

airtag

AirTag instrumentation including AirTechno and firmware downgrades.
JavaScript
130
star
16

wireshark-awdl

Wireshark Dissector for Apple Wireless Direct Link (AWDL) and Apple's CoreCapture logging framework. Note: the AWDL dissector is part of Wireshark 3.0!
129
star
17

mobisys2018_nexmon_channel_state_information_extractor

Example project for extracting channel state information of up to 80 MHz wide 802.11ac Wi-Fi transmissions using the BCM4339 Wi-Fi chip of Nexus 5 smartphones.
MATLAB
96
star
18

airdrop-keychain-extractor

Extracting Apple ID Validation Record, Certificate, and Key for AirDrop
Objective-C
94
star
19

frida-scripts

JavaScript
89
star
20

bcm-public

DEPRECATED: Monitor Mode and Firmware patching framework for the Google Nexus 5, development moved to: https://github.com/seemoo-lab/nexmon
C
75
star
21

fitness-app

Java
68
star
22

apple-continuity-tools

Reverse engineering toolkit for Apple's wireless ecosystem
JavaScript
59
star
23

nexmon_debugger

Debugger with hardware breakpoints and memory watchpoints for BCM4339 Wi-Fi chips
C
54
star
24

talon-tools

Talon Tools: The Framework for Practical IEEE 802.11ad Research
TeX
41
star
25

aristoteles

A Wireshark dissector for the Apple Remote Invocation (ARI) protocol, used between Intel base band chips and the iOS CommCenter for various management purposes, SMS, telephony and much more.
Lua
41
star
26

wisec2017_nexmon_jammer

This project contains the nexmon-based source code required to repeat the experiments of our WiSec 2017 paper.
C
41
star
27

mmTrace

mmTrace: Millimeter Wave Propagation Simulation
MATLAB
39
star
28

fitness-firmware

HTML
39
star
29

apple_u1

JavaScript
38
star
30

dtrace-memaccess_cve-2020-27949

C++
33
star
31

proxawdl

Tunnels a regular TCP connection through an AWDL link by exploiting the NetService API
Objective-C
33
star
32

chirpotle

A LoRaWAN Security Evaluation Framework
Jupyter Notebook
31
star
33

AirGuard-iOS

Protect yourself from being tracked πŸ“by Samsung SmartTags and Tile Trackers
Swift
26
star
34

pyshimmer

pyshimmer provides a Python API to work with the wearable sensor devices produced by Shimmer.
Python
24
star
35

mobisys2018_nexmon_covert_channel

Wi-Fi based covert channel that hides information in hand crafted acknowledgement frames imitating additional channel effects that can be extracted from channel state information at the intended receiver.
C
23
star
36

h4bcm_wireshark_dissector

Wireshark dissector for Broadcom specific H4 diagnostic commands
C
21
star
37

owlink.org

Opening up Apple's wireless ecosystem around the Apple Wireless Direct Link (AWDL) protocol
HTML
19
star
38

uwb-sniffer

A UWB Sniffer with accurate timestamps
C
19
star
39

wisec2017_nexmon_jammer_demo_app

This project contains source code of our Nexmon-based jammer app presented as a demo at WiSec 2017.
Java
18
star
40

plist17lib

Python
17
star
41

seemoo-mobile-sensing

Sensor data collector for Android devices
Java
17
star
42

BTLEmap-Framework

BTLEmap's Bluetooth Low Energy framework that powers the app
Swift
16
star
43

seemoo-wearable-sensing

Sensor data collector for Samsung Gear S3
JavaScript
16
star
44

nexmon-arc

The nexmon C-based firmware patching framework adapted for the ARC architecture.
C
16
star
45

csicloak

Python
14
star
46

talon-sector-patterns

Antenna Sector Patterns as obtained by Measurements in the CoNEXT'17 paper
MATLAB
13
star
47

privatefind

Lost and Found: Stopping Bluetooth Finders from Leaking Private Information
C
12
star
48

nexmon_tx_task

Scheduled frame transmission on Broadcom Wi-Fi Chips
C
11
star
49

wisec2017_nexmon_jammer_demo_firmware

This project contains the nexmon-based source code of the jammer used in our WiSec 2017 demo Android app.
C
11
star
50

fido2ext

Bring Your Own FIDO2 Extensions!
JavaScript
11
star
51

wifi-password-sharing

An open source implementation of Apple's Wi-Fi Password Sharing protocol in Swift.
Swift
10
star
52

bcm_misc

10
star
53

Hardwhere

snipeit-it based asset management app
Kotlin
9
star
54

opennan

OpenNAN - An open source NAN stack for Linux
C
9
star
55

ubicomp19_zero_interaction_security

Source code for experiments and evaluation of five zero-interaction security schemes, for our Ubicomp 2019 paper "Perils of Zero-Interaction Security in the Internet of Things"
Jupyter Notebook
9
star
56

myo-keylogging

Code for "My(o) Armband Leaks Passwords: An EMG and IMU Based Keylogging Side-Channel Attack" paper
Python
8
star
57

natural-disaster-mobility

Natural Disaster Mobility Model and Scenarios in the ONE
Java
7
star
58

wisec2017_nexmon_jammer_reproducibility

This project contains all measured data and scripts to recreate the plots used in our WiSec 2017 paper.
MATLAB
7
star
59

nexmon_energy_measurement

This repository contains patched Linux kernel sources to run energy measurements on the Wi-Fi chip of a Nexus 5 smartphone.
C
7
star
60

next2you

Source code for experiments and evaluation of Next2You copresence detection scheme, for our TIOT 2021 paper "Next2You: Robust Copresence Detection Based on Channel State Information".
C
7
star
61

aic-prototype

Proof of concept implementation of Acoustic Integrity Codes (AICs) for Android smartphones
Kotlin
7
star
62

offline-finding-evaluation

Quantitative analysis of location reports from Apple's offline finding (OF) location tracking system
Jupyter Notebook
6
star
63

pico-nexmon

Applications for the Raspberry Pi Pico W related to Nexmon the C-based firmware patching framework for Broadcom/Cypress WiFi chips.
CMake
5
star
64

fastzip

Source code for experiments and evaluation of FastZIP zero-interaction pairing scheme, for our Mobisys 2021 paper "FastZIP: Faster and More Secure Zero-Interaction Pairing".
Python
5
star
65

powerpc-ose

C++
4
star
66

d11-emu

D11emu: A BCM43 D11 Emulation Framework
Rust
4
star
67

PrivateDrop-Base

The framework that powers PrivateDrop
C
3
star
68

graphics

3
star
69

click-castor

Click implementation of LIDOR/SEMUD (based on the Castor routing protocol)
C++
3
star
70

tpy

A Lightweight Framework for Agile Distributed Network Experiments
Python
3
star
71

privatedrop-evaluation

Jupyter Notebook
3
star
72

wintech23_nexmon_d11debug

Pawn
3
star
73

wintech2017_nexmon_ping_offloading

This project contains the nexmon-based source code of the ping offloading application used in our WiNTECH 2017 paper.
C
2
star
74

wisec23-speaker-bootstrapping

Software repository for our WiSec '23 demo: Secure Bootstrapping of Smart Speakers Using Acoustic Communication
C
2
star
75

hardzipa

Source code for experiments and evaluation of HardZiPA system for our EWSN 2023 paper "Hardening and Speeding UpZero-interaction Pairing and Authentication".
Python
2
star
76

talon-library-measurements

Large-Scale Talon Measurements at Library
1
star
77

kardia-demod

Python
1
star
78

handoff-authentication-swift

C++
1
star
79

caret

CARET: The Crisis and Resilience Evaluation Tool
Python
1
star
80

Please-Unstalk-Me

User Data and Online Survey results
Jupyter Notebook
1
star
81

python-msp430-tools

This is a fork of the original python-msp430-tools repository on Launchpad. It features a patchset that is required to use the tools with the Shimmer3 devices.
Python
1
star