调整文件目录

This commit is contained in:
2026-07-07 14:37:04 +08:00
parent 98a1e9d371
commit 295558836b
53 changed files with 22339 additions and 4242 deletions
+42 -14
View File
@@ -10,16 +10,35 @@ import struct
import zlib
from pathlib import Path
AAD = b"Q05-Lidar init_boot resource v1"
DEFAULT_AAD = "Q05-Lidar init_boot resource v1"
FORMAT_MAGIC = {
"q05": (b"Q05R2\x00", "q05-lidar-resource-v2", DEFAULT_AAD),
"ez60": (b"EZ60R2\x00", "ez60-resource-v2", "Mazda-EZ60 init_boot resource v1"),
}
def b64u(data):
return base64.urlsafe_b64encode(data).decode("ascii").rstrip("=")
def decode_key_material(key_text):
text = str(key_text).strip()
if text.startswith("raw:"):
key = text.split(":", 1)[1].encode("utf-8")
elif len(text) == 64 and all(c in "0123456789abcdefABCDEF" for c in text):
key = bytes.fromhex(text)
elif len(text.encode("utf-8")) == 32:
key = text.encode("utf-8")
else:
key = base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))
if len(key) != 32:
raise ValueError(f"key must decode to 32 bytes, got {len(key)} bytes")
return key
def main():
parser = argparse.ArgumentParser(
description="Encrypt a Q05-Lidar init_boot image into resource.dat"
description="Encrypt a vehicle init_boot image into a resource dat file"
)
parser.add_argument("input_img", help="Magisk-patched init_boot image")
parser.add_argument(
@@ -27,9 +46,19 @@ def main():
default="resource.dat",
help="Output encrypted resource file, default: resource.dat",
)
parser.add_argument(
"--vehicle",
choices=sorted(FORMAT_MAGIC.keys()),
default="q05",
help="Resource header/profile to write. Default: q05.",
)
parser.add_argument(
"--aad",
help="Optional AES-GCM AAD text. Defaults to the selected vehicle profile.",
)
parser.add_argument(
"--key",
help="Optional AES-256 key as base64url or 64-char hex. Omit to generate a random key.",
help="Optional AES-256 key as base64url, 64-char hex, raw:TEXT, or 32-byte UTF-8 text. Omit to generate a random key.",
)
parser.add_argument(
"--no-compress",
@@ -49,29 +78,28 @@ def main():
input_path = Path(args.input_img)
plain = input_path.read_bytes()
sha256 = hashlib.sha256(plain).hexdigest()
magic, resource_format, default_aad = FORMAT_MAGIC[args.vehicle]
aad = (args.aad or default_aad).encode("utf-8")
if args.key:
text = args.key.strip()
if len(text) == 64 and all(c in "0123456789abcdefABCDEF" for c in text):
key = bytes.fromhex(text)
else:
key = base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))
if len(key) != 32:
raise SystemExit("key must decode to 32 bytes")
try:
key = decode_key_material(args.key)
except Exception as e:
raise SystemExit(str(e))
else:
key = os.urandom(32)
compression = "none" if args.no_compress else "zlib"
body = plain if args.no_compress else zlib.compress(plain, level=9)
nonce = os.urandom(12)
ciphertext = AESGCM(key).encrypt(nonce, body, AAD)
ciphertext = AESGCM(key).encrypt(nonce, body, aad)
header = {
"format": "q05-lidar-resource-v2",
"format": resource_format,
"cipher": "AES-256-GCM",
"kdf": "none",
"compression": compression,
"aad": AAD.decode("utf-8"),
"aad": aad.decode("utf-8"),
"nonce": b64u(nonce),
"sha256": sha256,
"plainSize": len(plain),
@@ -80,7 +108,7 @@ def main():
output_path = Path(args.output)
header_bytes = json.dumps(header, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
output_path.write_bytes(b"Q05R2\x00" + struct.pack(">I", len(header_bytes)) + header_bytes + ciphertext)
output_path.write_bytes(magic + struct.pack(">I", len(header_bytes)) + header_bytes + ciphertext)
print("resource.dat created")
print(f"input: {input_path}")
+195
View File
@@ -0,0 +1,195 @@
;
; Android WinUsb driver installation.
;
[Version]
Signature = "$Windows NT$"
Class = AndroidUsbDeviceClass
ClassGuid = {3F966BD9-FA04-4ec5-991C-D326973B5128}
Provider = %ProviderName%
DriverVer = 08/28/2014,11.0.0000.00000
CatalogFile.NTx86 = androidwinusb86.cat
CatalogFile.NTamd64 = androidwinusba64.cat
[ClassInstall32]
Addreg = AndroidWinUsbClassReg
[AndroidWinUsbClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-1
[Manufacturer]
%ProviderName% = Google, NTx86, NTamd64
[Google.NTx86]
;Google Nexus One
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02&MI_01
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E11
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E12&MI_01
;Google Nexus S
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E21
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E22&MI_01
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E23
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E24&MI_01
;Google Nexus 7
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4E40
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E42&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E44&MI_01
;Google Nexus Q
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_2C11
;Google Nexus (generic)
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE2&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE4&MI_02
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE6&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE7
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_D001
;Google Glass
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9001
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9001&MI_01
;Google Glass EE1
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9003
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9003&MI_01
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_9004
;Google Glass EE2
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9005
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9005&MI_00
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_9006
;Project Tango (generic)
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4D00
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D02&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D04&MI_02
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D06&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D07
[Google.NTamd64]
;Google Nexus One
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_0D02&MI_01
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E11
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E12&MI_01
;Google Nexus S
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E21
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E22&MI_01
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_4E23
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E24&MI_01
;Google Nexus 7
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4E40
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E42&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4E44&MI_01
;Google Nexus Q
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_2C11
;Google Nexus (generic)
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE2&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE4&MI_02
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE6&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4EE7
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_D001
;Google Glass
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9001
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9001&MI_01
;Google Glass EE1
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9003
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9003&MI_01
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_9004
;Google Glass EE2
%SingleAdbInterface% = USB_Install, USB\VID_18D1&PID_9005
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_9005&MI_00
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_9006
;Project Tango (generic)
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4D00
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D02&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D04&MI_02
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D06&MI_01
%CompositeAdbInterface% = USB_Install, USB\VID_18D1&PID_4D07
[USB_Install]
Include = winusb.inf
Needs = WINUSB.NT
[USB_Install.Services]
Include = winusb.inf
AddService = WinUSB,0x00000002,WinUSB_ServiceInstall
[WinUSB_ServiceInstall]
DisplayName = %WinUSB_SvcDesc%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WinUSB.sys
[USB_Install.Wdf]
KmdfService = WINUSB, WinUSB_Install
[WinUSB_Install]
KmdfLibraryVersion = 1.9
[USB_Install.HW]
AddReg = Dev_AddReg
[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{F72FE0D4-CBCB-407d-8814-9ED673D0DD6B}"
[USB_Install.CoInstallers]
AddReg = CoInstallers_AddReg
CopyFiles = CoInstallers_CopyFiles
[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01009.dll,WdfCoInstaller","WinUSBCoInstaller2.dll"
[CoInstallers_CopyFiles]
WinUSBCoInstaller2.dll
WdfCoInstaller01009.dll
[DestinationDirs]
CoInstallers_CopyFiles=11
[SourceDisksNames]
1 = %DISK_NAME%,,,\i386
2 = %DISK_NAME%,,,\amd64
[SourceDisksFiles.x86]
WinUSBCoInstaller2.dll = 1
WdfCoInstaller01009.dll = 1
[SourceDisksFiles.amd64]
WinUSBCoInstaller2.dll = 2
WdfCoInstaller01009.dll = 2
[Strings]
ProviderName = "Google, Inc."
SingleAdbInterface = "Android ADB Interface"
CompositeAdbInterface = "Android Composite ADB Interface"
SingleBootLoaderInterface = "Android Bootloader Interface"
WinUSB_SvcDesc = "Android USB Driver"
DISK_NAME = "Android WinUsb installation disk"
ClassName = "Android Device"
Binary file not shown.
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
Pkg.Revision=13
Archive.HostOs=WINDOWS
Extra.Path=usb_driver