dchristl / macless-haystack

Create your own AirTag with OpenHaystack, but without the need to own an Apple device
GNU General Public License v3.0
356 stars 58 forks source link

Can't create patched firmware for NRF51 #108

Closed isibizi closed 3 months ago

isibizi commented 3 months ago

Hello, i have running an alpine linux with python3 and pip in a docker container. I Can generate keys, but can not patch the firmware for nrf51 beacon. The keys and the firmware are in the same folder. When i execute this command

export LC_CTYPE=C xxd -p -c 100000 LXWV5A_keyfile | xxd -r -p | dd of=nrf51_firmware.bin skip=1 bs=1 seek=$(grep -oba OFFLINEFINDINGPUBLICKEYHERE nrf51_firmware.bin | cut -d ':' -f 1) conv=notrunc

i see this error message:

image

Is it possible that these command ist not running in alpine container?

isibizi commented 3 months ago

OK, i have the solution (step-by-step)

To running the keygen in an alpine container use following steps

docker run -it --restart unless-stopped --name haystack_keygen --volume heystack_keygen:/root/haystack_keygen alpine:latest

after this command you are automatically in the bash shell of the container

image

install pip apk add py3-pip

install crypthography pip install cryptography --break-system-packages

install vim apk add vim

install wget apk add wget

Navigate to the folder: cd /root/haystack_keygen

Download generate_keys.py wget https://github.com/dchristl/macless-haystack/releases/download/v2.2.0/generate_keys.py

Change execution permissions for generate_keys.py: chmod +x generate_keys.py

Run generate_keys.py: ./generate_keys.py

Change to the output folder: cd output/

Download firmware, in my example nrf51 wget https://github.com/dchristl/macless-haystack/releases/download/v2.2.0/nrf51_firmware.bin

grep is not working on Alpine, so instead, we use BusyBox. The command to create the firmware should be changed as follows: @dchristl

export LC_CTYPE=C offset=$(od -An -v -t x1 nrf51_firmware.bin | tr -d ' \n' | awk '{ n = index($0, "4f46464c494e4546494e44494e475055424c49434b455948455245"); if (n) print (n - 1) / 2 }') xxd -p -c 100000 PREFIX_keyfile | xxd -r -p | dd of=nrf51_firmware.bin skip=1 bs=1 seek=$offset conv=notrunc