Patching Adbd Binary - General Topics

Hi everyone, I'm trying to patch the adbd binary in my phone (rooted and with Android 11) in order to run it as root.
I found out that the binary was located in /apex/com.android.adbd/bin/, which, according to this link, comes from /system/apex/com.android.adbd.apex.
The apex file can be opened like a zip, so I extracted the files and found the apex_payload.img file, which is indeed mounted in /apex/com.android.adbd/.
Now, the problem is that I have to mount the img file in order to patch it, so I tried to do it with the command "mount -t ext4 -o loop apex_payload.img apex_payload" (yes, this folder exists) but I got the error "mount: '/dev/block/loop28'->'apex_payload': Invalid argument", and if I repeat the command the number after loop increases by one every time. I thought that maybe the image file had a read-only lock, like many partitions such as system,vendor,product etc..., and in fact the image has the shared_blocks feature (checked with "tune2fs -l apex_payload.img"), and I tried to remove it with "e2fsck -y -E unshare_blocks apex_payload.img", and this is the output: e2fsck 1.45.4 (23-Sep-2019)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information
apex_payload.img: 38/48 files (2.6% non-contiguous), 1932/1939 blocks
It doesn't return errors, and the exit code is 0, but it doesn't actually remove the read-only lock on the image file (checked again with tune2fs), so now I'm stuck with that problem. Does anyone know how to solve this or if there are other ways to modify an ext4 image?
Thank you very much.

hmmm. im trying to do something similar, but i have a system shell -- you have any luck?

Related

[Q] How do you mount the blob file in linux?

I downloaded the latest US update from from Asus and wanted to mount the blob file in Ubuntu. But don't know how, everything I tried did not work.
sudo mount -t ext4 -o loop blob /temp
sudo mount -t ext3 -o loop blob /temp
Any help?
I would use -t auto instead of manually specifying a filesystem type.
Also, are you sure it's actually a filesystem image? It could very well be a normal compressed file, or their own special-ish format. You could try running file blob (assuming 'blob' is the file name) to see what it thinks it is.
I found the following, but instead of flashing the file, i would first like to extract the contents.
Code:
run “dd if=/data/local/blob of=/dev/block/mmcblk0p4″
then reboot the device, on reboot you should see a progress bar indicating the flashing of the “blob”
i guess i'll look at it with a hex editor. Maybe there will be a header that will tell the story of what it is.

[Q] make_ext4fs to pack /system into system img file

Hi,
I am using make_ext4fs(from system/extra/ext4_utils) to make system.img on host machine and burn this image to pre-built eMMC partition.
The options I used for make_ext4fs is,
make_ext4fs -l 300M -a system system.img /system
I tried with -s option and it just could not be mounted. Anyhow, without -s it mounts ok, but the problem is the file permission gets all screwed up. Before the image was built, the original system folder had files with 777, but after image was built and mounted, all the files are 744. I doubt this has to do with -s option but I am no expert. Does anyone have similar experience like this or know how to fix this permission issue?
Thanks
Search before you post
See
http://forum.xda-developers.com/showthread.php?t=953461
Does anybody know how to generate those fs_config and file_context files for each sub-partition of super.img for the make_ext4fs binary to function properly? Thank you!

how can i get full ubuntu??

there are some problem with my webtop when i want get full ubuntu....like this
tar: ./usr: Cannot change mode to rwxr-xr-x: Read-only file system
tar: .: Cannot utime: Read-only file system
tar: .: Cannot change ownership to uid 0, gid 0: Read-only file system
tar: .: Cannot change mode to rwxr-xr-x: Read-only file system
tar: Error exit delayed from previous errors
unmounting your sdcard from the temp mount, now that we are done copying all the
files.
Now we will mount the sdcard with webtop copied over to it, to the correct place
, so we can patch it, and remove the FACLs and MACLs. These are what prevent you
accessing application and making changes in the ubuntu install.
help me
You need to mount the system as read/write.
In adb type.
su
mount -o remount, rw
Sent from my Atrixperia using xda premium
z652366 said:
there are some problem with my webtop when i want get full ubuntu....like this
tar: ./usr: Cannot change mode to rwxr-xr-x: Read-only file system
tar: .: Cannot utime: Read-only file system
tar: .: Cannot change ownership to uid 0, gid 0: Read-only file system
tar: .: Cannot change mode to rwxr-xr-x: Read-only file system
tar: Error exit delayed from previous errors
unmounting your sdcard from the temp mount, now that we are done copying all the
files.
Now we will mount the sdcard with webtop copied over to it, to the correct place
, so we can patch it, and remove the FACLs and MACLs. These are what prevent you
accessing application and making changes in the ubuntu install.
help me
Click to expand...
Click to collapse
Hi,
I assume you are using my how-to?
I have a few questions, and need you to get me a few things as well, before I can be of more help.
1) I assume you are already rooted? Are you already rooted?
2) Do you have busybox installed? And have it in /system/bin, and not /system/xbin?
3) Did you run my script as root?
I am thinking that it is either just that you are not running this as root, or that your root install did not work.
Can you run the following commands from the command line on your computer, with your phone connected and post them back in here?
Code:
adb shell
su
cd /data/local
id
busybox df -h
ls -l
mount -o remount, rw /system
touch /system/bin/test
rm /system/bin/test
exit
exit
Post the output back in here, and we will see if there is an issue with your root access.
Each line is a single command, and you must ONLY copy one line and paste it to one command line, do NOT copy all of the commands and paste them to your command line window, it will not work.

Question [SOLVED] How to extract files from super.img?

I am using global ROM in TB-J706F but I wanted to extract the original wallpaper from chinese ROM, so I downloaded the one available in lolinet.
Then I did (I am using Linux):
Extract files
Merge super_* to a single file with
Bash:
cat super_1.img super_2.img super_3.img super_4.img > super.img
Extract system_a.img with
Bash:
lpunpack -p system_a super.img ./super
Now I don't know how to mount system_a.img, this is what I tried:
Bash:
> simg2img super/system_a.img super/system_a.ext4.img
Invalid sparse file format at header magic
Failed to read sparse file
Bash:
> sudo mount -t ext4 -o loop super/system_a.img ./system
mount: ./system: wrong fs type, bad option, bad superblock on /dev/loop2, missing codepage or helper program, or other error.
Bash:
> file super/system_a.img
super/system_a.img: data
What am I missing?
P.S.
Anyway if someone has the wallpaper and can upload it somewhere would be great.
MrCrayon said:
I am using global ROM in TB-J706F but I wanted to extract the original wallpaper from chinese ROM, so I downloaded the one available in lolinet.
Then I did (I am using Linux):
Extract files
Merge super_* to a single file with
Bash:
cat super_1.img super_2.img super_3.img super_4.img > super.img
Extract system_a.img with
Bash:
lpunpack -p system_a super.img ./super
Now I don't know how to mount system_a.img, this is what I tried:
Bash:
> simg2img super/system_a.img super/system_a.ext4.img
Invalid sparse file format at header magic
Failed to read sparse file
Bash:
> sudo mount -t ext4 -o loop super/system_a.img ./system
mount: ./system: wrong fs type, bad option, bad superblock on /dev/loop2, missing codepage or helper program, or other error.
Bash:
> file super/system_a.img
super/system_a.img: data
What am I missing?
P.S.
Anyway if someone has the wallpaper and can upload it somewhere would be great.
Click to expand...
Click to collapse
Have you read the link below?
Editing system.img inside super.img and flashing our modifications
I'm trying to modify my system.img (/system/build.prop) to include support for multi users. After struggling a lot, I've succeeded following your guide (that's an awesome work btw) to unpack, mount, modify, umount and repack super.img. Then...
forum.xda-developers.com
mardon85 said:
Have you read the link below?
Editing system.img inside super.img and flashing our modifications
I'm trying to modify my system.img (/system/build.prop) to include support for multi users. After struggling a lot, I've succeeded following your guide (that's an awesome work btw) to unpack, mount, modify, umount and repack super.img. Then...
forum.xda-developers.com
Click to expand...
Click to collapse
Yes, I got some of the commands from there, as far as I understand what they do there is aimed to mount system rw so I shouldn't need it, I tried to mount read only and it gives the same error.
Also I cannot use resize2fs or e2fsck because it's not recognized as an image, I get:
Bad magic number in super-block
I think system_a.img needs an additional step but it's not even compressed, so I'm stuck.
Ok, I solved it.
It was actually very easy, starting from the ROM:
Extract files
Mount super_2.img for system with:
Bash:
sudo mount -t ext4 -o ro,loop super_2.img ./system
The trick is that it needs to be mounted read only with ro.
Nicely done. Did you find the wallpaper?
Yes, it was in system/media/wallpaper.

Question No Permissions for /system/ but I have root

I tried
mount -o rw,remount /system/
But
mount: '/system/' not in /proc/mounts
system-as-root = system is mounted as /, not /system
Permissions are fine.
DavidxxxD said:
system-as-root = system is mounted as /, not /system
Permissions are fine.
Click to expand...
Click to collapse
I can't write to / still
Are you root?
What is output of
Bash:
id
Bash:
su -c mount -o remount,rw /
Also try this to find out more
Bash:
mount | grep "/ "
DavidxxxD said:
Are you root?
What is output of
Bash:
id
Bash:
su -c mount -o remount,rw /
Also try this to find out more
Bash:
mount | grep "/ "
Click to expand...
Click to collapse
Bash:
berlna:/ $ id
uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),1078(ext_data_rw),1079(ext_obb_rw),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid),3012 context=u:r:shell:s0
Bash:
berlna:/ $ su -c mount -o remount,rw /
'/dev/block/dm-8' is read-only
Bash:
berlna:/ $ mount | grep "/ "
/dev/block/dm-8 on / type ext4 (ro,seclabel,relatime,discard)
And yes I have root
I've never seen this output from trying to remount. Could be a permanent read-only attribute somewhere. /dev/block/dm-8 looks like your system is on an encrypted partition, this could have something to do with the error. You can try using the busybox version of mount command. Also, does your device have a super partition? That could explain it.
DavidxxxD said:
I've never seen this output from trying to remount. Could be a permanent read-only attribute somewhere. /dev/block/dm-8 looks like your system is on an encrypted partition, this could have something to do with the error. You can try using the busybox version of mount command. Also, does your device have a super partition? That could explain it.
Click to expand...
Click to collapse
This is the same error i also face in oneplus os12 and yes my dev dm-x also is ro even after root
Its super.img and also i try with busybox
But useless
The only way now i can see is unpack backup super
Unpack edit repack and flash back
But its not possible for me
Rewriting the super partition every time, seems to be the only way in your case.
The lpflash tools are used to work with super partitions.
I've attatched a statically linked 64-bit ARM version that can run on the device, built from this source.
Extract the system image using
Bash:
./lpunpack -p system super.img
Note: This can also be run directly on the block device, it only reads.
From there, you can modify the system and add it to a super image (the firmware usually has sparse ones that need to be decompressed first). You could also flash the new system image directly via fastbootd mode.
Note: Ignore any "invaild sparse header" messages from fastboot.
Don't flash unsparse images on Samsung devices! They will not like it!
Hope this is helpful.
DavidxxxD said:
Rewriting the super partition every time, seems to be the only way in your case.
The lpflash tools are used to work with super partitions.
I've attatched a statically linked 64-bit ARM version that can run on the device, built from this source.
Extract the system image using
Bash:
./lpunpack -p system super.img
Note: This can also be run directly on the block device, it only reads.
From there, you can modify the system and add it to a super image (the firmware usually has sparse ones that need to be decompressed first). You could also flash the new system image directly via fastbootd mode.
Note: Ignore any "invaild sparse header" messages from fastboot.
Don't flash unsparse images on Samsung devices! They will not like it!
Hope this is helpful.
Click to expand...
Click to collapse
Its a super.img thx

Categories

Resources