yashsingh1/xdaforums huggingface dataset:
[LG V30 Guides, News, & Discussion] runningnak3d:
recovery and laf are now combined -- at least from what I have been able to tell from decompiling abl.

-- see below

The key combos that you use to get to download mode or recovery are processed by abl. In old school aboot, or even the V30 abl, if you hold vol up and plug in the USB cable, aboot (or V30 abl) hands off the boot process to laf so that you enter download mode. If you hold vol down + power / release power / hold power, the boot process is handed off to recovery.

In the G7 (again as near as I can tell since I don't own the device), those same key combos work, but a parameter is passed to laf to determine if download mode or recovery should be run.

Please keep in mind again that I don't own the device, and I only just figured out how to decompress abl so I could decompile it.

EDIT: actually this looks even more interesting. It appears that abl can also handle recovery, but if you extract laf, you will see that there is a stage2.img. That is starting to look like what we would consider "normal" recovery.

From abl:

factory_reset_no_1st_image
factory_reset_yes_1st_image
factory_reset_no_2nd_image
factory_reset_yes_2nd_image

and

recovery%c%a
[KSwitch] factory reset disabled, Do not go to handle_factory_reset_mode()
factory_reset_image
factory_reset_1st_line_image
factory_reset_2nd_line_image

recovery %c %a appears to be the command that is passed with a single argument.

I haven't downloaded the TWRP version that is available for the unlocked G7 (doing that now). That will give more insight from the dev that created it as to where it is flashed, and how it is booted.

Lastly, if any V30 folks would like me to take this to the G7 forums, please say so and I will ask to have the thread moved. I post here out of habit :)

-- Brian
[LG V30 Guides, News, & Discussion] runningnak3d:
Well, those little a-holes. LG stuck recovery in boot. It isn't an option that is passed to laf (although there ARE options that can be passed to laf), it is an option that is passed to boot.

recovery is not in laf.img, it is in the boot.img. If you extract it, and go into sbin:

[swango:~/dev … tracted/boot/initrd_dir/sbin] master* ± ls -al
total 4992
drwxr-x--- 2 swango swango 4096 Dec 18 11:08 .
drwxr-xr-x 31 swango swango 4096 Dec 18 11:08 ..
-rwxr-x--- 1 swango swango 1962720 Dec 18 11:08 adbd
-rwxr-x--- 1 swango swango 21964 Dec 18 11:08 bnrd
-rwxr-x--- 1 swango swango 998312 Dec 18 11:08 charger
-rwxr-x--- 1 swango swango 30176 Dec 18 11:08 rctd
-rwxr-x--- 1 swango swango 2078352 Dec 18 11:08 [B][U]recovery[/U][/B]
lrwxrwxrwx 1 swango swango 7 Dec 18 11:08 ueventd -> ../init
lrwxrwxrwx 1 swango swango 7 Dec 18 11:08 watchdogd -> ../init

Interesting. I still think (if you have an unlocked bootloader) it will be possible to inject TWRP into laf so that you have download mode OR TWRP.

There are some very interesting things in laf now. This stage2.img looks promising, also, they STILL have toybox which means that dd should be usable.

-- Brian
[LG V30 Guides, News, & Discussion] Dvalin21:
You rock as always. I decompile boot, but it didnt dawn on me when I saw the recovery folder that IT was recovery.
[LG V30 Guides, News, & Discussion] runningnak3d:
First post updated with a unified KDZ extractor that works on G4 to V40 KDZs.

-- Brian
[LG V30 Guides, News, & Discussion] TjoyD:
Thanks!! It works great and has been able to completely extract the G710N11d KDZ. So now, I can start the G7 camera port for V30.

---------- Post added at 01:53 AM ---------- Previous post was at 01:01 AM ----------

I have one more question.

You said that you removed the mkdz item due to RSA problem, is the DZ file also encrypted?

The reason I am asking this question is that the DZ file, just like the KDZ, can be selected in the PartitionDL menu of LGUP.
[LG V30 Guides, News, & Discussion] runningnak3d:
It isn't encrypted, it has an RSA signature. It doesn't matter if you flash just the DZ file, all versions of laf (download mode) since late versions of MM, and ALL versions of N, O, and P expect the SIGN payload to be sent.

Back in the KK and LP days, you could flash a TOT file that had no RSA signature -- you just had to know how to make one.

The SIGN payload is simply sha1 hashes of every partition, but it is RSA signed, if you modify any of the partition and try to package the KDZ back up, the hash will fail, and laf refuses to flash (even worse, it usually will wipe the partition first -- so you are really screwed). If you try to modify the SIGN payload to change the hash to match your modified partition, again, it will fail since now the RSA signature doesn't match.

If you search the V20 forums for "laf root" my development thread is there where I documented all of my research. You might have to sift through 100+ pages though :)

Bottom line, the only way to flash modified partitions with new versions of laf (that have removed the COPY opcode) is to find an exploit that gives you root and use dd (look at my H932 root thread here for an example).

-- Brian
[LG V30 Guides, News, & Discussion] seadersn:
damn, got a problem -.- may i ask you for assistance, [MENTION=3167089]runningnak3d[/MENTION]? for me it looks like the problem is with zstandard is used instead of zlib, header differences, who knows (i'm not) wtf...

Traceback (most recent call last):
File "./undz", line 1066, in <module>
dztools.main()
File "./undz", line 1032, in main
self.dz_file = UNDZFile(cmd.dzfile)
File "./undz", line 901, in __init__
self.loadChunks()
File "./undz", line 621, in loadChunks
g = gpt.GPT(self.chunks[0].extract())
File "./undz", line 221, in extract
buf = dctx.decompress(zdata, max_output_size=200000000)
zstd.ZstdError: error determining content size from frame header

$pip show zstandard
Name: zstandard
Version: 0.10.2
Summary: Zstandard bindings for Python
Home-page: [url]https://github.com/indygreg/python-zstandard[/url]
Author: Gregory Szorc
Author-email: gregory.szorc@gmail.com
License: BSD
Location: /home/seadersn/.local/lib/python2.7/site-packages
Requires: cffi
Required-by:

pip2 and pip3 is installed too, on ubuntu 16.04. v30 h930 eu open 21o kdz as test object (writing a script for kdz2zip conversion and wanted to use the new un(k)dz versions). i think that this one uses zlib and not zstandard, because unpacking works with another dz unpacker which hasn't zstandard included (https://github.com/thecubed/kdzutils/blob/master/DZFileTools.py).
[LG V30 Guides, News, & Discussion] runningnak3d:
[MENTION=3138121]seadersn[/MENTION] You mind linking to the KDZ you were trying to extract? You may have found another edge case.

Right now if zlib is needed, I detect that by reading the first two bytes of the compressed data. If it is zlib they are 0x7801 -- at least in every old format KDZ I have come across. However, that is the lowest level of compression. If they used a higher level, then that is denoted by the second byte -- so 0x01 could be something different. If that turns out to be the case, I can use a dict of all possible zlib values, but I won't know until I see the KDZ you are trying to extract.

EDIT: you did do a pull on my repo right -- or better yet, cloned [MENTION=5545101]steadfasterX[/MENTION]'s? Sorry -- gotta ask :)

-- Brian
[LG V30 Guides, News, & Discussion] steadfasterX:
yes I have this error here as well ( [MENTION=3167089]runningnak3d[/MENTION] -> see #lglaf) and I currently trying to fix the detection.

.
[LG V30 Guides, News, & Discussion] seadersn:
jep, i pulled both, yours and steadfasterX', which atm reflect the same state as yours. sry forgot the links, here now are two:

(i would take lg-fw.com, it's much faster)

https://androidfilehost.com/?fid=11410963190603862897

https://lg-firmwares.com/downloads-file/17112/H93021o_00_OPEN_EU_OP_1116.kdz

thx, maestro :)
[LG V30 Guides, News, & Discussion] steadfasterX:
ensure you use python3 ! python2 will fail exactly like that.

.-
[LG V30 Guides, News, & Discussion] seadersn:
let me check which version is used by default on my system ;) python jangles my nerves... xD
[LG V30 Guides, News, & Discussion] steadfasterX:
I have set the shebang lines correctly now. that way using "python" should work even when your default py is not py3

(req a git pull of my repo ofc)

.-
[LG V30 Guides, News, & Discussion] seadersn:
k, will test; it was python 2.7 which was used on my machine.
[LG V30 Guides, News, & Discussion] runningnak3d:
Yea, sum beee-yotch. The shebang change got lost in the PR. I will work on fixing unkdz.py so that it will work with python3 (I really don't want to make undz.py work with python2), so that only one version of Python is needed.

PR will be incoming :)

-- Brian
[LG V30 Guides, News, & Discussion] seadersn:
wonderful!! it's all working now :) thanks to both of you! :good:
[LG V30 Guides, News, & Discussion] steadfasterX:
SALT v3.21 is out which contains (besides other stuff ofc) all the latest changes to lglaf by [MENTION=3167089]runningnak3d[/MENTION] and me :)

Check it out:

https://xdaforums.com/android/software-hacking/tool-salt-lg-revolution-t3717864/post78478683

.-
[LG V30 Guides, News, & Discussion] Dvalin21:
A question that I failed to ask before and possibly just looking over, but how do I recompile back to kdz?
[LG V30 Guides, News, & Discussion] seadersn:
not possible. you'd need their (LG's) signing keys which aren't available for public.
[LG V30 Guides, News, & Discussion] love edition:
How to solve the problem bro [MENTION=3167089]runningnak3d[/MENTION]?
[LG V30 Guides, News, & Discussion] steadfasterX:
Use SALT in the desktop folder named LG . Ensure you update to the latest version 3.21 and try again . It sounds like you extract to a folder which has too less disk space though
[LG V30 Guides, News, & Discussion] love edition:
Hi bro !

I tried using SALT 3.21 and it still failed. :crying:
[LG V30 Guides, News, & Discussion] steadfasterX:
After you try to extract with SALT go to the advanced menu and share the link to the debug log
[LG V30 Guides, News, & Discussion] TjoyD:
This fails to decompress V350N10q.

error message : [!] Error: extraneous data found IN chunkName.
[LG V30 Guides, News, & Discussion] love edition:
How to fix bro ?
[LG V30 Guides, News, & Discussion] TjoyD:
You can temporarily solve the problem by opening undz.py file and find the containing part of error message and deleting the 'sys.exit(1)' phrase.
[LG V30 Guides, News, & Discussion] terirem:
How do I extract/unpack/mount the system_a.image and system_b.image?

Nevermind, it can be mounted, but I upgraded kernel and had to reboot.
[LG V30 Guides, News, & Discussion] love edition:
Hi bro !

This is log file
[LG V30 Guides, News, & Discussion] steadfasterX:
either attach the log or simply use the upload button in SALT.. its there for a reason ;)

thanks for the log anyways. has been fixed. as you are already on the develop channel just click update, once finished close SALT and re-open and you should have 3.22-

3

now.

If you still encounter issues provide the bpaste link after failing ( going to the log menu -> click upload -> copy link )

Thanks

.-
[LG V30 Guides, News, & Discussion] love edition:
i has upload log file new
[LG V30 Guides, News, & Discussion] steadfasterX:
you can not find the upload button don't you? ... it is written clearly in the FAQ 1000 of the SALT thread where you can even find a screenshot guide..:

ok that was my fault, sorry. just click the update again. the version will not increase but it should update kdztools now fine.

.-
[LG V30 Guides, News, & Discussion] hawknest:
Sorry if I'm blind guys but where can I find the undz2.py file? I'm getting errors when decompressing one of the oreo kdz files for the stylo 4?

hawknest@localhost:/data/linux/home/hawknest/kdztools$ sudo python undz.py -f kdzextracted/Q710TS10j_00.dz -x

Traceback (most recent call last):

File "undz.py", line 1069, in <module>

dztools.main()

File "undz.py", line 1035, in main

self.dz_file = UNDZFile(cmd.dzfile)

File "undz.py", line 901, in __init__

self.loadChunks()

File "undz.py", line 622, in loadChunks

g = gpt.GPT(self.chunks[0].extract())

File "undz.py", line 221, in extract

buf = dctx.decompress(zdata, max_output_size=200000000)

zstd.ZstdError: error determining content size from frame header

EDIT : NVM Figured it out
[LG V30 Guides, News, & Discussion] b8engl:
I can't figure this out ( [!] Error: pad is not empty ) ... is this related to my system or is from new compressed method that LG done?

root@duploclique:/home/b8engl/kdztools# python undz -f kdzextracted/V35010h_00.dz -x
[!] Error: pad is not empty
root@duploclique:/home/b8engl/kdztools# pip3 show zstandard
Name: zstandard
Version: 0.11.0
Summary: Zstandard bindings for Python
Home-page: https://github.com/indygreg/python-zstandard
Author: Gregory Szorc
Author-email: gregory.szorc@gmail.com
License: BSD
Location: /usr/local/lib/python3.6/dist-packages
Requires: cffi
root@duploclique:/home/b8engl/kdztools# pip list | grep zstd
[COLOR="Red"]DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.[/COLOR]
root@duploclique:/home/b8engl/kdztools#
[LG V30 Guides, News, & Discussion] maxmotos:
can anyone please port this to windows? :P
[LG V30 Guides, News, & Discussion] weakNPCdotCom:
I'm working on getting this tied into KDZZ using IronPython. I have unkdz working but there are some formatting issues with the undz. py script that I am trying to work out. it looks like the tabbing or EOL conversations are all messed up
[LG V30 Guides, News, & Discussion] weakNPCdotCom:
I am not sure if it was a problem on my end or what, but i just wanted to report that there is a size difference in the H93220s boot image when extracting all chunks from the dz vs extracting boot as a slice. I had to extract it as a slice to be able to extract it's contents. When extracted as a chunk, the format is not recognized.

edit: please correct me if this is the way the utility is supposed to work, but i have confirmed none of the bin.chunk files can be used individually as partition images when using -x after extracting a v2 KDZ

the only way im able to get valid images is by extracting each individually using -s [MENTION=3167089]runningnak3d[/MENTION]
[LG V30 Guides, News, & Discussion] runningnak3d:
Do not use -c or -x ... those options will come into play only when lglaf supports writing.

-c will extract the chunk with the header uncompressed

-x will extract the chunk with the header compressed

-s is what you want to use. That extracts the partition, and if it is chunked, it combines the chunks, and you end up with a usable image that you can flash to a partition.

If you NEED the chunks without the header (not sure why), I can add another switch, or if you don't want to wait, use the -c option and strip the first 512 bytes of each extracted chunk.

-- Brian
[LG V30 Guides, News, & Discussion] runningnak3d:
[MENTION=9374982]weakNPCdotCom[/MENTION] Just noticed you said: "the only way im able to get valid images is by extracting each individually" don't pass a slice number and it will extract all...

../undz -f G710VM10f_08.dz -s

[+] Extracting all slices/partitions

[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting PrimaryGPT_0.bin to PrimaryGPT.image
[+] Extracting persist_13446.bin to persist.image
[+] Extracting vendor_a_67334.bin to vendor_a.image
[+] Extracting vendor_a_100175.bin to vendor_a.image
[+] Extracting vendor_a_132870.bin to vendor_a.image
<snip>

-- Brian
[LG V30 Guides, News, & Discussion] weakNPCdotCom:
Thanks Brian, this is exactly what I needed.
[LG V30 Guides, News, & Discussion] alex.coffen:
[MENTION=3129964]Dvalin21[/MENTION],

When encountering the module cannot import problem, simple solution always being using the right version of python:

For your case, you should use python2.7 because you executed "pip show zstandard" showed "Location: /home/kdz/.local/lib/python2.7/site-packages"

Run command like:

python2.7 ./undz -f kdzextracted/V35010e_00.dz -l
[LG V30 Guides, News, & Discussion] runningnak3d:
The extractor will not work with Python 2.7 -- Python 3.x only.

pip3 install .......

-- Brian
[LG V30 Guides, News, & Discussion] alex.coffen:
But it seems works for me.

I leave a message for you in my thread: https://xdaforums.com/lg-v35/how-to/lg-v35-unlocked-bootloader-rooted-t3910512/page11

I can get the modem_a.img and modem_b.img. Can I use dd to flash those imgs?
[LG V30 Guides, News, & Discussion] runningnak3d:
Little late replying to this, but you have found a KDZ that uses additional fields in the header. I need to know the exact KDZ that you tried to extract so that I can define the field(s).

-- Brian
[LG V30 Guides, News, & Discussion] runningnak3d:
It will work on NEW format KDZs (v35, g7, v40) with Python2, but OLD format (v30 and older) will fail with:

python2 ../undz.py -f H91810j_00.dz -l
Traceback (most recent call last):
File "../undz.py", line 1069, in <module>
dztools.main()
File "../undz.py", line 1035, in main
self.dz_file = UNDZFile(cmd.dzfile)
File "../undz.py", line 901, in __init__
self.loadChunks()
File "../undz.py", line 622, in loadChunks
g = gpt.GPT(self.chunks[0].extract())
File "../undz.py", line 221, in extract
buf = dctx.decompress(zdata, max_output_size=200000000)
zstd.ZstdError: error determining content size from frame header

Bottom line, use Python 3 because all new functionality that will be added will require it even for new format KDZs.

As for your modem question, I will answer that in the proper thread.

-- Brian
[LG V30 Guides, News, & Discussion] alex.coffen:
Yes, you are right. Thanks!!

Anyway, lets use the python3 for this unkdz things.

A small tips, if we want to install "zstandard" in python3 in case that you have multiple versions, please install it as:

sudo python3 -m pip install zstandard
[LG V30 Guides, News, & Discussion] b8engl:
That's ok, don't worry, I have passed that phase also! Plus I don't have the file in the working folder...
[LG V30 Guides, News, & Discussion] Mesba1247:
CMD content:

TypeError: unsupported format string passed to NoGPT._format_

Why is this?

The unpacking file is: X42010l_00.dz
[LG V30 Guides, News, & Discussion] c1937:
need help

guys I just want to get the boot.img

but when I open boot a\b image

nothing happened

need help~~
[LG V30 Guides, News, & Discussion] Mesba1247:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.

Why
[LG V30 Guides, News, & Discussion] jack1621:
root@localhost:~/kdzextracted# python3 undz.py -f V405.dz -x

[!] Error: extraneous data found IN version

whats this mean? v40520a.dz
[LG V30 Guides, News, & Discussion] loveiem:
hello

how to make dz and kdz (for v35 firmvare)?

python3 mkdz.py -f out -l -d '/home/q/Downloads/lg/kdztools/dzextracted'
Traceback (most recent call last):
File "mkdz.py", line 355, in <module>
dztools.main()
File "mkdz.py", line 340, in main
self.dz_file = MKDZFile(self.indir)
File "mkdz.py", line 274, in __init__
self.loadChunks()
File "mkdz.py", line 193, in loadChunks
self.chunks.append(MKDZChunk(name, self.blockShift))
File "mkdz.py", line 98, in __init__
self.chunkName = dz_item['chunkName'].rstrip(b'\x00').decode("utf8")
TypeError: 'NoneType' object is not subscriptable
[LG V30 Guides, News, & Discussion] llucax:
I have an error trying to extract the new V30a version of LG G6 stock firmware:

Traceback (most recent call last):
File "./kdztools/undz", line 1070, in <module>
dztools.main()
File "./kdztools/undz", line 1066, in main
self.dz_file.saveHeader(cmd.dzfile)
File "./kdztools/undz", line 840, in saveHeader
params.write("factoryversion={:s}\n".format(self.ro_lge_factoryversion.decode("utf8")))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 128: invalid continuation byte

I printed `repr(self.ro_lge_factoryversion)` and this is what I get:

b'LGH870AT-00-V30a-OPT1-HQ-AUG-29-2019+0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe3\x07\x08\x00\x03\x00\x1d\x00\x12\x00\x19\x00,'

I wonder if this is an expected issue and if the decoding as UTF-8 should be done as a best effort instead, using `decode("utf-u", errors='replace')` or similar. This is what I have done temporarily to be able to get the boot image I needed from the DZ file.

Thanks!
[LG V30 Guides, News, & Discussion] Inerent:
Any news?
[LG V30 Guides, News, & Discussion] strifej:
Hi, what modification did you do to undz.py to go through? I have the same error when trying to extract a boot image for my LG G7 ULM 20f kdz.

Thanks
[LG V30 Guides, News, & Discussion] markdcouto:
[MENTION=3167089]runningnak3d[/MENTION], im getting the following error while using it on the latest v40 kdz. how should i proceed?

python undz.py -l -f C:\Users\hanti\Downloads\hop\kdztools-1.2\kdzextracted\V40520q_00_OPEN_ESA_DS_0306.dz

[!] Warning: extraneous data found IN version

[!] Error: Value supposed to be zero in field "reserved5" is non-zero (0x5900)
[LG V30 Guides, News, & Discussion] 17.aquarius.89:
Do you have a messenger Telegram or WhatsApp ???
[LG V30 Guides, News, & Discussion] strifej:
I found another way of doing things by just flashing the kdz, boot into 9008/qfil and pull the boot image from there. Use another phone with magisk to patch it, then use qfil to flash it back. Gives me root for any rom now. I have an older android phone that I'll keep around just for this purpose haha.
[LG V30 Guides, News, & Discussion] BROKEN1981:
Delete
[LG V30 Guides, News, & Discussion] kherio:
Im using undz to decompress the H93031a_00_OPEN_EU_OP_1105.dz file, and i get:

[+] Extracting gpt_main5.bin_0 to F.gpt_main5.bin_0.chunk

[+] Extracting gpt_backup5.bin_2043 to F.gpt_backup5.bin_2043.chunk

[+] Extracting gpt_main6.bin_0 to G.gpt_main6.bin_0.chunk

[+] Extracting gpt_backup6.bin_2043 to G.gpt_backup6.bin_2043.chunk

Traceback (most recent call last):

File "./undz", line 1069, in <module>

dztools.main()

File "./undz", line 1065, in main

self.dz_file.saveHeader(cmd.dzfile)

File "./undz", line 839, in saveHeader

params.write("factoryversion={:s}\n".format(self.ro_lge_factoryversion.decode("utf8")))

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 128: invalid continuation byte

what im doing wrong?

thx in advance
[LG V30 Guides, News, & Discussion] tristonpink:
You have done nothing wrong , the KDZ extractor haven't been updated since 2 years ago , the android pie 9 kdz file is not supported by it .
[LG V30 Guides, News, & Discussion] tristonpink:
Here is the windows version kdztool , I have tested it .

https://bbs.lge.fun/thread-69.htm
[LG V30 Guides, News, & Discussion] 一面小清新:
I just used your tutorial to unpack "Stylo 6, K61 and Q60", the result is "dz" that can be unpacked, but "dz" cannot be unpacked
[LG V30 Guides, News, & Discussion] Ratty696:
How do I fix this error?

Traceback (most recent call last):

File "undz.py", line 1068, in <module>

File "undz.py", line 1064, in main

File "undz.py", line 838, in saveHeader

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 128: invalid continuation byte

[6060] Failed to execute script undz