BangleApps/apps/openhaystack/custom.html

57 lines
2.5 KiB
HTML
Raw Normal View History

<html>
<head>
<link rel="stylesheet" href="../../css/spectre.min.css">
</head>
<body>
<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>
<p>Then paste the key in below and click <b>Upload</b></p>
<p>Base64 key: <input type="text" id="key" class="form-input" value="..."></p>
<p id="keyStatus">&nbsp;</p>
<p>Click <button id="upload" class="btn btn-primary">Upload</button></p>
<script src="../../core/lib/customize.js"></script>
<script>
function keyChanged() {
var keyValue = document.getElementById("key").value.trim();
var status = "👍 Key Ok.."
if (keyValue.length!=40) status = "⚠️ Key should be 40 characters long";
if (!keyValue.match(/^[A-Za-z0-9+\/=]+$/)) status = "⚠️ Key contains non-base64 characters";
document.getElementById("keyStatus").innerText = status;
}
document.getElementById("key").addEventListener("changed", keyChanged);
document.getElementById("key").addEventListener("keyup", keyChanged);
// When the 'upload' button is clicked...
document.getElementById("upload").addEventListener("click", function() {
// get the text to add
var keyValue = document.getElementById("key").value.trim();
// build the app's text using a templated String
var appJS = `/*
OPENHAYSTACK
A framework for tracking personal Bluetooth devices via Apple's massive Find My network
https://github.com/seemoo-lab/openhaystack/issues/59#issuecomment-1303236903
*/
{
const key = E.toUint8Array(atob(${JSON.stringify(keyValue)})); // public key
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
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
NRF.setAddress(mac);
NRF.setAdvertising([adv,{}],{whenConnected: true, interval: 1000}); // advertise AirTag *and* normal device name (to remain connectable)
}
`;
// send finished app
sendCustomizedApp({
storage:[
{name:"openhaystack.boot.js", content:appJS},
]
});
});
</script>
</body>
</html>