mcrute / go-inform

Ubiquiti Inform Protocol in Golang
BSD 3-Clause "New" or "Revised" License
17 stars 0 forks source link

Would it be feasible or make sense to write a protobuf definition for the inform data so it could be used/interfaced from any language supporting protobuf? #1

Closed dragon788 closed 1 year ago

dragon788 commented 3 years ago

https://developers.google.com/protocol-buffers

https://github.com/protocolbuffers/protobuf#protobuf-runtime-installation

mcrute commented 3 years ago

I've not done much work on this in a while and am currently exploring other (hopefully soon to be open-sourced) approaches using mqtt and some custom firmware. I don't see the value that protobuf would provide given that the inner payload of the inform is a JSON blob. That being said, if you want to submit a pull-request as a proposal of what you're thinking I'd be willing to consider merging it.

dragon788 commented 3 years ago

Hmm, is it using JSONP or just regular JSON with a number of fairly static fields defined for the messages?

mcrute commented 3 years ago

The protocol is basically TR-069 with a plain JSON payload. The payload structure seemed pretty static but was device dependent (access points different than mFI devices). I didn't actually test what the Unifi routers are sending but I think it's a variant of the config.json used by the controller. I also haven't tested any new Dream based hardware.

dragon788 commented 3 years ago

Interesting, I hadn't heard of TR-069 before, but while looking it up I found TR-369 which might be what they are using. There is even a mention of using protobuf to allow for a more flexible data structure to accommodate new endpoint types.

https://usp.technology/specification/

https://www.qacafe.com/articles/data-collection-analytics-with-tr069-tr369-usp/

mcrute commented 3 years ago

Have you tried decrypting the packets and testing them? I have not done so for newer generations of hardware but it was definitely TR-069 encapsulated JSON back when I did the original reverse engineering. That being said, the protocol does allow for setting the protocol version and the data version, so it would be at least theoretically possible for them to use protobufs in newer products.

Out of curiosity, are you interested in interoperability with UI gear or are you trying to use this protocol for a different design?

mcrute commented 3 years ago

It's worth noting that the UI implementation is more TR-069 inspired than it is implemented per the spec. It doesn't use XML or SOAP for signalling within a packet. It also uses an initial static bootstrapping secret for encryption and then negotiates a per-device key after that. TLS wasn't introduced into the mix until about a year ago and even then it's not strictly mandatory IIRC. This is far from a secure protocol, especially for someone with passive listening or man-in-the-middle capability on a network that's bootstrapping to a controller.