yashsingh1/xdaforums huggingface dataset:
[Xperia Z5 Android Development] munjeni:
Another hard day figuring out selinux and things. Found that my filecont tool produced some wrong things, for example one of the things:

produced:

/system/bin/blabla :u:r:blabla:s0

instead of:

/system/bin/blabla -- :u:r:blabla:s0

As you can see "--" is missed and cause problem to sefcontext_compile since pcre regex is totaly not what is expected. Also everybody who used that plaintext file_contexts on android, it was a bit wrong!

Now filecont is fully solved and I have provided updated source code too!

Also I have finished and modified sefcontext_compile, now conversion to binary is perfectly the same like one from original!

Enjoy!

Edit:

updated sefcontext_compile tool, one before crashes

Edit:

again updated since one before also crashed sometimes, thats because I have used fdopen, now its fopen and also file buffers all flushed so definitelly will not crash anymore.

Edit:

new version now booth functions extract/compile in single exe

Edit:

seems sony uses specific stems, now hardcoded stems.

WARNING:

some steams is hardcoded, so sugestion always hex modify newly generated file (just copy and replace steams by using steams from original file!), e.g. how steam looks in hex ascii:

Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F

00000000 8A FF 7C F9 04 00 00 00 0F 00 00 00 38 2E 33 38 Šÿ|ù........8.38
00000010 20 32 30 31 35 2D 31 31 2D 32 33 0A 00 00 00 04 2015-11-23.....
00000020 00 00 00 2F 64 65 76 00 07 00 00 00 2F 73 79 73 .../dev...../sys
00000030 74 65 6D 00 07 00 00 00 2F 76 65 6E 64 6F 72 00 tem...../vendor.
00000040 05 00 00 00 2F 64 61 74 61 00 04 00 00 00 2F 6D ..../data...../m
00000050 6E 74 00 06 00 00 00 2F 63 61 63 68 65 00 04 00 nt...../cache...
00000060 00 00 2F 73 79 73 00 08 00 00 00 2F 70 65 72 73 ../sys...../pers
00000070 69 73 74 00 05 00 00 00 2F 73 62 69 6E 00 05 00 ist...../sbin...
00000080 00 00 2F 70 72 6F 63 00 ../proc.
[Xperia Z5 Android Development] bam80:
Ok. Well, the error is here :)
[Xperia Z5 Android Development] YasuHamed:
for those who CANNOT REMOVE system apps even after ROOT ACCESS on xperia ANDROID N 32.3.A.0.372 (e6833 e6853 e6883)

here is SIMPLE command to fix it

while connected to ADB ... type

su

'grant root access on your mobile screen, then type

chmod -R g+w /system

'this will give you change the permissions to drwxrwxrwx,

ls -lh

'to check the access/permissions

it worked for me ;)
[Xperia Z5 Android Development] doundze:
Hi to all.

Thanks Tobias for your job.

I experienced battery drain after creating an installing the boot image and root.

The phone also become easily hot.

How can I solve the problem.

Thanks in advance
[Xperia Z5 Android Development] YasuHamed:
don't install SUPER SU while creating boot.img

instead flash supersu 2.79 via twrp later!
[Xperia Z5 Android Development] munjeni:
Again updated since one before also crashed sometimes, thats because I have used fdopen, now its fopen and also file buffers all flushed so definitelly will not crash anymore.
[Xperia Z5 Android Development] shoey63:
Download link for inserting TA.img into ramdisk and modifying file_contexts.bin at the same time?
[Xperia Z5 Android Development] meistr91:
hello guys!! i have used script for a long time on .305 and didnt have any problem. Right now i want to upgrade mine .305 to 5.11 so downloaded the latest repack tool (5.11) I got kernel.elf from my FTF (5.11) i placed it to the tool folder, started script i pressed Y:

dm-verity is enabled. Disable? Y

Sony RIC is enabled. Disable? [Y/n] Y

Install TWRP recovery? [Y/n] Y

Found SuperSU-v2.79-SR3-20170114223742 Y

Install DRM Fix - Y

Install busybox - Y

Everything went ok, but after i flash boot.img to my phone (xperia Z5 Compact) I stuck on white sony logo...:/

Edit:

Also before flashing boot.img I had fresh clean .5.11 ftf via flashtool with all wipes, but after that straight away i flashed boot.img . I didnt boot for first time after flaah 5.11 via flashtool. Maybe that can be a problem?

Or maybe latest superSU SR3 cousing this problem?
[Xperia Z5 Android Development] Hamidreza2010:
+1

--------------------------------------------

anybody cant help us?

i cant root my phone with this tool.

when i flash boot.img with supersu stuck on white sony logo and without supersu , phone was not rooted ( also i flashed supersu with recovery )
[Xperia Z5 Android Development] Gewiz:
Try this one:

https://xdaforums.com/showpost.php?p=69987858&postcount=10
[Xperia Z5 Android Development] Hamidreza2010:
someone able to share repack kernel here for android N for z5 6633 ( dual sim ) ?

thanks
[Xperia Z5 Android Development] Falenone:
This is for Z5 Compact, please regular Z5 E6653 repacked too. I'm facing the same issue
[Xperia Z5 Android Development] Gewiz:
After 5sec of searching, i found this thread:

https://xdaforums.com/xperia-z5/general/patched-stock-kernel-32-2-5-11-e6683-t3516979
[Xperia Z5 Android Development] smardu:
Same here, z5c and m4aqua.

Version 5 of the tool is working fine.
[Xperia Z5 Android Development] doundze:
Thanks.

Hi.

Thanks for the reply.

Should I do a fresh installation or install the new built image over the previous one.

Thanks in advance
[Xperia Z5 Android Development] munjeni:
Not yet, I'm working on that tool!
[Xperia Z5 Android Development] YasuHamed:
a fresh installation is must since system is already modified with kernel having supersu presintalled.

but you can try flashing fresh modified kernel only and can observe!

also remember , this rooting don't have RW permission to system! i am trying via code to give system rw access but it get stuck on sony logo.

now even if you have root access on android 7, you cannot remove apps unless u make system writable.

with sony its difficult, however i have read its easy for other brands like lenovo, oneplus3 etc
[Xperia Z5 Android Development] kgalv419:
Question

Hello I have a huge question. If I flash the latest firmware for android 7 and use this method. How exactly to I go about reactivating my TA partition? I did do a backup before unlocking the bootloader so I have a file like TA-(somenumbers).img. I just want to know what are the steps to using that file? and if i reactivate it will bootloader be locked back? Thanks
[Xperia Z5 Android Development] serajr:
Read OP instructions, download its latest version, and:

1. Create a custom boot.img with latest firmware's kernel.elf (ftf > kernel.sin > Flashtool > kernel.elf). Choose Y when prompted for "Install DRM fix?". Flash it with fastboot commands (fastboot flash boot boot.img).

[I]rootkernel kernel.elf [B]boot.img[/B][/I]

2. Create your personal DK.ftf with your TA-(somenumbers).img. Flash it with Flashtool.

[I]flash_dk TA-(somenumbers).img [B]DK.ftf[/B][/I]
[Xperia Z5 Android Development] kgalv419:
THANK YOU

Got it worked just find, now i'm on nougat and rooted with all drm functions. However I think I'll revert back to marshmallow for now, the lack of write permissions of sd card and lack of xposed isn't too nice. Still a big thanks I know what to do in the future now!
[Xperia Z5 Android Development] Falenone:
I'm still on my stock 32.2.A.5.11 got the "prepatched" kernel working and flashed my own backup for TA thing. Service test show all 3 keys OK and FIDO_KEYS Provisioned but when going to settings for X-Reality I see no difference.

Also camera shows no difference afaik.
[Xperia Z5 Android Development] jamesys:
where is the generated boot.img file as it's not in the same folder of rootkernel.
[Xperia Z5 Android Development] YasuHamed:
yes it is created in the same folder!

---------- Post added at 08:03 AM ---------- Previous post was at 08:00 AM ----------

[mention]@serajr [/mention]

sir is there way to make /system writable ?

i made it writable by this method via adb , it gave me access, and remove apps, but in my next reboot, device stuck at boot logo

su

chmod -R g+w /system

'this will give you change the permissions to drwxrwxrwx,

ls -lh

'to check the access/permissions
[Xperia Z5 Android Development] RyTekk:
It's a bad idea, chmod the whole system and its included folder could lead to bootloop due to wrong permisson. Why don't you use flashable zip to modify system instead? I used it to remove bloatwares and got no problem.
[Xperia Z5 Android Development] YasuHamed:
please guide to flashable zip method. if possible.

thank you so much for guiding, i will use this method and will update :)
[Xperia Z5 Android Development] Nyuubi:
Could somebody tell me what size should the boot.img file be ? Mine is 1Kb. I'm new at rooting Z5 (been using Z1 up until now which was easy to root). I get some kind of error when trying to test this.

My code is :

rootkernel kernel.elf boot.img

The response I get is:

kernel.elf: line 1: syntax error : unexpected word (expecting ")")

What should I do? Where's my error?

Edit#1: I've got no problem creating the DK.ftf (also 1 Kb, is that normal?) but creating the boot.img is the only problem!!
[Xperia Z5 Android Development] Aklo01:
boot.img should be about 20Mb.

DK.tft is correct at 1Kb. (it contains just a key)

Do not flash boot.img is its size is so small.

I think, given the error reported by rootkernel , that your kernel.elf is corrupted. Try to download it again
[Xperia Z5 Android Development] Klaus N.:
Have you put the kernel.sin into the rootkernel folder? You have to convert it before to kernel. elf (via FlashTool).
[Xperia Z5 Android Development] Nyuubi:
Yes, both files are in the rootkernel folder. I extracted kernel.elf from kernel.sin and run the code like mentioned but I get the same error!
[Xperia Z5 Android Development] serajr:
I really do not know why you (and many other people too) are experiencing problems while trying to remount system (and rootfs) as rw!

Remounting is working perfectly on Nougat with my XP (F8131) with no workarounds, simply choosing "Y" when asked for "Disable RIC?" (Rootkernel V5.1+).

Either way, you can do it manually as I've already described here.
[Xperia Z5 Android Development] RyTekk:
Try rootkernel.cmd instead on Windows or bash rootkernel.sh on Linux.

delete_recursive(

"/system/app/GoogleAnalyticsProxy",

"/system/priv-app/GoogleBackupTransport",

"/system/priv-app/textinput-chn-xxhdpi",

);

Put it in updater-script, this's just an example, change the right one you wanna delete instead.
[Xperia Z5 Android Development] lebigmac:
Hello.

Is it possible to flash the DK.ftf any other way other than using flashtool? I can't do it using flashtool for some reason. I keep getting a missing FSC script error or similar.

For example would it be possible to flash the DK.ftf file like this?

adb shell dd if=/data/local/tmp/DK.ftf of=/dev/block/bootdevice/by-name/TA

Thanks for any advice.
[Xperia Z5 Android Development] munjeni:
In case you want to say bye bye to your device!
[Xperia Z5 Android Development] Hamidreza2010:
but i have problem with this tool (i used V51.1 )

i made a kernel and flashed via fastboot and go to recovery and flash supersu ( of course cat edit system files like delete , ..... )

but when boot up device i have 2 problem

1- supersu didnt installed ( and root checker said device is not root )

2- when i want to flash file via recovery i saw a some red line about mount and blaaa blaaaa .......

hope you or [MENTION=4120742]munjeni[/MENTION] and ofcourse [MENTION=357342]tobias.waldvogel[/MENTION] fix/update tool

thanks all
[Xperia Z5 Android Development] lebigmac:
I don't want to brick my device.

This is the error that I get in Flashtool when trying to flash the DK.ftf :

07/001/2017 21:01:15 - INFO - Device connected in flash mode
07/001/2017 21:01:15 - INFO - Opening device for R/W
07/001/2017 21:01:16 - INFO - Reading device information
07/001/2017 21:01:16 - INFO - Phone ready for flashmode operations.
07/001/2017 21:01:16 - INFO - Opening TA partition 2
07/001/2017 21:01:16 - INFO - Current device : F8331 - GENERIC_39.0.A.3.30
07/001/2017 21:01:16 - INFO - Closing TA partition
07/001/2017 21:01:16 - INFO - Start Flashing
07/001/2017 21:01:16 - INFO - No loader in the bundle. Searching for one
07/001/2017 21:01:16 - INFO - No matching loader found
07/001/2017 21:01:16 - WARN - No loader found or set manually. Skipping loader
07/001/2017 21:01:16 - INFO - Loader : S1_Root_de8d - Version : 1299-4832_S1_Boot_MSM8996_LA2.0_42 / Boot version : 1299-4832_S1_Boot_MSM8996_LA2.0_42 / Bootloader status : ROOTED
07/001/2017 21:01:16 - INFO - Max packet size set to 4M
07/001/2017 21:01:16 - INFO - USB buffer size set to 512K
07/001/2017 21:01:16 - INFO - [B][COLOR="Red"]No flash script found.[/COLOR][/B]
07/001/2017 21:01:16 - INFO - [B][COLOR="red"]Flash script is mandatory.[/COLOR][/B] Closing session
07/001/2017 21:01:16 - INFO - Ending flash session
07/001/2017 21:01:16 - INFO - Flashing finished.
07/001/2017 21:01:16 - INFO - Please unplug and start your phone
07/001/2017 21:01:16 - INFO - For flashtool, Unknown Sources and Debugging must be checked in phone settings
07/001/2017 21:01:16 - INFO - Device connected in flash mode
[Xperia Z5 Android Development] munjeni:
Try with an old flashtool which don't have fsc things. I realy don't know which one is last one before that thing implemented, you can ask Androxyde! And remember, never touch trim area! :)
[Xperia Z5 Android Development] tobias.waldvogel:
I will have a look at this, but it might take some days as I am very busy with the root topic
[Xperia Z5 Android Development] tobias.waldvogel:
There seems to be an issue with SuperSU in Android 7. It installs and works if I use my integration, but then it drains the battery within 4 hours.

Currently I am adapting superuser instead, which is Open Source. By this we also can control which kind of root we want to grant: all (only for trusted apps, probably you in a terminal) or limit root with only access to app data files for Titanium Backup nor not trustworthy apps like ES explorer
[Xperia Z5 Android Development] serajr:
1- For now, flash a working fotakernel twrp recovery for your device and install SuperSU.

2- Tobias is already aware of rootkernel's twrp sdcard mounting issue.
[Xperia Z5 Android Development] rolo143:
Guys if I want to repack stock kernel for 32.2.A.5.11 fw which version of rootkernel should I use?

EDIT: Guys please help me!!! My phone got stuck in Sony boot image!!! :(

I used rootkernel 5.11

EDIT (2): I used rootkernel 5.0 to create another boot.img and after flashing it, it booted alright. :)

Do not use v5.11 for 32.2.A.5.11 firmware.
[Xperia Z5 Android Development] waleedsq81:
support other divices

Is it tool support DRM fix on XZ
[Xperia Z5 Android Development] kgalv419:
I got this error (Skipping TWRP recovery. No kernel modules for 3.10.84-perf-g0802f10 available) for both v4.51 and v5.0, v5.11 left me stuck on SONY logo please help i'm using firmware 32.2.A.5.11. Any assistance would be greatly appreciated.

---------- Post added at 04:51 AM ---------- Previous post was at 04:48 AM ----------

Did you get TWRP to install i got (Skipping TWRP recovery. No kernel modules for 3.10.84-perf-g0802f10 available) I'm on the same firmware as you
[Xperia Z5 Android Development] devilmaycry2020:
I've used v5.11 to repack 32.2.A.5.11 firmware for my z5 e6683 but it stuck at sony logo. Then i've tried v5.0 and it boot ok but failed to got TWRP working. please help
[Xperia Z5 Android Development] zemetal:
does everything works with v5.11 , RIC,dm-verity,TRWP,DRM?
[Xperia Z5 Android Development] YasuHamed:
seems like you are using wrong kernel

---------- Post added at 08:45 AM ---------- Previous post was at 08:32 AM ----------

1. remover kernel.sin from 32.2.A.5.11.ftf and make it kernel.elf (flashtool)

2. for rootkernel 4.51 and 5.0 and even 5.11 if you are getting "no kernel modules for 3.10.84-perf-g0802f10" then goto folder " \rootkernel_v5.11_Windows_Linux\Android\twrp_common_kmodules" COPY and paste folder "3.10.84-perf-gf38969a" and RENAME it to "3.10.84-perf-g0802f10" ------------- NOW TRY ;)

3. don't install supersu via rootkernel / instead flash it!

---------- Post added at 08:46 AM ---------- Previous post was at 08:45 AM ----------

it worked for me,

but after root you must give /system to writable
[Xperia Z5 Android Development] lebigmac:
Hi. Thanks for your advice munjeni. I tried it with an older version namely 0.9.18.1

and now I get a bunch of errors:

08/048/2017 11:48:00 - INFO - Device connected in flash mode
[COLOR="red"]08/048/2017 11:48:27 - ERROR - root : this bundle is not valid[/COLOR]
08/048/2017 11:48:27 - INFO - Selected Bundle for Sony Xperia XZ (F8331). FW release : 1.0. Customization : DeviceKey
08/048/2017 11:48:27 - INFO - Preparing files for flashing
08/048/2017 11:48:28 - INFO - Please connect your device into flashmode.
08/048/2017 11:48:29 - INFO - Opening device for R/W
08/048/2017 11:48:30 - INFO - Reading device information
08/048/2017 11:48:30 - INFO - Phone ready for flashmode operations.
08/048/2017 11:48:30 - INFO - Current device : F8331 - GENERIC_39.0.A.3.30
08/048/2017 11:48:30 - INFO - Start Flashing
[COLOR="red"]08/048/2017 11:48:30 - ERROR - root : this bundle is not valid[/COLOR]
08/048/2017 11:48:30 - INFO - Ending flash session
[COLOR="Red"]08/048/2017 11:48:30 - ERROR - C:\Flashtool\devices\F83XX\loader.sin (The system cannot find the file specified)
08/048/2017 11:48:30 - ERROR - Error flashing. Aborted[/COLOR]
08/048/2017 11:48:31 - INFO - Device connected in flash mode
08/048/2017 11:48:31 - INFO - Device disconnected
08/048/2017 11:48:36 - INFO - Device connected in flash mode

Thanks Toby for looking into the issue.
[Xperia Z5 Android Development] chinmoy32:
[MENTION=357342]tobias.waldvogel[/MENTION]

after patching the stock 372 kernel with your tool 5.11 I can delete anything inside the system folder

but after 1 sec they all reappear like nothing ever happened to them in the first place.

Can you please tell me how to fix it ??

My set is Z5 E6682 DSDS, Indian .372 Nougat firmware , SU 2.78 SR5
[Xperia Z5 Android Development] shoey63:
System apps are probably symlinked to a sqsh file system. This means they will always reappear on reboot.

Just speculation though....
[Xperia Z5 Android Development] chinmoy32:
nope.

nothing like that,

the whole SYSTEM partition acts like the same

even more. the whole ROOT partition is also the same way..................

no restart is needed ... they reappear after 1 sec or after a refresh from X-plore
[Xperia Z5 Android Development] kgalv419:
That did the trick TWRP working now i used V4.51 was able to flash root and xposed. thanks so much for your help!
[Xperia Z5 Android Development] Hamidreza2010:
ok

thanks i wait for new fixed version

hope release soon

speical thanks again
[Xperia Z5 Android Development] zemetal:
soo if i dont give /system to writable, RIC will still be on?

do i have to do it evertime i boot up my phone?

thx
[Xperia Z5 Android Development] munjeni:
Uh, sony have new sin data structure (lz4 compressed blocks) and by that way in most case before blocks is sent by s1protocol these blocks is extracted on host machine and sent to the device, but since old flashtool don't have that newer sin things it cause that errors, just guesing! Probably somebody need to compile flashtool byself and remove whole fsc mandatory!
[Xperia Z5 Android Development] steom:
flashing the DK.ftf is now superseeded.

https://goo.gl/VAvHok
[Xperia Z5 Android Development] tobias.waldvogel:
Which options did you use for dm-verity and RIC?
[Xperia Z5 Android Development] tobias.waldvogel:
The root partition is ramdisk populated from the boot image. You need to change the boot image if you want a persistent change.
[Xperia Z5 Android Development] chinmoy32:
I know !

RIC value is not the problem in my case. It stays 0 after patching.

The problem is the SYSTEM partition getting mounted as RO at startup.

Changing that to RW from rootexplorer or terminal using busybox or su mount command works most of the time.

But deleting 1 too many files from system causes the phone to boot loop.

I spent some time inside the ramdisk folder last night and got some lines mounting several partition as RO.

I was hoping to find a line mounting SYSTEM as RO so that I could change it to RW. so far no luck.

Also changed the RIC enable file permission to 444 (totally read only) which helps a bit I think.
[Xperia Z5 Android Development] YasuHamed:
please guide from where to download flashable superuser ? [MENTION=627287]tobias.[/MENTION]walvogel

i found july2012 link here https://xdaforums.com/showthread.php?t=1742522

update

I have found it

its https://superuser.phh.me/

THANKS TO [MENTION=5813612]sceryavuz[/MENTION]

https://xdaforums.com/showpost.php?p=70945409&postcount=21
[Xperia Z5 Android Development] serajr:
dm-verity must be disabled in order to be able to perform changes in the /system partition, otherwise you will face bootloops!

SuperSU
[Xperia Z5 Android Development] bruno$0:
When i try to flash a zip, twrp show this message:

" E:Legacy property environment did not initializa successfully. Properties may not be detected. "

Maybe something still missing on the rootkernel script.
[Xperia Z5 Android Development] L0nelyE4rth:
Did you try flashing in fastboot yet ?

btw op, Is this patch can flash and twrp too ?
[Xperia Z5 Android Development] YasuHamed:
new update is out,

.7.00 - 32.3.A.0.376 - 9FEB2017

rootkernel5.20 working fine with SUPERUSER
[Xperia Z5 Android Development] bruno$0:
I don't undertood: Flash a zip in fastboot?

I flash supersu zip in twrp. I prefere to not integrate su in kernel to choose when i will have root binary and play POGO.
[Xperia Z5 Android Development] shoey63:
Also, disabling RIC does not automatically make /system writeable. You STILL need to make it R/W with your favourite root Explorer (or terminal command).

If you don't disable RIC, /system R/W can't be achieved, even with root.
[Xperia Z5 Android Development] kgalv419:
DK.ftf

Quick quick question, what does flashing the DK.ftf do exactly? and should I flash after DRM fix or before?, just wanted a little more details also if I flash a custom rom I won't need to flash again correct? I know those questions are a bit noobish but I just like to be sure about everything, thank you all for your help!
[Xperia Z5 Android Development] Nyuubi:
Hi! If I upload my kernel.img and DK.ftf could somebody do it for me? No matter I try, I cann never make the rootkernel script work!
[Xperia Z5 Android Development] cyberwytch:
I'm a bit confused - you have your kernel.img and DK.ftf? Or you need them generated, from your kernel.elf and TA-*.img? If you mean the latter, I could give it a shot.

Out of curiosity, what problems are you facing? I had issues myself at first, turned out that the script doesn't work with Dash shell (the default in Debian), and only works with Bash, but it doesn't specify this.
[Xperia Z5 Android Development] zebasketteur:
Hi guys, i flashed 32.3.A.0.376 and i build a patch kernel with superuser but when i turn on my phone, supersu app say i don't have supersu and i can't flash it. Can you help me ?
[Xperia Z5 Android Development] cyberwytch:
Superuser is a replacement for SuperSU - I don't believe you need the SuperSU app anymore. Are you having any difficulty with apps that require root?

Edit: This is the replacement app for managing superuser requests: https://play.google.com/store/apps/details?id=me.phh.superuser
[Xperia Z5 Android Development] zebasketteur:
I will desinstall SuperSU app and reflash the kernel, btw adaway don't see i have root access...
[Xperia Z5 Android Development] cyberwytch:
Make sure you install the replacement management app: https://play.google.com/store/apps/details?id=me.phh.superuser
[Xperia Z5 Android Development] barjawid:
patching kernel 5.11

which version did i have to chose for patching kernel 5.11

because i have download all version in your post

all ended with result

failed

remote:dtb not found

cant u figure it out

THX:o
[Xperia Z5 Android Development] zebasketteur:
i have desinstall supersu and root work perfectly but adaway say i can't write in /system why ? When i build my kernel i have sayed Y...
[Xperia Z5 Android Development] bruno$0:
I flash the supersu zip. Everything works fine but i get that error at beginnig install zip.

Maybe something still not okay at all.