yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] 911-Future_Maker:
I can't extract system.patch.dat, command 'move' not found. Win 10 x86
[Android Software/Hacking General [Developers Only]] elhennig:
How can I resize Android N system.dat? Resizing only works for me if I do not use the file_contents file in male_ext4fs. Bit then the image does not seem to be bootable.

Any idea is appreciated...
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
could a few people post their system.transfer.list files for me? im converting this to c#, its almost complete but just wanna debug a little before i release
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
who is to say? well a public source code is to say.

if its so easy you do it then instead of me

everything this script needs to operate is internally implemented stock in c#.
[Android Software/Hacking General [Developers Only]] XDA_h3n:
Heres one from the Amazon Fire TV 4k, I got this from the OTA for 5.2.4.0.

https://ufile.io/ba4b0 Didn't see that OTA files don't work with this. Then how is it possible to create a image from an OTA?

Another one from Fire TV 4k, modified by rbox for a TWRP flashable zip

https://ufile.io/b1d98
[Android Software/Hacking General [Developers Only]] andy_zhang:
I repack system.img into system.new.dat, then flash it, display:unexpect transfer list version. How to solve. Thank u!
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
Post your system transfer list and tell me what android version it is and ill try fix it

Thank you, as far as i know it patches the system, very alike the way this script worka but it patches via hex, a tool could be made quite easily to immitate it although those patches are for the firmware on your device so you would need to dd the system block an image then aplly it, thats why OTA's will come multiple times if more then one update is available to your device, thats why we stick to modifying full firmware instead of update.zips
[Android Software/Hacking General [Developers Only]] XDA_h3n:
Explains a lot about why I spent a couple of hours figuring out how to do it. Thanks for your explanation on those hex patches. :)

I think I might as well just flash the OTA over original recovery and then backup the system partition, seems much more easier than directly patching the firmware which would take a long time and it might not even work. I blame Amazon as they have only ever made firmware's upgrades from the previous firmware, there is simply no full firmware available out there (probably is but closed to them); in this case I had to sniff out the update url.
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
either that or maybe you be the first to post a full firmware?
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
replace 1 on the first line with 3.
[Android Software/Hacking General [Developers Only]] xpirt:
.. and 3rd/4th line should be 0.

btw [MENTION=6542293]andy_zhang[/MENTION] don't use rimg2sdat, use latest img2sdat instead.
[Android Software/Hacking General [Developers Only]] andy_zhang:
Thank u

---------- Post added at 10:37 PM ---------- Previous post was at 10:12 PM ----------

Sir. Display: error unkown transfer list "0"
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
The first line should be 1

2nd and 3rd lines should be 0

Like xpirt gave the example..

1

0

0
[Android Software/Hacking General [Developers Only]] andy_zhang:
I have modified it, but, still erro. :confused:
[Android Software/Hacking General [Developers Only]] Tejas tedi:
How to build nougat system.img

Coz nougat uses file_contexts.bin(binary file) rather than a text file in marshmallow

And make_extfs gives error

Are there any updated tools for nougat??

Can anyone help me ??

Thank you!!
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
what error is it throwing?
[Android Software/Hacking General [Developers Only]] andy_zhang:
Unexpect transfer list [0]
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
post your modified transfer list
[Android Software/Hacking General [Developers Only]] karansangaj:
Android nougat (7.0,7.1,7.1.1) image unpack repack tools

1 . if you have file_contexts file from marshmallow then follow following steps

i. Go to https://android.googlesource.com/platform/system/sepolicy/+/android-7.1.1_r4/file_contexts

ii. copy data of file_contexts from https://android.googlesource.com/platform/system/sepolicy/+/android-7.1.1_r4/file_contexts

and replace with your file_contexts (of marshmallow system). (you can use notepad++ for file_contexts editing).

iii. save file_contexts and use it for packing ext4 image.

iv. use updated make_ext4fs tool for generating ext4 image.

2. Generate file_contexts from cyanogenmod sources , if your device is eligible for CM14.1

i. Go to

a. https://github.com/CyanogenMod/android_system_sepolicy/blob/cm-14.1/file_contexts

b. https://github.com/CyanogenMod/android_device_qcom_sepolicy/blob/cm-14.1/common/file_contexts

c. https://github.com/CyanogenMod/android_device_qcom_sepolicy/blob/cm-14.1/test/file_contexts

d. https://github.com/CyanogenMod/android_device_qcom_sepolicy/blob/cm-14.1/msm8226/file_contexts

e. https://github.com/CyanogenMod/andr...26-common/blob/cm-14.1/sepolicy/file_contexts

f. https://github.com/CyanogenMod/android_vendor_cm/blob/cm-14.1/sepolicy/file_contexts

step d and e according to your device sources

ii. copy and replace all data from above sources to marshmallow file_contexts file

iii. edit in notepad++ and do not change format , save as it is after replacing data.

Android 7.x.x Tools

1. make_ext4fs updated to 7.x.x

2. dat tools updated to 7.x.x ( Thanks to xpirt )

3. Tools attached below

i. main tool - https://drive.google.com/file/d/0B9J1N2fn8CH5eXViRlZCblJhbG8/view?usp=sharing

ii. file_contexts ( moto g cm14.1 ) - https://drive.google.com/file/d/0B9J1N2fn8CH5Z01pbGRsd3RUanM/view?usp=sharing

example : file_contexts

#line 1 "system/sepolicy/file_contexts"

copy here data from https://github.com/CyanogenMod/android_system_sepolicy/blob/cm-14.1/file_contexts

#line 1 "device/qcom/sepolicy/common/file_contexts"

copy here data from https://github.com/CyanogenMod/android_device_qcom_sepolicy/blob/cm-14.1/common/file_contexts

#line 1 "device/qcom/sepolicy/test/file_contexts"

copy here data from https://github.com/CyanogenMod/android_device_qcom_sepolicy/blob/cm-14.1/test/file_contexts

#line 1 "device/qcom/sepolicy/msm8226/file_contexts"

copy here data from https://github.com/CyanogenMod/android_device_qcom_sepolicy/blob/cm-14.1/msm8226/file_contexts

#line 1 "device/motorola/msm8226-common/sepolicy/file_contexts"

copy here data from https://github.com/CyanogenMod/andr...26-common/blob/cm-14.1/sepolicy/file_contexts

#line 1 "vendor/cm/sepolicy/file_contexts"

copy here data from https://github.com/CyanogenMod/android_vendor_cm/blob/cm-14.1/sepolicy/file_contexts

*do not delete #line 1 -------- commands

*just copy data according to sources

*This generated file_contexts is used only for generating bootable ext4 IMG and please do not replace this file_contexts in your rom.
[Android Software/Hacking General [Developers Only]] andy_zhang:
Thank u.i am successful.
[Android Software/Hacking General [Developers Only]] karansangaj:
See post #671 page no 68
[Android Software/Hacking General [Developers Only]] elhennig:
Thanks for the explanation! One question: I do have the MM file_contexts file and I understand your description that I need to replace the first part (i.e. #line 1 "external/sepolicy/file_contexts") only in this case, correct?
[Android Software/Hacking General [Developers Only]] karansangaj:
yes you should replace whole part (#line 1 "external/sepolicy/file_contexts) data

in android n replace it by (#line 1 "system/sepolicy/file_contexts)data

you can also generate file_contexts using cyanogenmod sources for your device

if you are not able to generate file_contexts , tell your device name

so that i can upload file_contexts for your device (i will try).
[Android Software/Hacking General [Developers Only]] elhennig:
I just notived that my file_contexts from MM was not CM13 but another ROM, so this does not really help.

My device is the LG G3 D855 16GB. If you could build the file_contexts for me, I would greatly appreciate that.

Is there a way to use the binary file_contects.bin? Is there any way to decode it to ASCII?

Where can I find a recent and appropriate make_ext4fs binary for Linux? I have one which is supposed to work with Nougat but I am not sure about that.
[Android Software/Hacking General [Developers Only]] karansangaj:
you are building which rom cyanogenmod 14.1 or other rom ( please name it )

and it's ok if file_contexts is not from cm13

just replace (#line 1 "system/sepolicy/file_contexts)data from google source mentioned above (same rom should be built from which you have extracted file_contexts and edited ) to updated android 7.x.x

*This generated file_contexts is used only for generating bootable ext4 IMG and please do not replace this file_contexts in your rom.
[Android Software/Hacking General [Developers Only]] elhennig:
It's CM 14.1 nightly
[Android Software/Hacking General [Developers Only]] karansangaj:
file_contexts for lg g3

https://drive.google.com/file/d/0B9J1N2fn8CH5cVlaT0x4QWxoQ2M/view?usp=sharing

This generated file_contexts is used only for generating bootable ext4 IMG and please do not replace this file_contexts in your rom.

place this file_contexts in ( folder place_dat_transfer_list_file_context_here) in tools provided in main section.

tools supported for windows 32 bit only .

paypal donations email : kscurren4@gmail.com
[Android Software/Hacking General [Developers Only]] Ricky Divjakovski:
ported to c#, will release when more test have been made, will run natively on linux and windows without the need for python, tried implementing ironpython but was incompatible unless i included most of the libs and thats basically a portable python and that is not what we want is it? source code will be public and i will update as xpirt does.

all credits to him as he made this possible.
[Android Software/Hacking General [Developers Only]] elhennig:
Thanks a lot for your help.

I was able to build the resized system image. However I was not successful in installing and booting it.

CM 14.1 showed only the boot animation. I waited at least half an hour knowing that the first boot takes some time.

I guess I need to revert to the original partition sizes in order to be able to migrate to Nougat.
[Android Software/Hacking General [Developers Only]] andy_zhang:
Sir, does not ur tools only be used 7.0?I use it in Android mm, but prompt erro.
[Android Software/Hacking General [Developers Only]] karansangaj:
Make_ext4fs supports only Android 7.x x

Dat to IMG extraction and IMG to dat should work

Make sure you have Python installed (2.7.x)

---------- Post added at 09:16 AM ---------- Previous post was at 09:06 AM ----------

1) make sure you have latest twrp installed on phone

2) make sure changes made in system are correct

3) make sure you have not deleted file_contexts.bin in rom folder
[Android Software/Hacking General [Developers Only]] andy_zhang:
img to dat is erro
[Android Software/Hacking General [Developers Only]] karansangaj:
ext4img should be sparse format

first convert ext4img to sparse format [ use option 05 ]

then convert sparse img to dat img [ use option 06]

i have only tested on android nougat images

it works well

steps

1) copy file_contexts , system.new.dat , system.transfer.list in ( place_dat_transfer_list_file_context_here )folder

2)then run script and follow the steps

*you should have python 2.7.x installed on pc

*do not install python 3.x.x , tools will not work then

if error occurs , please post log or screenshot of error occured
[Android Software/Hacking General [Developers Only]] andy_zhang:
Thank u, i will try

---------- Post added at 06:52 AM ---------- Previous post was at 06:49 AM ----------

Thank u,i am Android mm, i will try it.
[Android Software/Hacking General [Developers Only]] elhennig:
1) I have TWRP 3.0.2.0 (official) installed, so this should be fine.

2) The change in system I made is to reduce the size. The value was ok for MM so I guess this is also ok for Nougat. Or are you talking about other changes? How long is the initial boot supposed to take?

3) The file_contexts.bin is exactly the one packaged with the nightly build.

I really appreciate your support in this case. Currently I have no clue what happens after the installation. Logcat is not showing anything, it just staes "Waiting for device".
[Android Software/Hacking General [Developers Only]] andy_zhang:
still erro:

Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on

win32

#############################

img2sdat binary - version: 1.0

Traceback (most recent call last):

File "E:\system.new.dat\7.1.1 tools\tools\img2sdat.py", line 48, in <module>

main(sys.argv)

File "E:\system.new.dat\7.1.1 tools\tools\img2sdat.py", line 38, in main

input_image = sparse_img.SparseImage(INPUT_IMAGE, tempfile.mkstemp()[1], '0'

)

File "E:\system.new.dat\7.1.1 tools\tools\sparse_img.py", line 51, in __init__

raise ValueError("Magic should be 0xED26FF3A but is 0x%08X" % (magic,))

ValueError: Magic should be 0xED26FF3A but is 0x00000000
[Android Software/Hacking General [Developers Only]] karansangaj:
If you have deleted some important system files in rom

Then it won't boot. Just try upacking repacking official cm14.1 without making changes.

---------- Post added at 04:23 PM ---------- Previous post was at 04:16 PM ----------

This error occurs when there is no sparse image in folder

After using command 04 and 05 , check folder

(Output_converted_folder_to_ext4)

There should be two different system images present in that folder. One is ext4 an other is sparse image.

Also make sure temp file is present in main folder.

*also uninstall python 3.x.x

OR

i think you are not using script

if you are using commands

1) for folder to ext4 : make_ext4fs -T 0 -S file_contexts -l size -a my_new_system.img system

(system files must be in system folder)

2) for ext4 to sparse img : img2simg my_new_system.img system.img

3) for sparse to dat : img2sdat.py system.img

* all tools and folders must be in same folder
[Android Software/Hacking General [Developers Only]] elhennig:
I did not remove anything.

Here is the script I use (as I wrote I am using Linux).

#!/bin/bash
[ $# -ne 1 ] && exit 1
outFile=`echo $1 | sed -e 's/\.zip/_resized.zip/'`
tmpDir=tmp_`date +%s`

[ ! -d $tmpDir ] && mkdir $tmpDir
cd $tmpDir
unzip ../$1

${HOME}/bin/sdat2img.py system.transfer.list system.new.dat system.img

mkdir output
sudo mount -t ext4 -o loop system.img output/
sudo ${HOME}/bin/make_ext4fs -T 0 -S ../file_contexts -l 1121943552 -a system system_new.img output/
sudo umount output/
ls
#read a
rm -r output
rm system.img

#resize2fs system.img 1140M
${HOME}/bin/rimg2sdat system_new.img
#${HOME}/bin/img2sdat.py system_new.img
sudo rm system_new.img

sed -e 's/ro.sf.lcd_density=560/ro.sf.lcd_density=534/' system/build.prop >system/build.prop.new
mv system/build.prop.new system/build.prop

zip -9rm ../$outFile .
cd ..

[ -d $tmpDir ] && rmdir $tmpDir

This scripts works well with MM where I used the file_contexts file from the package to rebuild the ext4 filesystem instead of the "external" one you provided and which I put one level above the tmp dir where the zip is extracted to.

I don't see any modification of the contents instead of the filesystem size.
[Android Software/Hacking General [Developers Only]] karansangaj:
i think you are using old tools which support marshmallow

are you using update make_ext4fs given in main tool.

use main tools attached which are posted by me ( tools are updated for android 7.x.x)

currently tools support win 32 only

also post your system.transfer.list
[Android Software/Hacking General [Developers Only]] elhennig:
The make_ext4fs is from http://xdaforums.com/showpost.php?p=57635842&postcount=2

The file system.transfer.list is the one from the nightly build package:

> cat system.transfer.list
1
174880
erase 2,0,273912
new 94,0,72,73,217,551,6079,6082,26872,26876,29040,29043,32767,32768,32770,32841,32842,33319,55362,55363,55514,55519,65535,65536,65537,66014,71669,71670,71696,71749,72955,98304,98306,98377,98378,98855,103334,103335,103336,103337,103338,103339,103364,103365,118820,118822,128246,128253,128479,128480,131071,131072,131073,163840,163842,163913,163914,164391,167692,167694,167701,167706,167728,167729,167730,167749,196607,196608,196609,229376,229378,229449,229450,229927,247735,247739,247864,247865,247877,247880,247895,248152,254607,254613,256087,256088,256091,256092,262143,262144,262145,262622,262623,266901,273911
[Android Software/Hacking General [Developers Only]] karansangaj:
1) you are using outdated tools

use tools from https://drive.google.com/file/d/0B9J1N2fn8CH5eXViRlZCblJhbG8/view?usp=sharing

tools only support windows 32 bit

2)system.transfer.list generated is according to lollipop version

so system won't boot properply

3)this generated system.transfer.list only support till marshmallow

4) if you don't have windows try this

generate ext4 and sparse image according to your method

use img2simg for conversion of ext4 to sparse image

convert sparse image to dat using following command

img2sdat.py [sparseimage.img]

then you will have new (system.dat , system.transfer.list and system.patch.dat )

* use updated img2sdat.py tool which is given in above link

* img2sdat.py is present in tools folder
[Android Software/Hacking General [Developers Only]] elhennig:
Thanks again. I finally made it to update my script to convert cm14.1 zip and also the resurrection remix N which I installed successful.

I greatly appreciate your patience with me and your support!
[Android Software/Hacking General [Developers Only]] karansangaj:
Welcome bro

I have got appreciation from senior developer

By the way I'm junior developer as well as I'm mechanical engineer :) ;)

PayPal email : kscurren4@gmail.com
[Android Software/Hacking General [Developers Only]] andy_zhang:
i convert system.img to my new system.img ,then convert sparse system.img ,prompt success ,but only 2.17m,i dont know why
[Android Software/Hacking General [Developers Only]] karansangaj:
Check space on disk

Min 6-7 GB free space req on disk
[Android Software/Hacking General [Developers Only]] andy_zhang:
thank u, I will try
[Android Software/Hacking General [Developers Only]] Tejas tedi:
can you provide me the file contexts for my device lg l90 to build CM14.1

Here is the link to githhub : https://github.com/CyanogenMod/android_device_lge_w7

Marshmallow File_contexts: https://drive.google.com/open?id=0B3tcQL-ZiaWvOUdwdmxtSnpZc0U
[Android Software/Hacking General [Developers Only]] karansangaj:
download from link below

https://drive.google.com/file/d/0B9J1N2fn8CH5Z01pbGRsd3RUanM/view?usp=sharing

Hit thanks button

paypal donation email : kscurren4@gmail.com
[Android Software/Hacking General [Developers Only]] Tejas tedi:
getting this error in 06 option of the tools(simg 2 sdat step)
[Android Software/Hacking General [Developers Only]] karansangaj:
seems like tools are corrupted

download tools from following link and retry

https://drive.google.com/file/d/0B9J1N2fn8CH5eXViRlZCblJhbG8/view?usp=sharing
[Android Software/Hacking General [Developers Only]] Tejas tedi:
Tried it still same error on both 32&64 bit PC's..

And that sdat to image also doesn't work says it's successful but no output is generated..[emoji20]
[Android Software/Hacking General [Developers Only]] karansangaj:
Install Python 2.7.x

Uninstall Python 3.5.x

Install 7zip
[Android Software/Hacking General [Developers Only]] custon3:
It decompressed perfectly, but in the last step of the compression ( sparse -> Dat ) always fails me "error block".This is with a file system of cm13.0 in windows x86/python 2.7.x .:confused:
[Android Software/Hacking General [Developers Only]] mnx:
Hi, I tried the tool of firts page second post (I'm on ubuntu)

There is something that I don't understand.

When I tried to do the img2simg The final system.img file is only 640kb size but the system_new.img file is 2.0GB size

I've looked all of thread pages (71), I saw same errors shared but never answered :(

Can you help me ?

Thank you
[Android Software/Hacking General [Developers Only]] elhennig:
See http://xdaforums.com/showpost.php?p=70067090&postcount=694

The tools in the first page are not uptodate anymore.
[Android Software/Hacking General [Developers Only]] mnx:
Thank you but it doesn't answer my question. Your tools are for windows

I work on linux

the img2simg tool is from ubuntu sources android-tools-fsutils
[Android Software/Hacking General [Developers Only]] elhennig:
These are not my tools and I am running this on Linux, too.

Even if I am running opensuse leap I use the ubuntu binary from android-tools-fsutils-5.1.1r36+git20160322 (see https://launchpad.net/ubuntu/yakkety/amd64/android-tools-fsutils/5.1.1r36+git20160322-0ubuntu5)

What I do is:

Extract system.dat with sdat2img.py from this thread

Mount the resulting system.img via loop device

Use the mounted dir to create a new image with make_ext4fs

Create sparse system image with img2simg

Convert system_sparse.img with img2sdat.py to a new system.dat
[Android Software/Hacking General [Developers Only]] mnx:
Thank you

I know the method to do, the problem is file size of output file in img2simg

---------- Post added at 11:43 AM ---------- Previous post was at 11:33 AM ----------

Thank you, I know the method but the problem is on step 4, the filesize of output file is very small, about 640Kb, but the new image created on step 3 is 2Gb filesize
[Android Software/Hacking General [Developers Only]] elhennig:
So you follow the same procedure as I do?

Are there any error message/outputs when running img2simg? Which version do you use?
[Android Software/Hacking General [Developers Only]] mnx:
no errors, same procedure.

img2simg is from linux sources android-tools-fsutils

just filesize is very small

---------- Post added at 12:00 PM ---------- Previous post was at 11:56 AM ----------

I tried with your tools https://launchpad.net/ubuntu/yakkety/amd64/android-tools-fsutils/5.1.1r36+git20160322-0ubuntu5

but same issue
[Android Software/Hacking General [Developers Only]] elhennig:
How do you create your system.sparse.img?

My command with make_.ext4fs looks like this:

make_ext4fs -T 0 -S ../file_contexts -l 1121943552 -a system system_new.img output/

where file_contexts is the cm14.1 file provided by karansangaj and output/ is the mount point of the previous system image.

Do you have enough disk space? I think karansangaj mentioned that you need 6-7 GB but I not sure if that is used in this step.
[Android Software/Hacking General [Developers Only]] mnx:
yes my make-ext4 command is ok, I have the system_new.img that is correct, it's the next step that is bad, but the falie created by make_ext4fs is a raw img not a sparse img ?

About 50Gb available on my disk

the fils_context is from the source rom
[Android Software/Hacking General [Developers Only]] xpirt:
img2sdat 1.1:

- add ability to choose proper version during compression (commit #eb9b693)

- fixes mismatched transfer list version (issue #4)
[Android Software/Hacking General [Developers Only]] DodoGTA:
What's the difference between a raw image and a sparse image?
[Android Software/Hacking General [Developers Only]] androcraze:
A sparse image is sparse, and a raw image is raw;)

"Sparse" is a compressed image format. A raw image can get ***HUGE***, and sparse images made OTA downloading easier on the user. For developers, it's an added step or four.

"Raw" is a direct image grab, with no compression or tweaks. Be prepared for large files.
[Android Software/Hacking General [Developers Only]] DodoGTA:
Thanks for the answer
[Android Software/Hacking General [Developers Only]] andy_zhang:
delet
[Android Software/Hacking General [Developers Only]] Swapnil Soni:
Does this works on sdk25

Because now it has file_contexts.bin insted of file_contexts