yashsingh1/xdaforums huggingface dataset:
[Android Software Development] martyfender:
If I use your unSU app to remove su, with systemless root, does it replace the backed up boot image or does it continue to use the one patched by supersu?

If not, Is there a command line option to do that or should I back it up first?

Finally, is sepolicy the only thing supersu patches in the boot or are there other things patched by It?

Thanks
[Android Software Development] osm0sis:
You're getting pretty off topic here, and these are all questions you can answer yourself.

Read the instructions for unSU in the post it's attached to.

Read the documentation in the SuperSU zip update-binary header.
[Android Software Development] martyfender:
Sorry for being OT here.

I did find those and read them after my post.
[Android Software Development] XCnathan32:
You're a godsend. I spent forever trying to figure out how to modify a ramdisk without screwing up the permissions, but your tools worked perfectly. Thank you.
[Android Software Development] atarek:
Hello [MENTION=4544860]osm0sis[/MENTION]

I want to say thanks alot for ur AIK-mobile it saved me to modify boot.img ASAP without being near laptop. So it amazing but i noticed a weird behavior as attatched.

I'm using mixplorer, busy box for android NDK and magisk. I copied boot.img in same path with unpackimg.sh but excute failed.

Also in emulator it failed.

Success scenario achieved when typing full path of .sh and .img .

I think I'm missed something but i was on a hurry to use for fix issue in boot.img.

Sorry if I'm missed notes in any post.

Please advice.

View attachment 4228250View attachment 4228251View attachment 4228252

Regards,

Ahmed
[Android Software Development] atarek:
Deleted.
[Android Software Development] osm0sis:
Looks like a couple of peculiarities with the apps you're using and/or your device's shell.

The aik command should set up the su interactive sub-shell with the AIK-mobile directory in its PATH, but that doesn't appear to be the case. That said, the correct way to run an executable in the same directory as you in Linux is with ./ prepended, so you should try ./unpackimg.sh after aik and I'm sure it will work.

The other issue might be with the way your file explorer executes the scripts. Try FX File Explorer and see if it works. :good:
[Android Software Development] atarek:
Worked in emulator after appending ./ before .sh and .img files.

FX file explorer worked flawlessly. I'll communicate this issue with mixplorer dev.

Thanks alot for ur support :)

Regards,

Ahmed
[Android Software Development] shoey63:
Hide Unlocked Bootloader using AIK and pass SafetyNet

This method applies to kernels which haven't already been patched with Sultanxda's method

- Download latest RootSwitchhttps://www.asus.com/zentalk/tw/for...5MjEyfGM2OGVmYTlhfDE1MDEyNDcyNTZ8MHwxNzM1NDI=, extract the apk and install it.

-Download RootSwitch.zip (.supersu and custom_ramdisk_patch.sh, needed for passing SafetyNet checks)

https://mega.nz/#F!NwUAxKjA!lodsOX94Wd4I5HfBFR3jJg, extract the files and place them in the root of the /data directory and make them executable. (rename dot.supersu to .supersu first).

- Unpack your boot.img with AIK and add this to the end of the -cmdline line file in /split_img

androidboot.verifiedbootstate=green

- Repack, flash image-new.img and root/re-root with SuperSU.

That's it. Whenever you want to pass SafetyNet, just toggle off the "Enabled" switch in RootSwitch.

Curious note: /proc/cmdline will still have androidboot.verifiedbootstate=orange in it, but adding androidboot.verifiedbootstate=green seems to over rule it and satisfy SafetyNet that bootloader is locked:cool:
[Android Software Development] Vagelis1608:
Run: ./unpackimg.sh boot.img

Or: sh unpackimg.sh boot.img

Same for repacking.sh
[Android Software Development] luzhonghua0224:
unpack

Hi [MENTION=4544860]osm0sis[/MENTION]

I have unpacked boot.img by android image kitchen, but some direcory and file unpacked failed, such as /su... the .subackup is appeared, so I want to know the reason and how to deal it. Thank you!!

some log

/android_win_tools/cpio: res/images/charger/720x1280/number_3.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/number_4.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/number_5.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/number_6.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/number_7.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/number_8.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/number_9.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/images/charger/720x1280/percent_sign.png: Cannot open: No such file or directory

/android_win_tools/cpio: res/native_packages.xml: Cannot open: No such file or directory

/android_win_tools/cpio: .subackup/0006_init.environ.rc not created: newer or same age version exists

/android_win_tools/cpio: .subackup/0007_init.hisi.rc not created: newer or same age version exists

/android_win_tools/cpio: .subackup/0008_init.rc not created: newer or same age version exists

/android_win_tools/cpio: /su/bin/su not created: newer or same age version exists

/android_win_tools/cpio: /su/bin/daemonsu not created: newer or same age version exists

/android_win_tools/cpio: /su/bin/supolicy not created: newer or same age version exists

/android_win_tools/cpio: /su/bin/supolicy_wrapped not created: newer or same age version exists

/android_win_tools/cpio: /su/lib/libsupol.so not created: newer or same age version exists

/android_win_tools/cpio: /su/bin/sukernel not created: newer or same age version exists

26144 blocks

Error!
[Android Software Development] osm0sis:
This is the second time I've seen this.

You've got a malformed ramdisk, most likely from whatever injected those into it, with both missing directory cpio entries and absolute paths. I've got a workaround for v2.9, which is basically to add -d --no-absolute-paths to the cpio arguments in unpackimg.

You can do so in the meantime if you like, but you should also report the issue to whoever made your rooting tool, since they need to fix their ****.
[Android Software Development] osm0sis:
Turns out the PATH inheritance issue is a Magisk bug (works fine in SuperSU). I reported it to topjohnwu and it will hopefully be fixed in the next Magisk release. :good:
[Android Software Development] rybshik:
Will it work on Moto G4 Athene and Moto G4 Play Harpia with LineageOS 14.1? Thanks
[Android Software Development] Vinnom:
Hi!

Just downloaded AIK-Linux 2.8. Unzipped it and tried to unpack two boot.img of mine: one backed up with TWRP and another made with dd from shell. Both gave me the same error (sorry if I didn't find the solution, I did tried to find it before posting).

For short, I got:

Unpacking failed, try ./unpackimg.sh --sudo
Error!

attached it is all the output I had.

Any ideas?
[Android Software Development] osm0sis:
Hmm that translates to "file or directory not found"?

Read my reply like 4 posts ago about the malformed ramdisk, and try adding those flags to cpio by editing unpackimg.sh
[Android Software Development] Vinnom:
Yeah, that is the right translation. I didn't notice that some characters was messes though.

I saw your post, but I really didn't think was related. I added -d --no-absolute-paths to the cpio arguments but --no-absolute-paths wasn't recognized. So I left only -d and now I got "Done!". Thank you =)

But I got a problem when repacking now. Again I searched the thread but I found only a similar problem with a Samsung boot.img (mine is Huawei). The problem is that the guys could repack his image, I couldn't. Here is my boot.img

./repackimg.sh

Android Image Kitchen - RepackImg Script
by osm0sis @ xda-developers

Packing ramdisk...

Using compression: gzip

Getting build information...
kernel = boot.img-zImage
cmdline = androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 androidboot.bootdevice=7824900.sdhci androidboot.selinux=enforcing
board =
base = 80000000
pagesize = 2048
kernel_offset = 00008000
ramdisk_offset = 01000000
second_offset = 00f00000
tags_offset = 00000100
hash = unknown

Building image...

Using format: AOSP

error: unknown hash algorithm 'unknown'
Error!
[Android Software Development] osm0sis:
Sorry, that should have been --no-absolute-filenames; only required in AIK-Win32 and AIK-Linux.

Yep similar issue. v2.9 will assume unknown to be sha1 for backwards-compatibility with devices that use their own board name length/id offset (or no id hash at all in your case) and also accept the standard. You can just edit split_img/*-hash and change unknown to sha1 for now, and that will more than likely work.

Edit: Hmm the last "nohash" file someone submitted to me also had the bad cpio stuff going on... whoever is making these ****ty root/mod tools needs to fix their crap; do it right or don't do it. :eek:
[Android Software Development] Vinnom:
Oh! Ok, I'll do it as soon as I get home. About the superuser, mine is phh's. Would love to use Chainfire's superSu as its compatibility is better, but Huawei messes too much with their stuff and for now (and I did try the latest release and it doesn't work for me yet. I'll have to report to him at superSu Beta thread)

Enviado de meu HUAWEI CAN usando Tapatalk

EDIT:

I did what you suggested and the whole unpack/repack process is working now, thank you very much. My problem is now other (too many problems in a roll eh? lol). My original boot image size is 80 MB and my new-boot image size is 33 MB. Something is odd here. But I tested even though. Backed up the old one and flashed the new and the device won't boot. In case it helps, the new-boot is here.
[Android Software Development] osm0sis:
Just discovered a minor bug in v1.5; it doesn't support filenames with brackets, ( ), in them. Not really a big deal. I'll fix it in the next version once we've got something more significant to address. ;)

Just a few quotes need to be added in a few spots to clear it up.

Edit: If anyone wants to fix it in the meantime here are the changes (with line #s):

unpackimg.bat:

33: for /f "delims=" %%a in ('type "%ramdiskaname%"') do @set ramdiskaddr=%%a0000

36: for /f "delims=" %%a in ('type "%ramdiskcname%"') do @set ramdiskcomp=%%a

repackimg.bat:

19: for /f "delims=" %%a in ('type "split_img\%ramdiskcname%"') do @set ramdiskcomp=%%a

36: for /f "delims=" %%a in ('type "split_img\%cmdname%"') do @set cmdline='%%a'

39: for /f "delims=" %%a in ('type "split_img\%basename%"') do @set base=0x%%a

42: for /f "delims=" %%a in ('type "split_img\%pagename%"') do @set pagesize=%%a

45: for /f "delims=" %%a in ('type "split_img\%ramdiskaname%"') do @set ramdiskaddr=%%a0000

..and that should do it! :)
[Android Software Development] osm0sis:
So someone felt the need to rate this thread a 2/5.. :mad: Pretty sure this utility is useful and I've been extremely helpful to any who ask or post images. :rolleyes:

If it doesn't work for your device that's not a reason to downrate the thread, that's a reason for you to hate the manufacturer of your device for not following Google's Android image standards.

Edit: Thanks avina for rating it back up! A few more people would help too. :)
[Android Software Development] tajimura:
Any way to do that from an app?

EDIT: meaning Tapatalk app.

Nobody cares what/where is this sent from
[Android Software Development] osm0sis:
No idea, I always use Stock Browser on my phone or Chrome on my tab.. As I understand it you can "open in browser" from the Tapatalk menu?
[Android Software Development] kin912:
[MENTION=4544860]osm0sis[/MENTION]

unpack error,I use win7x64
[Android Software Development] trevd:
[MENTION=3996553]kin912[/MENTION] Do you know if any of the ramdisk scripts contain unicode characters? Can you upload the boot image?

Thanks
[Android Software Development] bombadier:
Just tried to unpack your latest boot-tuna-r382-osmod.img Osmosis and am getting these errors

The kitchen was working up until I updated to window 8.1 preview so whats changed to cause this and how to fix?

Thanks in advance.

BOARD_KERNEL_CMDLINE

BOARD_KERNEL_BASE 10000000

BOARD_PAGE_SIZE 2048

1 [main] cut 1016 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointe

r. Please report this problem to

the public mailing list cygwin@cygwin.com

2 [main] od 6056 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointer

. Please report this problem to

the public mailing list cygwin@cygwin.com

2 [main] head 1492 find_fast_cwd: WARNING: Couldn't compute FAST_CWD point

er. Please report this problem to

the public mailing list cygwin@cygwin.com

BOARD_RAMDISK_ADDR 11000000

2 [main] cut 6864 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointe

r. Please report this problem to

the public mailing list cygwin@cygwin.com

2 [main] cut 1240 find_fast_cwd: WARNING: Couldn't compute FAST_CWD pointe

r. Please report this problem to

the public mailing list cygwin@cygwin.com

Unpacking ramdisk to "/ramdisk/" . . .

Compression used: gzip

2 [main] gzip 5312 find_fast_cwd: WARNING: Couldn't compute FAST_CWD point

er. Please report this problem to

the public mailing list cygwin@cygwin.com

2 [main] cpio 6564 find_fast_cwd: WARNING: Couldn't compute FAST_CWD point

er. Please report this problem to

the public mailing list cygwin@cygwin.com

2781 blocks

Done!
[Android Software Development] osm0sis:
Looks like Windows 8.1 doesn't like the current Cygwin builds involved.
[Android Software Development] bombadier:
Oh dear looks like a while before I am doing any unpacking then:(
[Android Software Development] osm0sis:
You could try running the batch file in compatibility mode for Windows 7 (or less). I'll see if there are any newer builds next week sometime.

Edit: [MENTION=2714876]bombadier[/MENTION] On second read, it actually looks like everything worked fine if you ignore the errors. Does the repacked file actually work?
[Android Software Development] bombadier:
Done some research and decided to test as they were warnings and a unchanged repacked img was successfully flashed,

Also got a question, I asked a couple of times on franco's Gnex thread about including the patches for CD-ROM Emulation as described in frozencow's thread I take it that is beyond the scope of your image kitchen and would need code to be patched?

Thanks
[Android Software Development] osm0sis:
Ah good. Adding 2>nul might handle the warnings and keep the output clean. If there aren't any newer Cygwin files that might fix it I'll PM you a test revision. :good:

And no, unfortunately that's a kernel source patch, beyond the reach of the ramdisk.
[Android Software Development] tOrNadO™:
Hi.. I read your tutorial.. Nice work.. But i have a doubt.. I am trying to unpack boot.img of FXP of Sony Xperia S.. U have provided a link for extracting initramfs from zImage.. I simply don't get it that how do we unpack boot.img?? Sorry for a noob question, i am trying to port a ROM from SGS2 to Sony Xperia S.. Pls help??

Edit: Never mind.. Thanks for sharing this.. I got a thread specially for Xperia 2012/13 devices.. Here it is.. If u r willing to share it in ur thread, u can ask the OP of that thread for permission and share.. :)

http://xdaforums.com/showthread.php?t=1680526
[Android Software Development] churchmice:
Great, I am trying to modify the ramdisk but all ended up in bootloop.
[Android Software Development] osm0sis:
That'll happen if you modify things incorrectly. The disclaimer wasn't a joke. :(

Hopefully your bootloader is unlocked so you can just fastboot flash a working kernel.

Next time you could also try the boot command:

fastboot boot kernel.img

That way it doesn't actually get flashed on your device, just booted temporarily and a reboot will go back to what you have flashed before.
[Android Software Development] avinashrocks1990:
most people out here in the forum consider it a joke others don't bother to read it
[Android Software Development] lozohcum:
Does it work with new sony kernels like those from Xperia J, miro, tipo?

I have serious problem with unpacking my CM10 kernel for XJ, every tool gives an error about missing header.
[Android Software Development] osm0sis:
If they haven't changed their image format then no, just like the other Xperia devices in the OP, ELF is not supported.
[Android Software Development] webdroidmt:
Worked successfully unpacking/repacking TWRP 2.6 recovery on the N7 and it flashed with no problem. Will attempt to do the same on my Nook HD+ and TWRP 2.6.

I didn't see the Nook mentioned in your OP post number 2, so I guess I'll just give a shot and cross my fingers. :laugh: Thanks for a very useful cool tool.

EDIT: Doesn't work on Nook HD+, creates no ramdisk folder and looks like it falls into this category: http://xdaforums.com/showpost.php?p=37379904&postcount=31

Ah, too bad.

Mike T
[Android Software Development] vua777:
learing now

nice dev!
[Android Software Development] kykint:
Looks like v2.8 has some trouble getting tailtype info from G935SKSU1DQF4 boot.img. Tested on windows. Dev could you take a look into this please? Thanks in advance.

boot.img: https://drive.google.com/open?id=0B7E8Z1hIdBEOYkQwZUtxNTZXR00
[Android Software Development] osm0sis:
Hmm right you are! I've got a new-and-improved tailtype method for AIK-mobile v2.9 which already works for it, but I experimented and it looks like it's due to a false positive of PXA (despite no ANDROID! magic) with my GNU tail method in Windows and Linux. I should be able to fix it with an update to androidbootimg.magic. :good:
[Android Software Development] kykint:
Great! Will be looking forward to the update :D
[Android Software Development] osm0sis:
If you want to play with it in the meantime, the fix is quite simple. Basically I just had the detection hierarchy wrong for the AOSP entry so they could all be detected as their own thing by mistake.

Change this:

# Google Pixel/Nexus/AOSP Standard
# [test "x" as workaround to odd file/magic behavior not allowing search here]
0	string	x
>0	search	ANDROID!	AOSP bootimg
>36	string	\x00\x00\x00\x02	\b, PXA variant (02)
>36	string	\x00\x00\x00\x03	\b, PXA variant (03)
>1024	search	LOKI\x01	\b, LOKI header (recovery)
>1024	search	LOKI\x00	\b, LOKI header (boot)
>2048	search	\x88\x16\x88\x58	\b, MTK headers
!:strength * 2

To this:

# Google Pixel/Nexus/AOSP Standard
# [test "x" as workaround to odd file/magic behavior not allowing search here]
0	string	x
>0	search	ANDROID!	AOSP bootimg
>>36	string	\x00\x00\x00\x02	\b, PXA variant (02)
>>36	string	\x00\x00\x00\x03	\b, PXA variant (03)
>>1024	search	LOKI\x01	\b, LOKI header (recovery)
>>1024	search	LOKI\x00	\b, LOKI header (boot)
>>2048	search	\x88\x16\x88\x58	\b, MTK headers
!:strength * 2

(Each > is like a level of "if; then elif", so the >> don't get processed now unless the previous > level of ANDROID! magic is met).
[Android Software Development] kykint:
Works perfectly! Thanks! :highfive:
[Android Software Development] XCnathan32:
Found a small bug on Arch Linux.

I recently got a new hard drive, and I named it "3Tb Seagate". I copied all my files from my old hard drive (named "Programs") to my new hdd.

Unpackimg worked perfectly fine on my old drive, but on my new drive, I got this error:

Splitting image to "split_img/"...

./unpackimg.sh: line 141: /run/media/nathan/3Tb: No such file or directory

Error!

Weird, after renaming my hard drive to "3TbSeagate" it worked totally fine.

I decided to do a bit more testing, and renamed the folder "AIK" (where the AIK-Linux folder is) to "Image Kitchen", and I got this error:

Splitting image to "split_img/"...

./unpackimg.sh: line 141: /run/media/nathan/3TbSeagate/Image: No such file or directory

Error!

So it appears on Arch Linux, the script doesn't work if there are any spaces in the directory path. Not a huge problem at all, just wanted to let you know.
[Android Software Development] osm0sis:
Stay tuned for v2.9, since I'm fairly certain I've resolved all remaining path/name whitespace issues.
[Android Software Development] cascabel:
Just an update: my issue was kernel-related (the one where aik - - restore won't mount. Don't ask me where exactly lol). Had the same issue with magisk (not mounting). Going back to stock kernel fixed everything, including the "aik" command. :D
[Android Software Development] osm0sis:
[MENTION=5980306]sandpox[/MENTION] [MENTION=4393788]webdroidmt[/MENTION] There is actually a second ANDROID! header 1mb in, and this one unpacks correctly. Basically the "Green Loader" is a signature used to make the bootloader accept it. I'll have support for it in v2.9. :good:
[Android Software Development] UltraM8:
[MENTION=4544860]osm0sis[/MENTION], hey, is there any chance you can help us with xmlstartlet? We ported it to android, but having some difficulties in using it) Since you don't answer pm's, i didn't knew where to ask for help.
[Android Software Development] osm0sis:
My Odds and Ends thread would have been more appropriate than here.. Anyway, I'm pretty busy with work (full-time nurse, 12 hour day/night shifts, etc.) and my own Android projects so there's not a lot I can offer.. my only thought is if you're doing a dynamic compile, try static, or vice versa.
[Android Software Development] XCnathan32:
With AIK-Linux V2.8, I'm getting SELinux errors (which results in my device not booting) when I edit a cmdline parameter and then repack an Android O image. I did run the script with --sudo.

I'm not sure if the errors I'm getting are normal, or a result of the way the image was unpacked/packed. However, on android N, whenever I tried to modify the ramdisk without sudo, I got the SELinux errors, but sudo fixed them. However on O I get SELinux errors even if I modify a cmdline parameter. Is it possible Oreo could have changed the way SELinux works?

Edit: Yep, apparently SELinux was changed with O
[Android Software Development] osm0sis:
Hmm not sure what to do about that.. What kind of errors? I'll look into the Oreo changes hopefully later this week.
[Android Software Development] XCnathan32:
I did some research, and with Android O, SELinux is now "modular" apparently, which means that it loads contexts from vendor and system, so system and vendor must be mounted in the first stage. However, in my console-ramoops, at lines 1150-1153 it prints:

[ 5.317171] init: init first stage started!

[ 5.317346] init: First stage mount skipped (missing/incompatible fstab in device tree)

[ 5.317373] init: Skipped setting INIT_AVB_VERSION (not in recovery mode)

[ 5.317395] init: Loading SELinux policy

From that point on, I got a ton of denied SELinux permissions for init services, presumably because the policy was never able to be loaded. The policy loads a little later, but after it already denies a lot of permissions.

In the source for the commits that added the early mount support, there was a bug for the 6p that seems to be what I'm experiencing (see here). So I'm really not certain if it's a bug that still went unpatched, or me not giving the right permissions to the ramdisk, or what.

Edit: nevermind I just had to edit the fstab for it to work.
[Android Software Development] UltraM8:
As i said - it's already ported) So that's not the prob. Thx anyways.
[Android Software Development] osm0sis:
There are differences in the way things work with bionic libc system calls when dynamic vs. static, but yeah, good luck.
[Android Software Development] UltraM8:
It just acts differently with shell scripts, the system use is fine as expected
[Android Software Development] hsbadr:
Sorry for the late reply!

I'd say that supporting Darwin 64-bit is enough, considering that all new Macs are 64-bit capable (since ~2008). I compile on my MacBook Pro with using MacPorts or Homebrew package manager.
[Android Software Development] kessaras:
is there a link for older versions ?

2.4 worked but 2.8 always gives me error for all my phones.

s7, G4, op3T and 2 mtk devices.