Skip to content

Instantly share code, notes, and snippets.

View afedotov's full-sized avatar

Andy Fedotov afedotov

  • Moscow, Russia
  • 00:31 (UTC +03:00)
View GitHub Profile
@afedotov
afedotov / gan-mac-faq.md
Last active February 3, 2024 06:15
GAN Smart Cubes MAC address FAQ

Q: What is the cube MAC address?
A: MAC is the Bluetooth device hardware address, each device instance has it unique. It has 48 bits and typically represented as 6 bytes written in hexadecimal and separated by colons or hyphens, for example AB:12:34:5D:34:12.

Q: Why MAC address is ever needed?
A: The GAN smart cube application-layer protocol encrypts all data using AES cypher. Encryption keys are unique for each cube instance, and generated based on cube's MAC address. So to decrypt any data sent by cube it is required for application to know cube MAC address.

Q: But I used another GAN cube with Cubeast, or different smartcubing software, and it does not ever ask me for the MAC address.
A: For some GAN smart cubes range used for MAC addresses was small enough, so Cubeast try to bruteforce address automatically. This can be done in reasonable amount of time. But this is not an option for newer cubes and MAC can't be guessed. Also some software like platform-native applications h

@afedotov
afedotov / gan-timer-protocol.md
Last active August 18, 2023 18:29
GAN Smart Timer bluetooth protocol

GAN Smart Timer bluetooth protocol

BLE service

Main service = 0000fff0-0000-1000-8000-00805f9b34fb
    Timer state characteristic (notify) = 0000fff5-0000-1000-8000-00805f9b34fb
    Stored time characteristic (read) = 0000fff2-0000-1000-8000-00805f9b34fb
@afedotov
afedotov / gan-connect-poc.ts
Created February 3, 2023 02:01
Proof-of-Concept: extract GAN smart cube MAC address using Web Bluetooth
/**
*
* Proof-of-Concept: extract GAN smart cube MAC address using Web Bluetooth.
* MAC address resides at last 6 bytes in Manufacturer Specific Data field
* of the bluetooth advertising packet.
*
* In order for this to work it is necessary to enable following flag in Chrome:
*
* chrome://flags/#enable-web-bluetooth-new-permissions-backend
*
@afedotov
afedotov / create-server-crt.sh
Created April 17, 2022 11:30
Create dev-root-CA signed server certificate on macOS for local development purposes
#!/bin/bash
#
set -e
[[ $# -eq 2 ]] || {
echo -ne "\nUsage: $(basename $0) CERT_HOST_FQDN CERT_HOST_IP\n\n"
exit 1
}
@afedotov
afedotov / create-root-CA.sh
Created April 17, 2022 11:25
Create self-signed root CA certificate on macOS for local development purposes
#!/bin/bash
#
set -e
openssl genrsa -aes256 -passout env:PASSWORD -out certs/dev-root-CA-key.pem 4096
openssl req \
-new \
-sha256 \
@afedotov
afedotov / DynamicPollEnricher.java
Created July 10, 2015 18:32
Camel message processor that implements behavior of .pollEnrich() pattern with dynamic Endpoint URI
package org.apache.camel.processor;
import org.apache.camel.*;
import org.apache.camel.util.ExchangeHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.helpers.MessageFormatter;
import java.util.LinkedList;
import java.util.Map;