parent
65a1b04666
commit
6cf9292b44
1 changed files with 23 additions and 7 deletions
|
@ -8,7 +8,6 @@ import struct
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from zlib import adler32
|
|
||||||
|
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||||
|
@ -121,8 +120,11 @@ def discover(timeout=None, local_ip_address=None, discover_ip_address='255.255.2
|
||||||
packet[0x1c] = port & 0xff
|
packet[0x1c] = port & 0xff
|
||||||
packet[0x1d] = port >> 8
|
packet[0x1d] = port >> 8
|
||||||
packet[0x26] = 6
|
packet[0x26] = 6
|
||||||
|
|
||||||
|
checksum = 0xbeaf
|
||||||
|
for b in packet:
|
||||||
|
checksum = (checksum + b) & 0xffff
|
||||||
|
|
||||||
checksum = adler32(packet, 0xbeaf) & 0xffff
|
|
||||||
packet[0x20] = checksum & 0xff
|
packet[0x20] = checksum & 0xff
|
||||||
packet[0x21] = checksum >> 8
|
packet[0x21] = checksum >> 8
|
||||||
|
|
||||||
|
@ -268,7 +270,10 @@ class device:
|
||||||
if payload:
|
if payload:
|
||||||
payload += bytearray((16 - len(payload)) % 16)
|
payload += bytearray((16 - len(payload)) % 16)
|
||||||
|
|
||||||
checksum = adler32(payload, 0xbeaf) & 0xffff
|
checksum = 0xbeaf
|
||||||
|
for b in payload:
|
||||||
|
checksum = (checksum + b) & 0xffff
|
||||||
|
|
||||||
packet[0x34] = checksum & 0xff
|
packet[0x34] = checksum & 0xff
|
||||||
packet[0x35] = checksum >> 8
|
packet[0x35] = checksum >> 8
|
||||||
|
|
||||||
|
@ -276,7 +281,10 @@ class device:
|
||||||
for i in range(len(payload)):
|
for i in range(len(payload)):
|
||||||
packet.append(payload[i])
|
packet.append(payload[i])
|
||||||
|
|
||||||
checksum = adler32(packet, 0xbeaf) & 0xffff
|
checksum = 0xbeaf
|
||||||
|
for b in packet:
|
||||||
|
checksum = (checksum + b) & 0xffff
|
||||||
|
|
||||||
packet[0x20] = checksum & 0xff
|
packet[0x20] = checksum & 0xff
|
||||||
packet[0x21] = checksum >> 8
|
packet[0x21] = checksum >> 8
|
||||||
|
|
||||||
|
@ -409,7 +417,10 @@ class bg1(device):
|
||||||
for i in range(len(js)):
|
for i in range(len(js)):
|
||||||
packet.append(js[i])
|
packet.append(js[i])
|
||||||
|
|
||||||
checksum = adler32(packet[0x08:], 0xc0ad) & 0xffff
|
checksum = 0xc0ad
|
||||||
|
for b in packet[0x08:]:
|
||||||
|
checksum = (checksum + b) & 0xffff
|
||||||
|
|
||||||
packet[0x06] = checksum & 0xff
|
packet[0x06] = checksum & 0xff
|
||||||
packet[0x07] = checksum >> 8
|
packet[0x07] = checksum >> 8
|
||||||
|
|
||||||
|
@ -1034,7 +1045,9 @@ class lb1(device):
|
||||||
packet[0x0a] = len(command)
|
packet[0x0a] = len(command)
|
||||||
packet[0x0e:] = map(ord, command)
|
packet[0x0e:] = map(ord, command)
|
||||||
|
|
||||||
checksum = adler32(packet, 0xbeaf) & 0xffff
|
checksum = 0xbeaf
|
||||||
|
for b in packet:
|
||||||
|
checksum = (checksum + b) & 0xffff
|
||||||
|
|
||||||
packet[0x00] = (0x0c + len(command)) & 0xff
|
packet[0x00] = (0x0c + len(command)) & 0xff
|
||||||
packet[0x06] = checksum & 0xff # Checksum 1 position
|
packet[0x06] = checksum & 0xff # Checksum 1 position
|
||||||
|
@ -1091,7 +1104,10 @@ def setup(ssid, password, security_mode):
|
||||||
payload[0x85] = pass_length # Character length of password
|
payload[0x85] = pass_length # Character length of password
|
||||||
payload[0x86] = security_mode # Type of encryption (00 - none, 01 = WEP, 02 = WPA1, 03 = WPA2, 04 = WPA1/2)
|
payload[0x86] = security_mode # Type of encryption (00 - none, 01 = WEP, 02 = WPA1, 03 = WPA2, 04 = WPA1/2)
|
||||||
|
|
||||||
checksum = adler32(payload, 0xbeaf) & 0xffff
|
checksum = 0xbeaf
|
||||||
|
for b in payload:
|
||||||
|
checksum = (checksum + b) & 0xffff
|
||||||
|
|
||||||
payload[0x20] = checksum & 0xff # Checksum 1 position
|
payload[0x20] = checksum & 0xff # Checksum 1 position
|
||||||
payload[0x21] = checksum >> 8 # Checksum 2 position
|
payload[0x21] = checksum >> 8 # Checksum 2 position
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue