kdztools icon indicating copy to clipboard operation
kdztools copied to clipboard

[!] Error: Unsupported KDZ file format.

Open ishiestar opened this issue 4 years ago • 3 comments

when I run the following

$ ./unkdz -f V20D_00_0128.kdz -l

I get the following error

[!] Error: Unsupported KDZ file format.
[ ] Received header "f3 79 97 e5 2a 20 ff 71".

Are LG optimus KDZs not supported? This KDZ is of an LG Optimus L7 II (P713).

ishiestar avatar Sep 02 '19 12:09 ishiestar

Most likely LGE changed their format again (this happens, they want to deliberately break everyone else's software). The fix isn't too complex, near the top of unkdz.py the following:

        kdz_header = {
                b"\x28\x05\x00\x00"b"\x34\x31\x25\x80": 0,
                b"\x18\x05\x00\x00"b"\x32\x79\x44\x50": 1,
                kdz.KDZFile._dz_header:                 2,
        }

Would be changed to:

        kdz_header = {
                b"\x28\x05\x00\x00"b"\x34\x31\x25\x80": 0,
                b"\x18\x05\x00\x00"b"\x32\x79\x44\x50": 1,
                b"\xf3\x79\x97\xe5"b"\x2a\x20\xff\x71": 2,
                kdz.KDZFile._dz_header:                 3,
        }

Please confirm you end up with something sensible when trying this, also note those are tabs not spaces!

ehem avatar Oct 03 '19 20:10 ehem

Hi @ehem , I've got LG K40 and downloaded the zip with stock Android ROM.

However, there's an issue extracting the file. I've modified the byte definitions for the header.

--- a/unkdz.py
+++ b/unkdz.py
@@ -41,9 +41,10 @@ class KDZFileTools(kdz.KDZFile):
        infile = None

        kdz_header = {
-               b"\x28\x05\x00\x00"b"\x34\x31\x25\x80": 0,
-               b"\x18\x05\x00\x00"b"\x32\x79\x44\x50": 1,
-               kdz.KDZFile._dz_header:                 2,
+               b"\x28\x05\x00\x00"b"\x24\x38\x22\x25": 0,
+               b"\x58\x34\x32\x30"b"\x31\x30\x69\x5f": 1,
+               b"\x30\x32\x2e\x64"b"\x7a\x00\x00\x00": 2,
+               kdz.KDZFile._dz_header:                 3,
        }

But then I get:

./undz.py -x -f LG_K40.kdz
[!] Bad DZ file header!

https://github.com/ehem/kdztools/issues/26

Is there any documentation on the KDZ file format available?

phodina avatar Mar 23 '23 07:03 phodina

So I used the unkkdz to extract the DZ file. However, then I got error about the unsupported GPT header.

bin/unkdz -f ~/Downloads/X420HM20a_09_0303.kdz -x
[!] Warning: Data between headers and payload! (offsets 826 to 83768)
[+] Extracting all partitions from v2 file!

[+] Extracting X42021v_00_TCL_MX_OP_0303.dz to kdzextracted/X42021v_00_TCL_MX_OP_0303.dz
[+] Extracting LGUP_c.dll to kdzextracted/LGUP_c.dll
[+] Extracting LGUP_c.dylib to kdzextracted/LGUP_c.dylib
[+] Extracting extra data to kdzextracted/kdz_extras.bin
undz -f ~/Downloads/kdzextracted/X42021v_00_TCL_MX_OP_0303.dz -l
[ ] Warning: Found 1 out of order chunks (please report)
Traceback (most recent call last):
  File "/gnu/store/h0326sq0gsqz8fxhlq4cjnnaql25qgnq-kdztools-1.2/bin/.undz.py-real", line 632, in loadChunks
    g = gpt.GPT(self.chunks[0].extract())
  File "/gnu/store/h0326sq0gsqz8fxhlq4cjnnaql25qgnq-kdztools-1.2/lib/python3.10/site-packages/gpt.py", line 268, in __init__
    raise NoGPT("Error: GPT major version isn't 1")
gpt.NoGPT: Error: GPT major version isn't 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/gnu/store/h0326sq0gsqz8fxhlq4cjnnaql25qgnq-kdztools-1.2/bin/.undz.py-real", line 1079, in <module>
    dztools.main()
  File "/gnu/store/h0326sq0gsqz8fxhlq4cjnnaql25qgnq-kdztools-1.2/bin/.undz.py-real", line 1045, in main
    self.dz_file = UNDZFile(cmd.dzfile)
  File "/gnu/store/h0326sq0gsqz8fxhlq4cjnnaql25qgnq-kdztools-1.2/bin/.undz.py-real", line 911, in __init__
    self.loadChunks()
  File "/gnu/store/h0326sq0gsqz8fxhlq4cjnnaql25qgnq-kdztools-1.2/bin/.undz.py-real", line 673, in loadChunks
    print("[!] Unable to find GPT in DZ file: {:s}".format(err))
TypeError: unsupported format string passed to NoGPT.__format__

phodina avatar Jul 27 '23 05:07 phodina