Initial commit

This commit is contained in:
Milan Stute
2021-03-03 14:35:18 +01:00
commit 52dde375e3
93 changed files with 8048 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
# nRF SDK
nrf51_sdk_v4_4_2_33551/
nrf51_sdk_v4_4_2_33551.zip
# Build artifacts
*.bin
*.map
*.out
*.o
+8
View File
@@ -0,0 +1,8 @@
Copyright 2021 Secure Mobile Networking Lab (SEEMOO)
Copyright 2021 The Open Wireless Link Project
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+34
View File
@@ -0,0 +1,34 @@
PLATFORM := nRF51822
NRF51_SDK_PATH := $(shell pwd)/nrf51_sdk_v4_4_2_33551
NRF51_SDK_DOWNLOAD_URL := https://developer.nordicsemi.com/nRF5_SDK/nRF51_SDK_v4.x.x/nrf51_sdk_v4_4_2_33551.zip
OPENHAYSTACK_FIRMWARE_PATH := $(shell pwd)/../OpenHaystack/OpenHaystack/HaystackApp/firmware.bin
export PLATFORM
export NRF51_SDK_PATH
ifeq ($(DEPLOY_PATH),)
DEPLOY_PATH := /Volumes/MICROBIT
endif
offline-finding/build/offline-finding.bin: $(NRF51_SDK_PATH) blessed/.git
$(MAKE) -C blessed
$(MAKE) -C offline-finding
$(NRF51_SDK_PATH):
wget $(NRF51_SDK_DOWNLOAD_URL)
unzip $(NRF51_SDK_PATH).zip -d $(NRF51_SDK_PATH)
blessed/.git:
git submodule update --init
clean:
$(MAKE) -C blessed $@
$(MAKE) -C offline-finding $@
install: offline-finding/build/offline-finding.bin
cp $< $(DEPLOY_PATH)
update-app: offline-finding/build/offline-finding.bin
cp $< $(OPENHAYSTACK_FIRMWARE_PATH)
.PHONY: clean install update-app
+47
View File
@@ -0,0 +1,47 @@
# OpenHaystack Firmware for nRF51822
This project contains a PoC firmware for Nordic nRF51822 chips such as used by the [BBC micro:bit](https://microbit.org).
After flashing our firmware, the device sends out Bluetooth Low Energy advertisements such that it can be found by [Apple's Find My network](https://developer.apple.com/find-my/).
## Disclaimer
Note that the firmware is just a proof-of-concept and currently only implements advertising a single static key. This means that **devices running this firmware are trackable** by other devices in proximity.
## Requirements
You need to [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads) to build the firmware.
On macOS, you can install it via [Homebrew](https://brew.sh):
```bash
brew install --cask gcc-arm-embedded
```
## Build
You need to specify a public key in the firmware image. You can either directly do so in the [source](offline-finding/main.c) (`public_key`) or patch the string `OFFLINEFINDINGPUBLICKEYHERE!` in the final firmware image.
To build the firmware, it should suffice to run:
```bash
make
```
from the main directory, which also takes care of downloading all dependencies. The deploy-ready image is then available at `offline-finding/build/offline-finding.bin`.
## Deploy
To deploy the image on a connected nRF device, you can run:
```bash
make install DEPLOY_PATH=/Volumes/MICROBIT
```
*We tested this procedure with the BBC micro:bit V1 only, but other nRF51822-based devices should work as well.*
## Author
- **Milan Stute** ([@schmittner](https://github.com/schmittner), [email](mailto:mstute@seemoo.tu-darmstadt.de), [web](https://seemoo.de/mstute))
## License
This firmware is licensed under the [**MIT License**](LICENSE).
+1
Submodule Firmware/blessed added at 48d5b6ccdf
+6
View File
@@ -0,0 +1,6 @@
PROJECT_TARGET = offline-finding
PROJECT_SOURCE_FILES = main.c
BLESSED_PATH := ../blessed
include $(BLESSED_PATH)/examples/Makefile.common
+70
View File
@@ -0,0 +1,70 @@
/**
* OpenHaystack Tracking personal Bluetooth devices via Apple's Find My network
*
* Copyright © 2021 Secure Mobile Networking Lab (SEEMOO)
* Copyright © 2021 The Open Wireless Link Project
*
* SPDX-License-Identifier: MIT
*/
#include <stdint.h>
#include <string.h>
#include <blessed/bdaddr.h>
#include <blessed/evtloop.h>
#include "ll.h"
#define ADV_INTERVAL LL_ADV_INTERVAL_MIN_NONCONN /* 100 ms */
/* don't make `const` so we can replace key in compiled binary image */
static char public_key[28] = "OFFLINEFINDINGPUBLICKEYHERE!";
static bdaddr_t addr = {
{ 0xFF, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF },
BDADDR_TYPE_RANDOM
};
static uint8_t offline_finding_adv_template[] = {
0x1e, /* Length (30) */
0xff, /* Manufacturer Specific Data (type 0xff) */
0x4c, 0x00, /* Company ID (Apple) */
0x12, 0x19, /* Offline Finding type and length */
0x00, /* State */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, /* First two bits */
0x00, /* Hint (0x00) */
};
void set_addr_from_key() {
/* copy first 6 bytes */
/* BLESSED seems to reorder address bytes, so we copy them in reverse order */
addr.addr[5] = public_key[0] | 0b11000000;
addr.addr[4] = public_key[1];
addr.addr[3] = public_key[2];
addr.addr[2] = public_key[3];
addr.addr[1] = public_key[4];
addr.addr[0] = public_key[5];
}
void fill_adv_template_from_key() {
/* copy last 22 bytes */
memcpy(&offline_finding_adv_template[7], &public_key[6], 22);
/* append two bits of public key */
offline_finding_adv_template[29] = public_key[0] >> 6;
}
int main(void) {
set_addr_from_key();
fill_adv_template_from_key();
ll_init(&addr);
ll_set_advertising_data(offline_finding_adv_template, sizeof(offline_finding_adv_template));
ll_advertise_start(LL_PDU_ADV_NONCONN_IND, ADV_INTERVAL, LL_ADV_CH_ALL);
evt_loop_run();
return 0;
}