mirror of
https://github.com/bkerler/edl.git
synced 2024-11-28 10:25:50 -05:00
Fix enableadb, issue with telnetlib, replace crypt.crypt
This commit is contained in:
parent
87c37796ba
commit
93470b921f
1 changed files with 21 additions and 10 deletions
|
@ -20,7 +20,8 @@ except ImportError as e:
|
||||||
|
|
||||||
import usb.core
|
import usb.core
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import crypt
|
|
||||||
|
from passlib.hash import md5_crypt
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from edlclient.Tools.sierrakeygen import SierraKeygen
|
from edlclient.Tools.sierrakeygen import SierraKeygen
|
||||||
|
@ -37,6 +38,15 @@ import logging.config
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import colorama
|
import colorama
|
||||||
|
|
||||||
|
|
||||||
|
itoa64 = bytearray(b"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
|
||||||
|
def _crypt_to64(s, v, n):
|
||||||
|
out=bytearray()
|
||||||
|
while --n >= 0:
|
||||||
|
out.append(itoa64[v&0x3f])
|
||||||
|
v >>= 6
|
||||||
|
|
||||||
|
|
||||||
class ColorFormatter(logging.Formatter):
|
class ColorFormatter(logging.Formatter):
|
||||||
LOG_COLORS = {
|
LOG_COLORS = {
|
||||||
logging.ERROR: colorama.Fore.RED,
|
logging.ERROR: colorama.Fore.RED,
|
||||||
|
@ -187,7 +197,7 @@ class connection:
|
||||||
elif device.vid == vendor.netgear.value:
|
elif device.vid == vendor.netgear.value:
|
||||||
try:
|
try:
|
||||||
# vid 0846, netgear mr1100, mr5100
|
# vid 0846, netgear mr1100, mr5100
|
||||||
self.tn = Telnet("192.168.1.1", 5510, 5)
|
self.tn = Telnet("192.168.1.1", 5510)
|
||||||
self.connected = True
|
self.connected = True
|
||||||
except:
|
except:
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
@ -231,8 +241,8 @@ class connection:
|
||||||
data = ""
|
data = ""
|
||||||
while True:
|
while True:
|
||||||
tmp = self.tn.read_eager()
|
tmp = self.tn.read_eager()
|
||||||
if tmp != b"":
|
if tmp != "":
|
||||||
data += tmp.strip().decode('utf-8')
|
data += tmp.strip()
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
if "ERROR" in data:
|
if "ERROR" in data:
|
||||||
|
@ -533,12 +543,13 @@ class adbtools(metaclass=LogBase):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def Quectel(self, cn, enable: bool = True):
|
def Quectel(self, cn, enable: bool = True):
|
||||||
salt = cn.send("AT+QADBKEY?\r")
|
sn = cn.send("AT+QADBKEY?\r")
|
||||||
if salt != -1:
|
if sn != -1:
|
||||||
if len(salt) > 1:
|
if len(sn) > 1:
|
||||||
salt = salt[1]
|
sn = sn[1]
|
||||||
code = crypt.crypt("SH_adb_quectel", "$1$" + salt)
|
cc = md5_crypt(salt="")
|
||||||
code = code[12:]
|
code = cc.encrypt("SH_adb_quectel", salt=str(sn))
|
||||||
|
code = code[12:28]
|
||||||
cn.send("AT+QADBKEY=\"%s\"\r" % code)
|
cn.send("AT+QADBKEY=\"%s\"\r" % code)
|
||||||
if enable:
|
if enable:
|
||||||
if cn.send("AT+QCFG=\"usbcfg\",0x2C7C,0x125,1,1,1,1,1,1,0\r") == -1:
|
if cn.send("AT+QCFG=\"usbcfg\",0x2C7C,0x125,1,1,1,1,1,1,0\r") == -1:
|
||||||
|
|
Loading…
Reference in a new issue