Skip to content

Commit 97bed18

Browse files
author
ictar
committed
add translation for "Hacking the Worcester Wave thermostat in Python –
Part 3"
1 parent 09fc2b0 commit 97bed18

2 files changed

Lines changed: 21 additions & 18 deletions

File tree

‎Others/README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
紧接着第一部分,我们看看如何用starttls-mitm进行合法的中间人攻击以破解app和服务器之间加密的通信,看看如何使用反编译器反编译apk以获得消息中的信息加密算法以进行逆向,最终获得完整的明文交互信息……
2020

21+
- [用Python玩转Worcester Wave恒温器-第三部分](./用Python玩转Worcester Wave恒温器-第三部分.md)
22+
23+
收尾章节。我们可以看到如何利用破解出来的信息达到实际的控制。并且,作者还在Github上分享了他的源代码!
24+
2125
- [psutil 4.0.0以及如何获得Python中“真正的”进程内存和环境](./psutil 4.0.0以及如何获得Python中“真正的”进程内存和环境.md)
2226
描述如何用psutil 4.0.0获得“真正的”进程内存度量以及进程环境变量的一些信息。
2327

‎Others/用Python玩转Worcester Wave恒温器-第三部分.md‎

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
---
44

5-
So, [last time](http://blog.rtwilson.com/hacking-the-worcester-wave-thermostat-in-python-part-2/) we worked out how communications were encrypted and managed to read the current status of the heating system (whether the boiler is on or not, the current temperature, and so on). That’s great – but it’d be even better if we could actually control the thermostat from Python: set the temperature, change from timer mode to manual mode etc. That’s what we’re going to focus on today.
5+
所以,[前面](http://blog.rtwilson.com/hacking-the-worcester-wave-thermostat-in-python-part-2/)我们找出了通信是如何被加密的,并且设法读取到了加热系统的当前状态(热水器是否开启,当前温度,等等)。这很棒 —— 但是如何我们能实际地用Python控制恒温器,这将会更棒,例如,设置温度,由定时器模式修改到手动模式,等等。这就是我们今天要关注的。
66

7-
So, using the same ‘man-in-the-middle’ approach I monitored the communications from the app as I changed various settings. When changing the temperature I got a message like this:
7+
所以,使用相同的‘中间人’方法,在我修改多项设置的同时,我监控来来自应用的通信。当修改温度的时候,我得到了一个像这样的消息:
88

99
`<message id="lj8Vq-31" to="rrcgateway_458921440@wa2-mz36-qrmzh6.bosch.de" type="chat"><subject>/heatingCircuits/hc1/manualTempOverride/temperature</subject><body>PUT /heatingCircuits/hc1/manualTempOverride/temperature HTTP:/1.0\nContent-Type: application/json\nContent-Length: 25\nUser-Agent: NefitEasy\n\n\n\nXmuIR7wCfDZpPrPkrb/CqQ==\n</body></message>`
1010

11-
Again, tidying it up a bit, and removing the XMPP headers we see the body is:
11+
再次,整理一下它,并且移除XMPP头部,我们看到消息体如下:
1212
```py
1313
PUT /heatingCircuits/hc1/manualTempOverride/temperature
1414

@@ -22,21 +22,21 @@ HTTP:/1.0
2222

2323
XmuIR7wCfDZpPrPkrb/CqQ==
2424
```
25-
If we decode the text at the bottom we find that it decodes as:
2625

27-
`<span class="s1">{"value":16}\x00\x00\x00\x00</span>`
26+
如果我们解码底部的文本,那么可以发现它解码为:
27+
`<{"value":16}\x00\x00\x00\x00`
2828

29-
This looks like JSON, with a bit of null-padding at the end (presumably so that the encryption routine is given data with the length divisible by a certain number) – and it makes sense, as I set the thermostat to 16 degrees.
29+
这看起来像JSON,并在最后有一个位的空填充(大概是这样的,长度按一定数可整除的数据被提供给加密例程) - 它是有意义的,因为我设置了恒温器为16度。
3030

31-
So, if we send this message (but with a different number) then presumably the temperature setting will change?&nbsp;Well…sort of!
31+
所以,如果我们发送这条短信(但使用不同的号码),那么假设温度会改变?嗯...有可能!
3232

33-
You see, changing the temperature depends on what mode you are in. There are two modes, and the UMD part of the status message tells you which one you are in: _manual_ or _clock._ If you’re in manual mode then you can change the temperature by simply sending a PUT message (like the one above) to&nbsp;`/heatingCircuits/hc1/temperatureRoomManual`, with JSON of&nbsp;`{"value":21}` (or whatever temperature you want).
33+
你看,改变温度取决于你在什么模式。有两种模式,而状态消息的UMD部分告诉你,你是其中哪一个:手动(manual)或时钟(clock)。如果你在手动模式下,则可以简单发送一个PUT消息(像上面那个)给`/heatingCircuits/hc1/temperatureRoomManual`,并带上JSON数据`{"value":21}`(或任何你想要的温度)来更改温度。
3434

35-
However, if you’re in clock mode then you have to set the ‘override temperature’ (a PUT message to&nbsp;`/heatingCircuits/hc1/manualTempOverride/temperature`) with the same JSON as above,&nbsp;_and_ you then have to turn the ‘temperature override function’ on (a PUT message to&nbsp;`/heatingCircuits/hc1/manualTempOverride/status` with the JSON `{"value": "on"}`).
35+
但是,如果在时钟模式下,那么你必须设置“覆盖温度(override temperature)”(一个到`/heatingCircuits/hc1/manualTempOverride/temperature`的PUT消息),并且带上与上面相同的JSON,然后你必须打开”温度覆盖功能(temperature override function)'(一个到`/heatingCircuits/hc1/manualTempOverride/status`的带有JSON数据`{"value": "on"}`的PUT消息)。
3636

37-
Oh, and if you want to change the mode then you can just send a PUT message to&nbsp;`/heatingCircuits/hc1/usermode` with the JSON `{"value": "clock"}` or `{"value":"manual"}`.
37+
哦,如果你想改变模式,那么你可以只发送一个到`/heatingCircuits/hc1/usermode`的PUT消息,并携带JSON数据`{"value": "clock"}`或`{"value":"manual"}`。
3838

39-
You may be wondering whether you get a response from these messages or not: you do, but they’re not very interesting. Unless there has been an error, all you get is:
39+
你可能想知道是否从这些消息获得了响应:你可以这样做,但它们不是很有趣的。除非出现了一个错误,你得到的会是:
4040
```py
4141
No Content
4242

@@ -45,15 +45,14 @@ Content-Type: application/json
4545
connection: close
4646
```
4747

48-
There are loads of other messages you can send to do all sorts of complicated things (such as changing the timer programme), but I haven’t bothered to investigate&nbsp;any of those yet. I know they will use the same format as these messages, they’ll just have slightly more complicated JSON payloads, and may require the sending of multiple messages. I’m just happy that I can read the status of my thermostat, and control basic settings (mode and temperature)!
48+
你还可以发送许多其他的消息来做各种复杂的事情(如改变定时程序),但我还没有尝试去调查这些呢。我知道它们会使用与这些消息相同的格式,它们只是由稍微复杂一点的JSON有效载荷,并可能需要发送多个消息。我很高兴,因为我可以读取我的恒温器状态,并控制基本设置(模式和温度)!
4949

50-
So, I haven’t actually mentioned Python that much in this series so far (sorry!) – although, in fact, most of my ‘trial and error’ work was done through Python using the great [sleekxmpp library](http://sleekxmpp.com/). I have to confess here that I haven’t written the code as well as I should have done: I should really have designed it to implement a proper Finite State Machine, and send and receive the appropriate messages at the appropriate times, all while updating internal information in the Python classes…but I didn’t! Sorry – dealing with all of that, working asynchronously, was too much like hard work.
50+
所以,迄今为止,在这个系列中我并没有真正那么多提到Python(对不起!)—— 尽管,事实上,我的大部分'试错'工作是通过使用Python中棒棒哒的[sleekxmpp库](http://sleekxmpp.com/)来完成的。在这里,我必须承认,我没有如我应该做的那样编写代码:我真的本应该设计它来实现一个适当的有限状态机,并且在适当的时间里发送和接收相应的消息,同时在Python类中更新内部信息......但我没有!对不起 —— 应对所有这一切,异步工作,这都太像繁重的工作了。
5151

52-
So, I wrote a&nbsp;`BaseWaveMessageBot` class that implemented connecting, sending messages, encoding and decoding message payloads and a bit of simple error handling. That class has all of the complicated stuff in it, so I then wrote a couple of very simple classes (`StatusBot` and `SetBot`) that send the appropriate messages and process the responses. I then combined these in a nice class called `WaveThermo`. Currently there aren’t many methods in WaveThermo, but I will gradually add more functionality as I need it.
52+
所以,我写了一个`BaseWaveMessageBot`类,它实现连接,发送消息,编码和解码消息负载和一点简单的错误处理。这个类拥有所有复杂的东西,所以后来我写了几个非常简单的类(`StatusBot`和`SetBot`),它们发送适当的消息并处理响应。然后,我在一个漂亮的名为`WaveThermo`的类中将它们组合在一起。目前,WaveThermo还没有很多方法,但因为我需要它,所以我会逐渐添加更多的功能。
5353

54-
The code is available [on Github](https://github.com/robintw/pywavethermo)&nbsp;and is fairly easy to use:
54+
该代码可[在Github](https://github.com/robintw/pywavethermo)上找到,并且它是相当容易使用:
5555

56+
当然,我只是用我的恒温器测试了一下它 —— 所以,如果它对你无效,那么请让我知道!
5657

57-
Of course, I’ve only tested it with my thermostat – so if it doesn’t work for you then please let me know!
58-
59-
So, that’s it for this time – next time I’ll talk about a bit of the work I’ve done with automated monitoring of the temperature and the thermostat state, and some of the interesting patterns I’ve found.
58+
所以,目前就是这样了 - 下一次,我将谈论我完成的温度和恒温状态自动监控所做的一点工作,以及我发现的一些有趣的模式。

0 commit comments

Comments
 (0)