yashsingh1/xdaforums huggingface dataset:
[Android Software Development] osm0sis:
Yes it's normal. boot images don't usually fill the entire partition, so they repack much smaller than the dump, which is padded with 0's.

You didn't quite follow my instructions, you need to try repackimg.bat --original from the command line and see if that resulting image boots to rule out the ramdisk.
[Android Software Development] 8oldemar:
I'm sorry, I misunderstood. Tried it but it didn't help.

Spoiler content hidden.
[Android Software Development] osm0sis:
Good, that narrows it down to the image format itself. I'll check it out. (y)
[Android Software Development] CXZa:
If O would remove the upx like I have said before many more would not detect that as a virus.

Now Chrome gives this if one wants to download it. Not good.

(In lesser cases one at least can select "Keep"...)

View attachment 5208207

So, how to download a virus if using Chrome?

Do not "Discard", not just yet. Go to the download folder and rename the latest "Unconfirmed XXXXXX.crdownload" to something else. The XXXXXX can be any number....
[Android Software Development] 8oldemar:
Or disable the security setting in your browser.
[Android Software Development] CXZa:
Maybe.. if you are downloading viruses on a daily basis...
[Android Software Development] osm0sis:
Chrome doesn't prevent me from downloading it and I haven't messed with any settings. How does that work? 🤔

Go compiled Win32 binary without UTX was 2mb, and if I recall still triggered heuristics. If people would just submit my sudo.exe everywhere as the false-positive it is, then it would be fine. 🤷‍♂️
[Android Software Development] GuneetAtwal:
@osm0sis Hi,

Is there any way to edit init.rc of a MIUI 12 boot.img ? when i try to unpack it says ramdisk not found. I am attaching the boot.img file as well. I want to add a patch which makes the device boot automatically when switch off and cable is connected instead of charging. Any help would be appreciated a lot.
[Android Software Development] soilentgreen:
Why you made it if you know that the sudo is safe?

Again if you know it safe so what if other engines detected it?

@CXZa My chrom is not detected it as virus too

I think its somthing in yours.
[Android Software Development] CXZa:
If some file that can be removed is making people paranoid, why keep it?

I would be a bit worry if my Chrome didn't warn me about suspicious files...
[Android Software Development] soilentgreen:
I think better approach is to ask the companies to fix their false positive.

About chrom I dont know why mine didnt warn me.
[Android Software Development] osm0sis:
Comparing a `repackimg --original` built image-new.img to your original they're identical except for your original has AVBv2 signing at the end. Is your bootloader unlocked? AVBv2 on boot.img shouldn't really be being checked by unlocked bootloaders, though I have heard the odd few cases of it. You could try re-signing it with avbtool to see if that gets it working. Recent instructions for signing (and/or spoofing) AVBv2 with an image for a device which wouldn't otherwise accept modified images popped up in the Magisk Issues the other day actually: https://github.com/topjohnwu/Magisk/issues/2491#issuecomment-660202293

The only other thing I notice is Sony has some potentially new data in the AVBv2 signature which I don't recall ever seeing before, including the strings "com.android.build.boot.fingerprint.Sony/pdx206/pdx206:11/RKQ1.200928.002/1:user/dev-keys" "com.android.build.boot.os_version.11" and "com.android.build.boot.security_patch.2020-12-01"; so if that is something new in AVBv2 or a variant of AVBv2 then perhaps it's checking for those as well and it could explain what you're seeing.
[Android Software Development] 8oldemar:
Yes, of course.

Although I don't understand anything about the kernel / ramdisk, most likely these additions in the signature appeared quite recently - with the release of software based on the new Android 11.
[Android Software Development] osm0sis:
So your device is in the same boat as the Oppo Find X, and AVBv2 is apparently enforced even when unlocked. Try the avbtool instructions from the link in my last post. Might work for your device too. (y)
[Android Software Development] CXZa:
Better? When it isn't necessarily needed?

Some comparisons just for fun.

Spoiler content hidden.

Spoiler content hidden.

Chrome. Probably those security settings mentioned...

I have the standard selected as it was.

chrome://settings/security

https://support.google.com/chrome/answer/6261569

edit2:

One more, using AutoIt v2.64 to keep it small (1 hit) https://www.autoitscript.com/files/AutoIt/AutoIt.zip

Spoiler content hidden.
[Android Software Development] osm0sis:
Not UPX packed sudo.exe is way fewer than I remember; presumably they've improved their heuristics! 🙂

I'll at least unpack it for the next release, then maybe we can pick off those last few false positives more easily. Thanks for the comparison. (y)
[Android Software Development] osm0sis:
@kory-vadim

So it triggers because by pure chance your zImage contains "FC FA BC 00" which is the OSIP bootimg (headerless) "magic", and since that's a more direct match than the workaround AOSP's "ANDROID!" required it took OSIP as the match.

Add "!:strength / 10" after the OSIP bootimg (headerless) line in androidbootimg.magic and it should correctly work around the problem going forward. (y)

What device is this image from by the way?
[Android Software Development] AHMAD EL-NSOUR:
It will generate file named new-image.img or somthing like this
[Android Software Development] ineedroot69:
unrecognized format. error!

what is that? i drop system.img on unpackimg.bat help me ?
[Android Software Development] ineedroot69:
#update for documentation purpose ::

i was avail to extract my system.img using 7-zip

just right click system.img then choose 7-zip then extract

7-zip would say "Warning :: There are some data after the end of payload" just ignore it

i was avail to recover my stock "build.prop" files :D (y)

Disclaimer:: This is not the right way to extract .img but it's good enough for recovering something
[Android Software Development] Xeust:
Hi! My phone got into a bootloop because of an outdated magisk module. I managed to unpack my pixel 3 magisk_patched.img trying to boot into magisk core only and was unable to repack it back. Later, I was pointed out by another developer, Tulsadiver that it was due to the lack of sbin on android 11. For now I already wiped my phone but I would like to ask if there is any other way for me to repack the patched the boot.img or ways to boot with magisk to remove the modules? Just in case something similar happens in the future. Thank you very much.
[Android Software Development] osm0sis:
Completely off topic. At no point has AIK ever claimed it could unpack a system.img. No need to update the AIK documentation, people like you just need to read it.

Sounds like a Magisk question you should ask in the Magisk Discussion thread.. but safe mode is triggered on latest Magisk by triggering Safe Mode on Android with the key combination during boot. That's in the Magisk documentation, so you should probably read it.
[Android Software Development] Xeust:
I did try booting into safe mode using the key combo with magisk intact but it just wont boot for whatever reason. That was why I resorted to the repacking boot.img method. I'll try and ask around the magisk discussion thread. Thank you very much!
[Android Software Development] FearNaiim:
Hello,

Thank you for this great tool. I've been used for 2 years now. recently I'm trying to unpack boot image of samsung S21 and it keeps saying the following error:

unpackbootimg: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

./unpackimg.sh: line 218: 241693 Aborted (core dumped) "$bin/$arch/unpackbootimg" -i "$img"

Error!

Do you have any idea of how I can fix that? I really need to unpack boot image so I can change kernel image on it

Thanks
[Android Software Development] osm0sis:
If you showed the whole log it might help diagnose. Also please upload the boot.img in question.

Just guessing I'd bet it's hdr v3 which my tools will support in the next release.
[Android Software Development] FearNaiim:
Hello, Thank you for your replay. Here is the whole log :

View attachment 5240597

I've attached the boot.img too. Thanks

If you know any other tool that can help to extract this image before your next version come out, please let me know as I need to extract it for school purpose. Thanks
[Android Software Development] osm0sis:
Yep. Header version 3. So you'll have to wait for the next release, or use magiskboot from Magisk in the meantime.
[Android Software Development] FearNaiim:
Thank you for your help. wish you all the best
[Android Software Development] KaMyKaSii:
I'm trying to use AIK (tried Linux and mobile) to repack some recovery images for my Poco M3 and I'm going crazy. The device refuses to boot recovery after flash the repack image by fastboot. Even repacking the stock recovery image with --original --origsize parameters does not work. The device goes back to fastboot. And at that point where the repack image is installed on the recovery partition, it also refuses to start Android with "fastboot reboot" or by long press power button. The device only starts in fastboot. But it is possible to circumvent this and start Android with the command "fastboot continue" (which becomes necessary with each restart). But I realized that if I install the repack image on the boot partition and then proceed with "fastboot continue" then the recovery image is finally loaded. I think maybe this has to do with android boot verification? At the moment I am using an Android 10 GSI and installed the vbmeta image provided by Google with the command "fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img". I'll leave attached the stock recovery image. I hope you have some idea why this is happening. Thank you!
[Android Software Development] osm0sis:
`fastboot --disable-verity --disable-verification flash vbmeta vbmeta.img` was the main thing I was thinking of... I see your image is signed with AVBv2, so maybe it somehow needs to still be signed with it? Magisk started patching AVBv2 flags in place recently, for example: https://github.com/topjohnwu/Magisk/commit/027ec7026252bf1615c19205855ae58a79f1225e
[Android Software Development] KaMyKaSii:
I don't think AVB is necessary because the attached TWRP image is bootable and not signed. But the repack with the original ramdisk and size still fails to boot
[Android Software Development] osm0sis:
I compared in a hex editor the stock recovery.img you uploaded with the image-new.img produced by --original --origsize and literally the only difference is the AVBv2 signature, as I suspected. That TWRP .img you uploaded is actually also AVBv2 signed, by the way. AIK recognizes it and everything. So my hunch is that my hunch is still probably right? 🤷‍♂️

Either use Google's latest avbtool with Python on your Linux machine, or you can play around with signing on-device with my previous avbtool-arm experiment: https://xdaforums.com/t/beta-2017-10-01-supersu-v2-82-sr5.2868133/page-572#post-74498246
[Android Software Development] shadowstep:
@osm0sis Hey Chris, I've been getting multiple warnings while unpacking and repacking the latest version of TWRP v3.5.1 using AIK v3.7. Although the both unpacking and repacking end up going through successfully, I've never seen these warnings before (I tested unpacking and repacking TWRP v3.5.0 and there were no warnings at all). Any clue on what might be the issue? For reference, I tried extracting twrp-3.5.1_9-0-cheeseburger_dumpling.img and got the following (the ones in red are what I'm referring to):

Spoiler content hidden.
[Android Software Development] osm0sis:
They added terminfo for nano, and it includes files with the same name except for case, and of course Windows doesn't handle those. Pretty much nothing I can do about that other than suggest you use AIK-mobile or AIK-Linux instead; maybe AIK-Linux would work on WSL2? 🤔

Edit

:

The errors could likely be ignored without issue since those are all terminfo setups that will never be used on Android. 😛

You could also try this registry hack, but I definitely won't be forcing that on everybody:

ntkern-disable-case-insens.reg:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel]
"obcaseinsensitive"=dword:00000000
[Android Software Development] shadowstep:
Alright, thanks! I'll make the switch and see how it goes. (y)

EDIT

: Made the change manually in regedit, but the warnings still popped up. I'll try rebooting once just because Windows can be finicky that way.
[Android Software Development] osm0sis:
Yep it needs a reboot for that one. 🤞
[Android Software Development] shadowstep:
Those crossed fingers did the trick! Thanks a lot! Unpacked without any warnings, repacked without any warnings. :D
[Android Software Development] osm0sis:
Nice! Yeah, we've pretty much just been lucky not to have run into this before now.
[Android Software Development] scarlet-glass:
@osm0sis When will the HDRv3 support bootimg package tool be released? Or if there is a beta?
[Android Software Development] osm0sis:
You're seriously asking for an ETA on xda? Pretty poor form. It'll be out when it's out.

That said, I've been - working - on it.

BUT, remember, I am a Registered Nurse doing 12-hour shifts on a Mental Health inpatient unit, that's my full time job, and this xda stuff is entirely done with my free time, and out of my goodwill and passion/itch to mess around with Android, with very little in return for my effort.

I work all this weekend, so we'll see what I can get done maybe next week, but no promises.. Not to mention all the work I still need to be doing on my house and other real life things..
[Android Software Development] osm0sis:
So that's very clearly a boot.img.lz4, while AIK supports boot.img, so you can probably guess what you need to do before trying to unpack it. 🙂
[Android Software Development] chronolz:
Well, I tried decompressing the lz4 first and running unpacking on boot.img also

and this is the output

WSL2

Android Image Kitchen - UnpackImg Script

by osm0sis @ xda-developers

Supplied image: boot.img

Setting up work folders...

Image type: AOSP

Signature with "AVBv2" type detected.

Splitting image to "split_img/"...

BOARD_KERNEL_CMDLINE permissive

BOARD_KERNEL_BASE 0x000a2356

BOARD_NAME oidboot.selinux=permissive

BOARD_PAGE_SIZE 0

BOARD_HASH_TYPE sha1

BOARD_KERNEL_OFFSET 0x00008000

BOARD_RAMDISK_OFFSET 0xfff5e2d6

BOARD_SECOND_OFFSET 0xfff5dcaa

BOARD_TAGS_OFFSET 0xfff5dcaa

BOARD_OS_VERSION 57.25.13

BOARD_OS_PATCH_LEVEL 2102-01

BOARD_HEADER_VERSION 3

BOARD_HEADER_SIZE 0

unpackbootimg: malloc.c:2379: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

./unpackimg.sh: line 218: 182 Aborted "$bin/$arch/unpackbootimg" -i "$img"

Error!

WIN10

Android Image Kitchen - UnpackImg Script

by osm0sis @ xda-developers

Supplied image: boot.img

Setting up work folders . . .

Image type: AOSP

Signature with "AVBv2" type detected.

Splitting image to "split_img/" . . .

BOARD_KERNEL_CMDLINE permissive

BOARD_KERNEL_BASE 0x000ee9a2

BOARD_NAME oidboot.selinux=permissive

BOARD_PAGE_SIZE 0

BOARD_HASH_TYPE sha1

BOARD_KERNEL_OFFSET 0x00008000

BOARD_RAMDISK_OFFSET 0xfff11c8a

BOARD_SECOND_OFFSET 0xfff1165e

BOARD_TAGS_OFFSET 0xfff1165e

BOARD_OS_VERSION 57.25.13

BOARD_OS_PATCH_LEVEL 2102-01

BOARD_HEADER_VERSION 3

BOARD_HEADER_SIZE 0

0 [main] ∩âò∩â│♂@∩â╣∩âá♥☻∩é¬∩â╜{┬¿^∩éÄ_∩â╕∩âÇ♥_∩âû^∩éå 1755 cygwin_exception::open_stackdumpfile: Dumping stack trace to unpackbootimg.exe.stackdump

Error!

Press any key to continue . . .
[Android Software Development] osm0sis:
So yup, hdr_v3 support will be added in the upcoming 3.8 release.

Also, please edit your posts using [code] and [hide] tags for the logs so they don't dominate the thread as much. 👍
[Android Software Development] T3chDelicious:
I get the "unrecognized format" error. Got a Sony Xperia 5 II. I downloaded whole Firmware and make a boot.img from the boot.sin inside firmware folder with the program UnSin. Than patched this img with Magisk. I need to remove some lines in ramdisk/fstab.qcom or it will bootloop. But when I drag the patched Magisk.img over unpackimg and than I get the error. Does I do something wrong?

Thanks in advance!
[Android Software Development] T3chDelicious:
Sorry....messed here a little up. Didn't mean to quote myself.
[Android Software Development] osm0sis:
You didn't supply the image so I can't really help. 🤷‍♂️
[Android Software Development] T3chDelicious:
I totally forgot about it. Sorry for that. Here is the patched image.

Edit: Cant attach file. Uploaded on Google Drive. Here ist the link:

Edit: I did figure it out. But anyway much thanks for your reply and help.
[Android Software Development] osm0sis:
You never put a link... I think you're saying you got it working anyway? Cool cool! 👍
[Android Software Development] FearNaiim:
Hi

Sorry for this off topic question but I tried a lot of things and no sucess

I'm trying to turn off SELINUX from Samsung S21 by modifying the kernel image. The image is compiled without any problem. When I try to unpack and repack the boot image with modifying kernel using Magiskboot tool, the phone doesn't start up and get stuck in samsung logo. do you know what could be the problem? I can easily modify the kernel for Samsung S20 but with S21 I got stuck

thanks

by the way I have exynos samsung s21
[Android Software Development] osm0sis:
This isn't the thread for magiskboot. Does Magisk root your device successfully? That's your first step. Any further magiskboot questions should be taken to the Magisk Discussion thread.
[Android Software Development] FearNaiim:
Yes it does. Sorry for writing this question here, I used to compile the kernel with your tool but now I couldn't do it with magiskboot
[Android Software Development] thanhnamPDAviet:
thank for you
[Android Software Development] hanzoo1504:
I am sorry. But this tool is to support only that's it.
[Android Software Development] shoey63:
If Philz CWM is ALREADY SUPPORTED for your device, then you can use this tool to swap ordinary CWM or TWRP recovery with Philz, in CM or Omni boot.img (as an example).

If it is not supported, then you need a dev for your device to what is required as per Philz main thread. No point in asking here....

Go here http://xdaforums.com/showthread.php?p=39433612 and read post 2
[Android Software Development] osm0sis:
Yeah I've told him all that in PM and here a couple times now..
[Android Software Development] hanzoo1504:
Port Philz Recovery jb4.1.2 ???
[Android Software Development] shoey63:
Porting not possible in this thread. End of story.

Give it a rest.
[Android Software Development] SymbiX:
Stweaks

Greetings and happy holidays everyone.

I unpacked the attached kernel and only changed the boot paths for the frameworks. It boots fine, but, it loses support for it's tweak app (stweaks). Also, the kernel is about half a megabyte smaller when repacked. Any ideas?

Thanks in advance.
[Android Software Development] osm0sis:
Did you ask the kernel/tweak app dev? Sounds like it may base support on kernel checksums or something weird like that.
[Android Software Development] SymbiX:
I did. No responce yet. The weird thing is that when I repack using the -o argument, it won't even boot.

Thank you.
[Android Software Development] osm0sis:
That is really weird. I'll take a look.

Edit: Haven't had the chance to look too deeply yet, but there must be something weird about the image that gives it the extra filesize, that's the only way that -o wouldn't repack a file identical to the input.

Edit 2: There is this in the header "smdk4x12" then everything is otherwise identical with the -o image up until the end, where there's then extra crap tacked on, starting "..BOOT_IMAGE_OFFSETS.boot_offset=14369;boot_len=1023;" which seems like nandenv stuff, and then more raw data which looks like a second ramdisk, in xz format.

Definitely breaking with format since this looks like a crazy hack to extract extra stuff into the rootfs during boot. Look in /sbin/ext/install.sh

extract_payload()
{
payload_extracted=1
chmod 755 /sbin/read_boot_headers
eval $(/sbin/read_boot_headers /dev/block/mmcblk0p5)
load_offset=$boot_offset
load_len=$boot_len
cd /
dd bs=512 if=/dev/block/mmcblk0p5 skip=$load_offset count=$load_len | tar x
}

Definitely appears to be looking for the extra section tacked on the end to extract from it. Unfortunately I can't support every dev's random hacks for their own purposes. :(
[Android Software Development] SymbiX:
I understand. Thank you for trying anyway :)

Have a happy new year :)
[Android Software Development] tdawgg777:
i got the vzw s4 and im having trouble unpacking twrp. how were you guys able to unpack those lokied images? i tried to find some info on it but couldnt find anything. i am a noob at this as well
[Android Software Development] osm0sis:
Really great job! Only question I have is whether this would interfere with repacking a working boot.img since all the offsets in the header will be the ones from the loki header, no? I guess I could just split the header info beforehand...

Though here are a couple other interesting developments:

http://xdaforums.com/showpost.php?p=49253223&postcount=187 :)
[Android Software Development] jeboo:
I've had no problems dumping kernel/ramdisk from a de-loki'd boot.img and repacking. I've never tried booting from a de-loki'd boot.img directly as my device doesn't support it.
[Android Software Development] osm0sis:
Fair enough, I guess "reloki'ing" might make it a non-issue, but I'd like to retain as much of the original pre-loki header info as possible for the repack. I'll look into it!
[Android Software Development] :
[MENTION=4544860]osm0sis[/MENTION]

In my signature is a link to a thread I have made with three compiled binaries specifically named, mkbootimg, unmkbootimg, and mkbootfs. They work on ARM devices. Regarding HTC devices, they come with a 256 bit signature prior to the android heading so that junk needs to be removed. Anyways, check it out. May be useful to you and it may not. Though, wanted to throw this your way because you never know lol. If it isn't useful then hey, can't beat me up for not trying to help :). lol
[Android Software Development] hkfriends:
[MENTION=4544860] osm0sis [/MENTION]

I am back to use your tools for my new Pantech A890 kernel.... It seems the tools is working for DTB stuff..

good job :good:
[Android Software Development] kansari921:
not working For Qmobile A7 !!!

It is not working for qmobile a7

i want to port 3.4.5 kernel to it

please do something

it says "Compression used: data Error!"

please if you can port 3.4.5 kernel please do that

Here is the original boot.img
[Android Software Development] tombmax:
THANKS

THANKS
[Android Software Development] osm0sis:
Sorry it took me so long to get back to you. I broke my leg at the end of January and I'm still rediscovering some posts I missed. ;)

Your device seems to have the same problem as the Alps A5ENZE, as mentioned in the OP: "looks like a regular image but has weird section header "labels" that break ramdisk decompression."

See this post for a bit more detail:

http://xdaforums.com/showthread.php?p=48733822#post48733822

As for your intent: Porting a kernel is NOT what this thread's about, that has to be done with kernel source code; we're only talking about ramdisks here.
[Android Software Development] osm0sis:
Might be AVBv2 or fastboot verity/vbmeta stuff. Google/OEMs are making it harder. AIK will support hdr_v3 for the upcoming 3.8 release.