• Stars
    star
    229
  • Rank 168,871 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created about 4 years ago
  • Updated over 2 years ago

Reviews

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

Repository Details

ToothPicker Logo

ToothPicker

ToothPicker is an in-process, coverage-guided fuzzer for iOS. It was developed to specifically targets iOS's Bluetooth daemon bluetoothd and to analyze various Bluetooth protocols on iOS. As it is built using FRIDA, it can be adapted to target any platform that runs FRIDA.

This repository also includes an over-the-air fuzzer with an exemplary implementation to fuzz Apple's MagicPairing protocol using InternalBlue. Additionally, it contains the ReplayCrashFile.py script that can be used to verify crashes the in-process fuzzer has found.

New: Inplace Fuzzer (ToothFlipper)

This is a very simple fuzzer that only flips bits and bytes in active connections. No coverage-guidance, no injection, but nice as a demo and stateful. Runs just with Python+Frida, no modules or installation required. Tested on iOS 13.5-14.3. See inplace-fuzzer.

In-Process Fuzzer

The In-Process Fuzzer works out-of-the-box on various iOS versions (13.3-13.7 tested), but symbols need to be specified. Other iOS versions require adaptions to function addresses. Additionally, it seems like FRIDA's stalker has some problems with the iPhone 8. On newer iPhones that support PAC, the performance significantly suffers from signing pointers. Thus, it is recommended to run this on an iPhone 7.

ToothPicker is built on the codebase of frizzer. However, it has been adapted for this specific application as therefore not compatible with the original version anymore. There exist plans to replace this with a more dedicated component in the future.

Prerequesits:

On the iPhone:

On Linux:

For Arch-based Linux:

# usbmuxd typically comes with libimobiledevice
# but just to be sure, we manually install it as well
sudo pacman -S usbmuxd libimobiledevice python-virtualenv radamsa

# Connect the iPhone to the computer
# Unlock it.
# If a pairing message pops up, click "Trust"
# If no pairing message pops up:
idevicepair pair
# Now there should be the pop up, accept and then again:
idevicepair pair

# In case of connection errors:
sudo systemctl restart usbmuxd
# or pair phone and computer again


# Other useful commands

# To ssh into the iPhone:
# Checkra1n comes with an SSH server listening on Port 44
# Proxy the phone's SSH port to 4444 localport:
iproxy 4444 44
# Connect:
ssh root@localhost -p 4444
# Default password: alpine

# To fetch some device information of the phone:
ideviceinfo

For Debian Linux:

Almost the same as above. Exceptions:

  • radamsa needs to be installed from the git repository because it is not packaged.
  • The command iproxy requires the additional package libusbmuxd-tools.

For macOS:

Slightly different commands compared to the Arch Linux setup...

brew install libimobiledevice usbmuxd radamsa npm
idevicepair pair
npm install frida-compile
pip3 install frida-tools

On macOS, PacketLogger, which is part of the Additional Tools for Xcode, can decode various packets once the Bluetooth Debug Profile is installed. Moreover, if you open iOS crash logs with Xcode, it will add some symbols.

Setup and Fuzzing

Setup:

  • It is recommended to set up a virtual Python environment for frizzer.
  • Install the required packages by running in the frizzer directory.
  • The projects directory contains an example project to fuzz the MagicPairing protocol.
  • To build the harness compile the general harness and the specialized MagicPairing harness into one file.
  • cd into the harness directory and install frida-compile. Note that this needs to be run in that folder and can be directly installed as user by running npm install frida-compile.
  • Now run frida-compile ../projects/YOUR_PROJECT/YOUR_SPECIALIZED_HARNESS.JS -o ../projects/YOUR_PROJECT/harness.js. As this was installed in npm context it might require running npx frida-compile instead. Each time the harness changes, you need to rerun frida-compile.

Fuzzing:

  • Connect an iOS device to your computer.
  • It is advisable to put the phone in flight mode and turn on the "Do not disturb" feature to limit any other activity on the phone.
  • Run killall -9 bluetoothd to freshly start bluetoothd.
  • Make sure the phone does not connect to other Bluetooth devices.
  • Now, cd back into your project's directory, create the crashlog-directory (mkdir crashes) and run ../../frizzer/fuzzer.py fuzz -p .
  • Yay! Now collect zero days and obtain large amounts of cash from Apple! (Or collect a huge list of useless NULL-pointer dereferences...)

In short, for starting a new project, run:

cd harness
npx frida-compile ../projects/YOUR_PROJECT/YOUR_SPECIALIZED_HARNESS.JS -o ../projects/YOUR_PROJECT/harness.js
cd ../projects/YOUR_PROJECT/
mkdir crashes
../../frizzer/fuzzer.py fuzz -p .

You can start with a different seed by using frizzer/fuzzer.py fuzz --seed 1234 -p ..

Adding new iOS versions:

Currently, different versions of iOS are defined in bluetoothd.js. You can find these with the Ghidra versioning tool given an initial version that has all the required symbols. Note that some of them are not named in the original iOS binary, so ideally start with one that was already annotated before. Each time the bluetoothd.js changes, you need to re-run frida-compile.

Increasing bluetoothd capacities:

iOS crash logs are stored in Settings -> Privacy -> Analytics & Improvements -> Analytics Data. If they contain bluetoothd crashes of the pattern bluetoothd.cpu_resource-*.ips this indicates that the crash was caused due to exceeding resources. They can be increased as follows.

On an iPhone 7, run:

cd /System/Library/LaunchDaemons/
plistutil -i com.apple.jetsamproperties.D10.plist -o com.apple.jetsamproperties.D10.plist.txt
plistutil -i com.apple.jetsamproperties.D101.plist -o com.apple.jetsamproperties.D101.plist.txt

On iPhone SE2, these are in com.apple.jetsamproperties.D79.plist.:

cd /System/Library/LaunchDaemons/
plistutil -i com.apple.jetsamproperties.D79.plist -o com.apple.jetsamproperties.D79.plist.txt

Search for bluetoothd, update the priority to 19 (highest valid priority) and set the memory limit to something very high. Apply the same changes to both files.

<dict>
       <key>ActiveSoftMemoryLimit</key>
       <integer>24000</integer>
       <key>InactiveHardMemoryLimit</key>
       <integer>24000</integer>
       <key>EnablePressuredExit</key>
       <false/>
       <key>JetsamPriority</key>
       <integer>19</integer>
</dict>

Write the changes back and restart bluetoothd.

plistutil -i com.apple.jetsamproperties.D10.plist.txt -o com.apple.jetsamproperties.D10.plist
plistutil -i com.apple.jetsamproperties.D101.plist.txt -o com.apple.jetsamproperties.D101.plist
killall -9 bluetoothd

Respectively on the iPhone SE2:

plistutil -i com.apple.jetsamproperties.D79.plist.txt -o com.apple.jetsamproperties.D79.plist
killall -9 bluetoothd

Deleting old logs:

iOS stops saving crash logs for one program after the limit of 25 is reached. If loading a crash log with Xcode (via Simulators&Devices), some symbols are added to the stack trace. Once the limit is reached, the logs can either be removed via Xcode or directly on the iOS device by deleting them in the folder /var/mobile/Library/Logs/CrashReporter/.

A12+:

Starting from the iPhone XR/Xs, PAC has been introduced. This requires calling sign() on NativeFunction in FRIDA. While this is a no-op on earlier CPUs, this tremendously reduces speed on newer devices, but is required to make them work at all. We observed that ToothPicker operates at half the speed when using an iPhone SE2 instead of an iPhone 7.

Over-the-Air Fuzzer and Crash Replay

The MagicPairing implementation of the over-the-air fuzzer requires InternalBlue to be installed and can be executed by running python MagicPairingFuzzer.py TARGET_BD_ADDR.

If you want to reproduce crashes, use the ReplayCrashFile.py script, which can take a crash file and initiates an over-the-air connection with a payload based on the crash.

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

frankenstein

Broadcom and Cypress firmware emulation for fuzzing and further full-stack debugging
C
414
star
10

nexmon_csi

Channel State Information Extraction on Various Broadcom Wi-Fi Chips
C
286
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