Skip to content

Reverse engineering the LSC 'smart' plug - 30 oct

@
Oct 31, 20265 min read

o today I have finally cracked the LSC 'smart' plug. After multiple days of messing around with it, it finally gave way and I was able to flash it with my own software.

1. The "OTA" hack

For the punishing smart home we required to also have smart plugs so we could turn appliances on and off from a distance. So I quite quickly found that the cheap LSC plug from action was hackable.

The wiki talked about that some models might be vulnerable to a bug with the ESP8266's firmware, which as a result would be able to allow you to simulate an update server and flash the smart plug with your custom firmware.

To get this to work I would be required to have a linux device with a wifi adapter, the tested devices included raspberry pi's. So I grabbed my 4GB Pi 4B, then realized I forgot the password of the OS that was on it, reflashed the OS with a newer version of the raspbian OS and went to try out the bug. After some troubleshooting I was finally ready to try hacking the smart plug. The Pi booted up a custom Access Point (AP) and connected my phone to it. Turns out it was not that easy. I tried multiple times putting the smart plug in pairing mode, I then quickly discoverd the bug was likely patched and later on went to discover they even switched chips entirely in their newer models.

So I went on to the next method.

2. Direct flashing to chip

Opening it up!

When the OTA hack did not work out I went on to the more difficult approach, by opening it up. Prying around with a flathead screwdriver makes short work of it, although damaging the encasing a bit, but not destroying it. On the PCB for the microcontroller it showed T1-2S-NL which after googling it turns out to be a completely different microcontroller then expected, it was a BK7238. At this point I was already spending way too much time on it and it was getting late. Next to that I did not have the appropriate tools to continue so I put it aside and went on with my day, also finishing up my halloween costume. Although my Halloween costume is not really halloween themed I might write a blog post about it later.

Soldering the pins!

After
Before
BeforeAfter

The following day after being done with giving a seminar I went right to prepping for soldering my Halloween project and the smart plug. I grabbed a few extra jumper wires I had laying around and primed the soldering iron tip. And after some time of soldering all 4 jumper wires were connected. (RX, TX, GND and 3v3)

After completion it was already almost closing time so I went on home to prepare for a Halloween party.

The flashing

Now that the wires have been soldered we can start the complicated process of flashing. I ordered a USB to UART Serial adapter last year for a project I never started. So I used multiple flashing softwares. Starting with BK7231GUIFlashTool which at first didn't seem to be working. So I tried using LTChiptool, which gave me a bit more information. As it turned out all the COM/serial ports I was trying at that point were related to the bluetooth module of my laptop. And found out in device manager that I did not have a proper driver for the USB to UART adapter. By googling for a driver for the specific chip of my USB I easily found one that I could install, it even came with ARM64 binaries. Now that I finally had the right drivers I will be able to instantly flash and have no more problems right? No, because the controller uses the UART lanes for some of it's own functions, the controller will garble up all the data you try to send it. It requires exact timing where the PC sends a packet to put it in flashing mode and the module being exactly at the right startup state. What do you do if you don't have such timing? Well just do what I did and short the CEN to GND a dozen of times until it shows on the PC as successful!

The result!

After that it was finally done, I had done did it! Now the only thing that was left to do is program the OpenBK Firmware with the correct configuration, first set the wifi to use then allocate the right pins with the right devices. This was quite easily done by extracting the Tuya configuration from before. BK7231GUIFlashTool will automatically show you the allocations after it has done a backup allowing you to copy that and paste into a WebGUI of the microcontroller that will then automatically function as if it wasn't even reflashed at all. I did end up having a small problem where one of the two smart plugs I had didn't show the estimated power usage. This might have been broken during the soldering process, but is not important to the project. The second device does still have this function but is as of yet uncalibrated. It started showing 260V on a 230V net. So I manually set/calibrated it to an estimate of the voltage and it has worked quite well since then. I will add some more pictures down below.

Thanks for reading, hope you have enjoyed reading about my adventure in a fraction of the time that it took to make it. If you enjoyed you can always subscribe to the blog and get notification if any new post is made! Have a (reverse) engineeringfull day!

Did you enjoy this article?

Recommend it — Standard Reader surfaces well-loved writing to more readers across the network.

Across the AtmosphereDiscussions