Remove libusb1 for windows (libusb0 only), fix reset command

This commit is contained in:
Bjoern Kerler 2022-06-16 11:23:26 +02:00
parent b208e3edd6
commit 6ab6ace5a8
No known key found for this signature in database
GPG key ID: 52E823BB96A55380
7 changed files with 27 additions and 17 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python3
from Library.tcpclient import tcpclient
from edl.Library.tcpclient import tcpclient
class client():
def __init__(self):

View file

@ -1,5 +1,5 @@
# Qualcomm Sahara / Firehose Attack Client / Diag Tools
(c) B. Kerler 2018-2021
(c) B. Kerler 2018-2022
## Why
@ -7,9 +7,12 @@
- Because attacking firehose is kewl
- Because memory dumping helps to find issues :)
### Use Re LiveDVD (everything ready to go, based on Ubuntu):
[Download Re Live DVD V3](https://androidfilehost.com/?fid=2981970449027578109)
User: user, Password:user
### Use LiveDVD (everything ready to go, based on Ubuntu):
User: user, Password:user (based on Ubuntu 22.04 LTS)
[Live DVD V4](https://androidfilehost.com/?fid=15664248565197177367)
[Live DVD V4 Mirror](https://drive.google.com/file/d/10OEw1d-Ul_96MuT3WxQ3iAHoPC4NhM_X/view?usp=sharing)
## Installation

10
edl
View file

@ -44,7 +44,7 @@ Usage:
edl send <command> [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial]
edl xml <xmlfile> [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial]
edl rawxml <xmlstring> [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--skipstorageinit] [--portname=portname] [--serial]
edl reset <resetmode> [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial]
edl reset [--resetmode=mode] [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--portname=portname] [--serial]
edl nop [--loader=filename] [--debugmode] [--vid=vid] [--pid=pid] [--skipstorageinit] [--portname=portname] [--serial]
edl modules <command> <options> [--memory=memtype] [--lun=lun] [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--devicemodel=value] [--portname=portname] [--serial]
edl provision <xmlfile> [--loader=filename] [--debugmode] [--skipresponse] [--vid=vid] [--pid=pid] [--portname=portname] [--serial]
@ -118,6 +118,7 @@ Options:
--portname=portname Set serial port name (/dev/ttyUSB0 for Linux/MAC; \\.\COM1 for Windows)
--serial Use serial port (port autodetection)
--slot Set active slot for setactiveslot [a or b]
--resetmode=mode Resetmode for reset (poweroff, reset, edl, etc.)
"""
import os
@ -136,6 +137,7 @@ from edlclient.Library.streaming_client import streaming_client
from edlclient.Library.firehose_client import firehose_client
from edlclient.Library.streaming import Streaming
from edlclient.Library.sahara_defs import cmd_t, sahara_mode_t
from edlclient.Library.utils import is_windows
from binascii import hexlify
args = docopt(__doc__, version='3')
@ -153,7 +155,6 @@ def parse_cmd(rargs):
return cmd
return ""
def console_cmd(cmd):
read = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, close_fds=True)
@ -174,6 +175,8 @@ def parse_option(rargs):
class main(metaclass=LogBase):
def __init__(self):
self.serial = None
self.portname = None
self.__logger = self.__logger
self.info = self.__logger.info
self.debug = self.__logger.debug
@ -239,12 +242,11 @@ class main(metaclass=LogBase):
return mode
def run(self):
if sys.platform == 'win32' or sys.platform == 'win64' or sys.platform == 'winnt':
if is_windows():
proper_driver = console_cmd(r'reg query HKLM\HARDWARE\DEVICEMAP\SERIALCOMM')
if re.findall(r'QCUSB', str(proper_driver)):
self.warning(f'Please first install libusb_win32 driver from Zadig')
mode = ""
loop = 0
vid = int(args["--vid"], 16)
pid = int(args["--pid"], 16)

View file

@ -9,7 +9,9 @@ import usb.util
import time
import inspect
import array
from edlclient.Library.utils import is_windows
import usb.backend.libusb0
if not is_windows():
import usb.backend.libusb1
from enum import Enum
from binascii import hexlify
@ -63,11 +65,8 @@ class usb_class(DeviceClass):
self.is_serial = False
if sys.platform.startswith('freebsd') or sys.platform.startswith('linux') or sys.platform.startswith('darwin'):
self.backend = usb.backend.libusb1.get_backend(find_library=lambda x: "libusb-1.0.so")
elif sys.platform.startswith('win32'):
if calcsize("P") * 8 == 64:
self.backend = usb.backend.libusb1.get_backend(find_library=lambda x: "libusb-1.0.dll")
else:
self.backend = usb.backend.libusb1.get_backend(find_library=lambda x: "libusb32-1.0.dll")
elif is_windows():
self.backend = None
if self.backend is not None:
try:
self.backend.lib.libusb_set_option.argtypes = [c_void_p, c_int]

View file

@ -299,6 +299,8 @@ class firehose(metaclass=LogBase):
return response(resp=True,data=rdata)
def cmd_reset(self, mode="reset"):
if mode is None:
mode = "poweroff"
data = "<?xml version=\"1.0\" ?><data><power value=\""+mode+"\"/></data>"
val = self.xmlsend(data)
try:

View file

@ -617,9 +617,9 @@ class firehose_client(metaclass=LogBase):
return False
elif cmd == "reset":
mode = "reset"
if not self.check_param(["<resetmode>"]):
if not self.check_param(["--resetmode"]):
return False
return self.firehose.cmd_reset(options["<resetmode>"])
return self.firehose.cmd_reset(options["--resetmode"])
elif cmd == "nop":
if not self.check_cmd("nop"):
self.error("Nop command isn't supported by edl loader")

View file

@ -25,6 +25,10 @@ try:
except ImportError:
print("Keystone library is missing (optional).")
def is_windows():
if sys.platform == 'win32' or sys.platform == 'win64' or sys.platform == 'winnt':
return True
return False
class structhelper_io:
pos = 0