andyvorld / LGSTrayBattery

A tray app used to track battery levels of wireless Logitech mouse.
GNU General Public License v3.0
369 stars 30 forks source link

How did you figure out the lghub_agent.exe websocket API #119

Closed ndbeals closed 3 months ago

ndbeals commented 4 months ago

Hello!

I'm trying to write a custom tool to help me manage LG HUB, and I'd like to discover what I can do with the websocket and/or HTTP API.

How did you figure out this code here?

Do you have any resources you could share, or point me in the right direction?

Thanks in advance.

andyvorld commented 4 months ago

The frontend of LG HUB is an electron app, you can actually unpack the app.asar and get to the javascript code. Initially what I did was forcibly enable the dev tools to look at the network request logs between the frontend and the agent. With the javascript code you can also get a glimpse of some of the commands as they would be stored as plaintext, but that is a bit harder as the javascript is minified and obfuscated.

The other way of looking at the code was to just use wireshark to analyze the tcp packets on localhost to port 9010, this should give the same result as watching the devtools.

ndbeals commented 3 months ago

Thank you very much for the help! extracting the ASAR worked, too bad the code is minified.

Were you able to undo the webpack bundling?

andyvorld commented 3 months ago

I don't recall, as reading the asar js and sniffing on wireshark was actually enough for my use case.

ndbeals commented 3 months ago

I see, thanks again for the help! it's been very useful and I've got what I wanted with your help.