softScheck / tplink-smartplug

TP-Link WiFi SmartPlug Client and Wireshark Dissector
Apache License 2.0
1.13k stars 296 forks source link

Troubleshooting tplink-smartplug.py #32

Closed jhalbrecht closed 6 years ago

jhalbrecht commented 6 years ago

I've purchased and received (today 12/16/2017) a tp-link smart plug HS 100(US) It is version 2.0 according to label on back of device.

I installed the Kasa app on my android phone configuring it for Local only. I didn't create a cloud account. I can turn the switch on and off with the Kasa app.

I cloned the Master branch tplink-smartplug repository. I learned the ip address of the smart plug and tried the tplink-smartplug.py script. I'm apparently not receiving anything back, nor am I seeing an error.

$ ping 192.168.1.79
PING 192.168.1.79 (192.168.1.79) 56(84) bytes of data.
64 bytes from 192.168.1.79: icmp_seq=1 ttl=64 time=2.40 ms
64 bytes from 192.168.1.79: icmp_seq=2 ttl=64 time=2.34 ms
^C
--- 192.168.1.79 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 2.344/2.376/2.409/0.058 ms
$
$ ./tplink-smartplug.py -t 192.168.1.79 -c info
Sent:      {"system":{"get_sysinfo":{}}}
Received:
$
$ telnet 192.168.1.79 9999
Trying 192.168.1.79...
Connected to 192.168.1.79.
Escape character is '^]'.
help
^]

telnet> quit
Connection closed.
$

I've tried info, on and off and also on a couple different hosts. Also tried it with firewall off in case port was blocked. I can telnet to port 9999.

Any suggestions?

jhalbrecht commented 6 years ago

In issue Cannot get working with smartPlug_CE_HS100(AU)_HS110(AU) #22 I found a fix by @kchiem

In tplink-smartplug.py add this struct and in the 'def encrypt' change the 'result' line

from struct import pack
#[...]
# result = "\0\0\0\0"
result = pack('>I', len(string))

It works on my machine! tplink-smartplug.py needs a merge.