|
| 1 | + |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <link rel="stylesheet" href="../../css/spectre.min.css"> |
| 5 | + </head> |
| 6 | + <body> |
| 7 | + <p>Follow the steps on <a href="https://github.com/seemoo-lab/openhaystack#how-to-use-openhaystack">https://github.com/seemoo-lab/openhaystack</a> to install OpenHaystack and get a unique base64 code</p> |
| 8 | + <p>Then paste the key in below and click <b>Upload</b></p> |
| 9 | + |
| 10 | + <p>Base64 key: <input type="text" id="key" class="form-input" value="..."></p> |
| 11 | + <p id="keyStatus"> </p> |
| 12 | + |
| 13 | + <p>Click <button id="upload" class="btn btn-primary">Upload</button></p> |
| 14 | + |
| 15 | + |
| 16 | + <script src="../../core/lib/customize.js"></script> |
| 17 | + |
| 18 | + <script> |
| 19 | + function keyChanged() { |
| 20 | + var keyValue = document.getElementById("key").value.trim(); |
| 21 | + var status = "👍 Key Ok.." |
| 22 | + if (keyValue.length!=40) status = "⚠️ Key should be 40 characters long"; |
| 23 | + if (!keyValue.match(/^[A-Za-z0-9+\/=]+$/)) status = "⚠️ Key contains non-base64 characters"; |
| 24 | + document.getElementById("keyStatus").innerText = status; |
| 25 | + } |
| 26 | + document.getElementById("key").addEventListener("changed", keyChanged); |
| 27 | + document.getElementById("key").addEventListener("keyup", keyChanged); |
| 28 | + // When the 'upload' button is clicked... |
| 29 | + document.getElementById("upload").addEventListener("click", function() { |
| 30 | + // get the text to add |
| 31 | + var keyValue = document.getElementById("key").value.trim(); |
| 32 | + // build the app's text using a templated String |
| 33 | + var appJS = `/* |
| 34 | +OPENHAYSTACK |
| 35 | +A framework for tracking personal Bluetooth devices via Apple's massive Find My network |
| 36 | +https://github.com/seemoo-lab/openhaystack/issues/59#issuecomment-1303236903 |
| 37 | +*/ |
| 38 | +const key_b64 = ${JSON.stringify(keyValue)}"; |
| 39 | +
|
| 40 | +function b64ToArray(str) { |
| 41 | + let bstr = atob(str); |
| 42 | + let arr = []; |
| 43 | + for (let i = 0; i < bstr.length; i++) { |
| 44 | + arr[i] = bstr.charCodeAt(i); |
| 45 | + } |
| 46 | + return arr; |
| 47 | +} |
| 48 | +
|
| 49 | +const key = b64ToArray(key_b64); // public key |
| 50 | +const mac = [ key[0] | 0b11000000, key[1], key[2], key[3], key[4], key[5] ].map(x => x.toString(16).padStart(2, '0')).join(':'); // mac address |
| 51 | +const adv = [ 0x1e, 0xff, 0x4c, 0x00, 0x12, 0x19, 0x00, key[6], key[7], key[8], key[9], key[10], key[11], key[12], key[13], key[14], key[15], key[16], key[17], key[18], key[19], key[20], key[21], key[22], key[23], key[24], key[25], key[26], key[27], key[0] >> 6, 0x00 ]; // advertising packet |
| 52 | +NRF.setAddress(mac); |
| 53 | +NRF.setAdvertising(adv, {interval:5000}); |
| 54 | +`; |
| 55 | + // send finished app |
| 56 | + sendCustomizedApp({ |
| 57 | + storage:[ |
| 58 | + {name:".boot0", content:appJS}, |
| 59 | + ] |
| 60 | + }); |
| 61 | + }); |
| 62 | + |
| 63 | + </script> |
| 64 | + </body> |
| 65 | +</html> |
0 commit comments