MatthewKuKanich / FindMyFlipper

The FindMy Flipper app turns your FlipperZero into an AirTag or other tracking device, compatible with Apple AirTags and Samsung SmartTag and Tile Trackers. It uses the BLE beacon to broadcast, allowing users to clone existing tags, generate OpenHaystack key pairs for Apple's FindMy network, and customize beacon intervals and transmit power.
1.59k stars 51 forks source link

Importing generated keys in openhaystack #7

Closed lupettohf closed 8 months ago

lupettohf commented 8 months ago

I'm trying to import the generated keys inside OHS however the import function looks for a .plist file; I tried exporting one and it seems holding more keys than the one generated by the python script. Any additional step to perform?

Chapoly1305 commented 8 months ago

Having the same issue. Have not used OpenHaystack before so not sure how to proceed. @MatthewKuKanich if you would be so kind as to add a section to the readme documenting importing into OpenHaystack and adding to the iOS FindMy app I would be really grateful!

Dear @Martyfree123 and @lupettohf , I am happy to assist in questions and make clarification. As you asked,

  1. To use OpenHayStack for tracking, you must use MacOS lower than version 14 (https://github.com/seemoo-lab/openhaystack/discussions/224). If you do own a device, I believe a convertor script can be provided without much of effort. If you do not own a Mac device or the system has been upgraded to 14 and beyond. The alternative solution includes,
  2. To use FindMy, you need to firstly have a legit AirTag or certified third-part tag in FindMy network, you may clone the mac address and payload, and remove the battery from AirTag. If you do not have a legit tag, unfortunately, key generated by this project and OpenHayStack are both unlikely able to add into the Apple FindMy app, due to the device in such compatibility requires to pay and pass the Apple MFi certification. You may consider use software, e.g., OwnTags. With the combination of https://github.com/Chapoly1305/FindMy to self-host a service, you should have a similar but less accurate result.

To import existing .keys to OpenHayStack, you need to firstly generate the .plist file. Try place this script at the root of this project, then use this script to convert the .keys to .plist. The converted .plist can be found under ./keys directory. Modify to match your needs accordingly.

import os, plistlib

if __name__ == "__main__":
    keys = []

    if not os.path.exists("keys"):
        print("No keys found.")
        exit(1)

    for fname in os.listdir("keys"):
        if not fname.endswith(".keys"):
            continue

        with open(f"keys/{fname}", "rb") as f:
            this_key = {}
            for line in f.readlines():
                line_split = line.decode("utf-8").replace('\n', '').replace(" ", "").split(":")
                key, value = line_split[0], line_split[1]
                if key == "MAC":
                    this_key["id"] = int(value, 16)
                elif key == "Privatekey":
                    this_key["privateKey"] = value.encode("utf-8")
            this_key["colorComponents"] = [0.0, 0.0, 0.0, 0.0]
            this_key["isActive"] = True
            this_key["lastDerivationTimestamp"] = 0
            this_key["symmetricKey"] = b""
            this_key["updateInterval"] = 3600
            this_key["icon"] = "briefcase.fill"
            this_key["isDeployed"] = True
            this_key["colorSpaceName"] = "kCGColorSpaceExtendedSRGB"
            this_key["usesDerivation"] = False
            this_key["name"] = f"OHS_{hex(this_key['id'])[2:].upper()}"
            this_key["oldestRelevantSymmetricKey"] = b""

            keys.append(this_key)

    with open(f"keys/ohs.plist", "wb") as f:
        plistlib.dump(keys, f)
image