In previous episodes, I:
- I bought devices from Xiaomi for a smart home and, using a soldering iron, made them work in a fun manner - without native servers through the home assistant ( link to the post )
- Wrapped the web interface from the home assistant into electron ( link to the post ) with support for notifications, menus, tochbar, etc. (code here)
- miio ( ) xiaomi_miio.
, . "" IoT lisp-, . .
Xiaomi:
- udp
- ,
- ,
Home Assistant:
- ,
- , Home Assistant
- Single Point of Failure
home assistant ā . ~1000, Home Assistant Raspberry PI ~4000, Home Assistant - . .
, CPU, , " ā , ā " . Home Assistant.
xiaomi , - , json-based dsl ( ).
"" , . zigbee/ble esp32/nrf51 , ā¦
.
Xiaomi CO2, , home assistant , , ā¦.
, , , , , arduino-ide ( -), , , , "" .
Proof of concept:
- CO2 ā 1
- ā 1
- ā 2
- home assistant ā 1
- cli ā 1
- ,
home-assistant Xiaomi "chuangmi.plug.v3 1.3.0_92 ESP8266 detected". , ESP8266 ā (~100/) , . Wi-Fi, I2C/SPI/UART/GPIO. ESP8266 Xtensa 80/160Mhz 32- 112 Tensilica ( - , tensilica 2013, esp8266 2014), 1 , .
. ESP8266 . esp201 ā , 2.54mm. arduino ā¦
ā¦
ESP8266. Xtensa Wi-Fi ā , - . nrf51 (~150/). , . .
CO2
aliexpress CO2 ( ). CCS811 ( ). (~500/) , CO2 TVOC , , 60, CCS811 .
LED 8x8 max7219 (~100/). ...
hlk-pm03 (~200/). 4- ; 220v AC, 3.3v DC esp8266.
, . . ( - ā ).
:
- SensorPack ā CCS811 ESP201 I2C ( , )
- Pixel ā LED 8x8, max7219 ESP201 SPI
SensorPack
Pixel :
:
- USB/UART
- UART "Hello world!"
- Wi-Fi
- CCS811 UART
- / led
20-50 . .
, :
- /
- /
- DSL /
udp , Xiaomi wi-fi , . ā udp , ip/ ā udp . ā . , ā xiaomi , ( ), , / "Faster! Harder! Scooter!" " ā !".
python.
python , .
, aes128-cbc :
- 128 ā Initialization Vector (IV) aes128
- ā , aes128
, IV python arduino api.
python
IV, , replay attack. , xiaomi replay attack, :) , IV IV , . ...
?
, , python-, , . , -. ? FLOPS , , , . , ?! , led , n ā .
JS . ESP8266 JS, . Lua, NodeMCU ESP8266. , lua .
lua ā¦
, :
- 1 esp201 lua
- NodeMCU lua , . , , ā¦
lua , .
uLisp
" ?ā ā , lisp. , , ---- lisp esp8266, uLisp. c ā @technoblogy :
- udp
- ulisp
- s-expression
- ip/
- api ulisp CCS811 Max7219
Lua , ulisp arduino ulisp . ulisp , , C++. , lisp arduino.
:
192.168.2.99 ā IP SensorBoard
192.168.2.174 ā IP Pixel
:
python tools/client.py --ip 192.168.2.99 --message '(+ 1 2)' --key YOUR_AES128_HEX_KEY
>> (+ 1 2)
<< 3
discovery. , ulisp.
python tools/client.py --ip 192.168.2.99 --message '(discovery)' --key YOUR_AES128_HEX_KEY
>> (discovery)
<< ("light-read" "co2-read" "tvoc-read" "humidity-read" "temperature-read")
CCS811
python tools/client.py --ip 192.168.2.99 --message '(list (co2-read) (tvoc-read))' --key YOUR_AES128_HEX_KEY
>> (list (co2-read) (tvoc-read))
<< (840 67)
REPL,
python tools/client.py --ip 192.168.2.174 --message '(discovery)' --key YOUR_AES128_HEX_KEY
>> (discovery)
<< ("show" "request")
show ā led
request ā , , ,
# led 30
(defun show_sensor (x)
(show
(format nil "CO2=~a TVOC=~a"
(first x)
(second x))
30000))
# 33 , show_sensor
(periodic 33000
(quote
(request
"192.168.2.99"
54321
(quote (list
(co2-read)
(tvoc-read)))
'show_sensor)))
Pixel
$ python tools/client.py --ip 192.168.2.174 --mfile ulisp_scripts/red.ulisp --key YOUR_AES128_HEX_KEY
Pixel SensorPack
lisp . Raspberry PI ā . , - Home Assistant lisp . SPoF, Home Assistant.
SensorPack USB Wi-Fi
, , , dsl, lisp . , s-expression ( json, , lisp ā s-expression).
I'll go to sculpt more other devices on the same protocol, next in line are ESP32 and NRF51 ...
And at the same time I will finish the firmware to a more grocery state, if you are suddenly interested, join!
PS All attacks on Home Assistant are made with great love, Iām even a bit of a committer there.