modder2
Mikhail Yudin 2023-06-03 10:21:31 +07:00
rodzic fb62b129ed
commit 7f7fdf7ed9
4 zmienionych plików z 49 dodań i 8 usunięć

Wyświetl plik

@ -1,9 +1,20 @@
# Quansheng UV-K5 firmware encoder/decoder
WARNING: I am not responsible for the consequences of using. Think before use twice or more. =)
Supports updater [v1.1.7](https://drive.google.com/file/d/1l7NiaImDJCEhKz6BdxD4UxNbs_u4J-cr/view?usp=share_link) (decrypted only) and [1.1.11+](https://drive.google.com/file/d/1hvjFoKGwMibhNqMi6X-rjFYcb6iIzUxe/view?usp=share_link) (encrypted only).
## Usage
### Example modding
```
./modder.py fw/k5_26_encrypted.bin > fw/k5_26_encrypted_mod18to1300.bin
```
### Encdec usage
```
./encdec.py <e|d> input.bin > output.bin
```

Wyświetl plik

@ -14,3 +14,7 @@ B6_1=0xE088
B6_2=0xE0A4
B7_1=0xE08C
B7_2=0xE0A8
[limits]
L1=0x150C
L2=0x1510

Wyświetl plik

@ -1,12 +1,14 @@
#!/usr/bin/env python3
import os
from pathlib import Path
from sys import argv
from configparser import ConfigParser
from lib.encdec import decrypt, eprint
from lib.encdec import decrypt, encrypt, eprint
ADDR_DIR = Path(__file__).parent / 'addresses'
MODS_DIR = Path(__file__).parent / 'mods'
def main(encrypted_file_path):
file_bytes = Path(encrypted_file_path).read_bytes()
@ -14,14 +16,31 @@ def main(encrypted_file_path):
eprint('version:', version)
addr_file = ADDR_DIR / ('%s.ini' % version)
addresses = ConfigParser()
addresses.read(addr_file)
mods_file = MODS_DIR / ('%s.ini' % version)
addresses = ConfigParser()
mods = ConfigParser()
addresses.read(addr_file)
mods.read(mods_file)
for section_name in addresses:
eprint('[%s]' % section_name)
section_values = addresses[section_name]
for k in section_values:
addr = int(section_values.get(k), 16)
value = int.from_bytes(decrypted[addr:addr+4], 'little')
eprint(k, addr, value)
if mods[section_name] and mods[section_name].get(k):
new_value = mods[section_name].get(k)
eprint('new:', new_value)
decrypted = decrypted[:addr] + int(new_value).to_bytes(4, 'little') + decrypted[addr+4:]
encrypted = encrypt(decrypted, version)
os.write(1, encrypted)
bands_addr = addresses['bands']
for k in bands_addr:
addr = int(bands_addr.get(k), 16)
value = int.from_bytes(decrypted[addr:addr+4], 'little')
eprint(k, addr, value)
if __name__ == "__main__":

7
mods/2.01.26.ini 100644
Wyświetl plik

@ -0,0 +1,7 @@
[bands]
B1_1=1800000
B7_2=130000000
[limits]
L1=1800000
L2=130000000