Skip to content

Latest commit

 

History

History
514 lines (440 loc) · 26.4 KB

enecsys-gateway-cg-a-ab-us-1.org

File metadata and controls

514 lines (440 loc) · 26.4 KB

Enecsys Gateway CG-A-AB-US-1

Intro

The Enecsys Gateway is a Zigbee gateway allowing communications between the Enecsys microinverters and their monitoring backend. The Enecsys company is unfortunately defunct since 2015 and their DNS domains have been taken over by a UK enecsys owner who created his own monitoring system on https://enecsys-monitoring.com/

Zigbee Radio

The gateway contains a ETRX2-PA Zigbee module manufactured by Telegesis. More information about this module can be found in the page describing the Enecsys SMI-360-72 Inverter. This module is connected with an UART on the main MCU. The uart settings are 19200 8n1.

When the gateway boots and initializes its radio interfaces it starts to send broadcast frames every 15 seconds:

Some more beacons can be found in gateway-beacon.txt. Unfortunately the beacons are encrypted with an unknown Zigbee Network key. This key is likely preconfigured as it would make sense for such a closed-loop system. Trying to decrypt the messages using the typical Zigbee key used by the Home Automation Profile (0x5A 0x69 0x67 0x42 0x65 0x65 0x41 0x6C 0x6C 0x69 0x61 0x6E 0x63 0x65 0x30 0x39) does not work.

As for the inverter, when it boots it first sends out a standard Beacon Request Zigbee packet every 77 (sic!) seconds, see traffic inverter-beacon.txt:

After receiving an answer to the Beacon Request from the gateway the standard association process starts. This has been captured and is available in zigbee-inverter-connect.pcapng and inverter-associate.txt as a text dump. After the exchange of some data back and forth the gateway indicates that the inverter is connected by incrementing a counter on the LCD.

Network interface

Device bootup

During the gateway bootup the following network traffic can be seen:

boot.pcapng

Port scans

TCP port scan results for the gateway’s IPv4 address:

UDP port scan results for the gateway’s IPv4 address:

The Web Interface

The default credentials for the web interface are admin/password. You can tell that the gateway is (c) 2009 as there is no way to change the admin password ;).

The following endpoints have been detected on the device:

EndpointDescriptionNotes
/Main user interface
/index.htm
/debug.htmDebug interface HTML layout
/ajax.xmlDebug interface polling endpoint
/mpfsuploadMPFS Image Upload

Main user interface

The main user interface has basic settings like IP address and it can be used to set the remote monitoring server hostname and port. Apart from that NTP and proxy can be configured. Here is a screenshot of the main UI:

thumb-main-ui.png

Debug Interface

The debug interface allows us to see what messages the Zigbee Module UART sends to the main MCU. These appear to be raw decrypted contents of Zigbee frames from the inverters as well as some traffic generated by the Zigbee module firmware itself even when there are no inverters connected. Some of the layout of these messages has been reverse engineered in the section near the end of the document. There is also a status display about the Zigbee network and monitoring server connection. The interface itself looks like this:

thumb-debug-ui.png

The debug UI polls the /ajax.xml endpoint in the background in order to receive the data about the latest messages received from the Zigbee module. The endpoint returns the following XML:

The MPFS upload

The MPFS is an internal HTTP upload server enabled by default in the Microchip TCP/IP stack. This feature can be used to upload files into the internal flash and possibly even modify firmware. There has been at least one device where this is possible: https://vulners.com/talos/TALOS-2018-0511. In the case of our device this won’t be much use however as all of the Zigbee traffic encryption happens in the Zigbee module and the Microchip MCU is just a simple bridge which forwards the messages to the remote monitoring server.

Debug Messages Format

A number of debug messages have been captured so far when the device and inverter were in various operational modes. Based on simple time correlation the messages sent out from the debug interface seem to be plaintexts for the traffic exchanged via Zigbee. Based on the knowledge gained the development of a parser for the messages has been started: enecsys-watch-zigbee.py. Here is an example set of messages together with their hexdumps:

All of the messages fall into two patterns:

MessageFlavorContentsChecksumKey-value pairsNotes
WZ=qcE1dwCaxjQAAAZhIQEAAAAMClP1BfcFAJrGNEg=AE,S=2000011689WZqcE1dwCaxjQAAAZhIQEAAAAMClP1BfcFAJrGNEg=AES=20000116892000011689 is the serial number of the Zigbee module inside the gateway
WS=9QX3BQCaxjQAAAbLIQEAAAAAFDADiAEAAgAAAAAAAAAYAY0AAwQF00WS9QX3BQCaxjQAAAbLIQEAAAAAFDADiAEAAgAAAAAAAAAYAY0AAwQF00

The first characters consitute what was named the “flavor” of a message. The flavor determines the syntax of the next parts as well as the message source. After the flavor come the messages contents (encoded with URL-safe base64), two hexadecimal digits which I assume is a checksum of some kind and after the comma key-value pairs. There was only one key-value pair seen so far and that is ‘S’ which contains the serial number of the Zigbee module contained within the gateway that is generating the message.

Based on many observations I have deduced that the WZ messages are generated by the gateway itself as they are present even when there are no inverters connected. The schema used to calculate what I assume to be the checksum has not been reverse-engineered yet. The meaning of the key-value pairs is obvious at this point. Further information is revealed after decoding the base64-encoded payloads. The structure inside is similar for both flavors and a number of common fields are used to encode the source of the message, type, etc. See below:

DataDescriptionNotes
a9 c1 35 77 00 9a c6 34EUI64 of the sourceBytes are inverted, gateway EUI64 is 34:c6:9a:00:77:35:c1:a9
00 00 07 51uptimeUnit is 500ms
21 01type
00 00 00 0fcounterSequence number
0acontent length
53 f5 05 f7 05 00 9a c6 34 48content

Similar for a WS flavored message:

DataDescriptionNotes
f5 05 f7 05 00 9a c6 34EUI64 of the sourceBytes are inverted, inverter EUI64 is 34:c6:9a:00:05:f7:05:f5
00 00 06 cbuptimeUnit is 500ms
21 01type
00 00 00 00counterSequence number
14content length
30 03 88 01 00 02 00 00 00 00 00 00 00 18 01 8d 00 03 04 05content

Most of the interesting information is present in the ‘content’ section of every message, thus far the messages have been documented in the parser script mentioned above. To quickly summarize:

FlavorTypeDesciptionExample messagesNotes
WZ0x2100BootupWZ=qcE1dwCaxjQAAAAAIQAAAAAAA1BSAg==96,S=2000011689
WZ=qcE1dwCaxjQAAAAAIQAAAAABGU4SAGS13J5ge-wZ4QAAAAAAAAAAAAAAAAA=DF,S=2000011689
WZ0x2101Connectivity reportWZ=qcE1dwCaxjQAABDnIQEAAAASClOpwTV3AJrGNEg=9A,S=2000011689Sends the EUI64 of other Zigbee devices on the network
WZ=qcE1dwCaxjQAAAdRIQEAAAAPClP1BfcFAJrGNEg=60,S=2000011689
WS0x2100BootupWS=9QX3BQCaxjQAAAB4IQAAAAABPXIBAwX3BfVXU0ktMDAwMDMAAAAAAAAAADwAAAAAMDEtMDItMTIgMDI6MjH__wAAAAAAAAAAAAAAAAAAAAA=29
WS0x2101Power measurementWS=9QX3BQCaxjQAAE4HIQEAAAARFDADiAMAAgAAAAAAAEUdAY4AAwAFE1Contains DC and AC power, AC frequency, efficiency as well as AC voltage (inverter idle)
WS0x2102Power measurementWS=9QX3BQCaxjQAAAdYIQIAAAAAFDADiAEAAgAAAAAAAAAZAY0AAwAF81Contains DC and AC power, AC frequency, efficiency as well as AC voltage (inverter online)

The 0x2101 and 0x2102 WS messages seem to contain identical data and look to be related to the state of the inverter itself. For example, the 0x2101 messages are sent always, even when the inverter is connected only to the DC side. However the exact difference is not clear at this point.

Based on a screenshot found for a gateway software that is being sold on eBay (https://www.ebay.com/itm/283656242209) it looks like there are additional items reported by the inverter which have not yet been located:

  • serial number
  • lifetime kWh
  • DC amps
  • temperature