Created
April 3, 2021 19:31
-
-
Save nikiink/8ff2894c42c6320a50dc4b70b32a716a to your computer and use it in GitHub Desktop.
Revisions
-
nikiink created this gist
Apr 3, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,129 @@ ANDROID 10 SAMSUNG IMG PACK/REPACK - UBUNTU 18.10 COSMIC [BOOTLOADER UNLOCKED IS REQUIRED - FIRST UNLOCK BOOTLOADER] ----------------------------------------------------------- /etc/apt/sources.list deb http://old-releases.ubuntu.com/ubuntu/ cosmic main universe restricted multiverse deb-src http://old-releases.ubuntu.com/ubuntu/ cosmic main universe restricted multiverse deb http://old-releases.ubuntu.com/ubuntu/ cosmic-security main universe restricted multiverse deb-src http://old-releases.ubuntu.com/ubuntu/ cosmic-security main universe restricted multiverse deb http://old-releases.ubuntu.com/ubuntu/ cosmic-updates main universe restricted multiverse deb-src http://old-releases.ubuntu.com/ubuntu/ cosmic-updates main universe restricted multiverse ============================================== +------------------------------------------------------------------------------------------------------------------------------+ ## SELINUX NOTE *** (. after linux permissions) Modified files (in the image) must have selinux permissions, otherwise are ignored ( -rw-r--r--. <--- must have a dot at the end ) Before modify a file or replace it, read the actual permissions from that file or from a file in the same folder with this command: getfattr -n security.selinux cscfeature.xml ----> security.selinux="u:object_r:vendor_configs_file:s0" and set it with this command: setfattr -n security.selinux -v "u:object_r:vendor_configs_file:s0" cscfeature.xml +------------------------------------------------------------------------------------------------------------------------------+ [BE ROOT] sudo -s =================================================================== INSTALLATION OF SIMG2IMG - IMG2SIMG - AVBTOOL - getfattr - setfattr =================================================================== apt-get install liblz4-tool android-tools-fsutils openjdk-11-jre-headless build-essential make gcc zlib1g-dev git -y apt-get install attr policycoreutils policycoreutils-python-utils -y cd ~ wget https://github.com/fei-ke/OmcTextDecoder/releases/download/v0.3/omc-decoder.jar ###DECODE EXAMPLE ###java -jar /root/omc-decoder.jar -i cscfeature.xml -o cscfeature_decoded.xml ###ENCODE EXAMPLE ###java -jar /root/omc-decoder.jar -e -i cscfeature_decoded.xml -o cscfeature.xml git clone https://github.com/anestisb/android-simg2img.git cd android-simg2img make cd ~ git clone https://android.googlesource.com/platform/external/avb =================================================================== PACK/REPACK PRODUCT.IMG.LZ4 (FOR EDITING CSCFEATURE.XML) =================================================================== [FIRST OF ALL CREATE A BACKUP OF YOUR DATA, A COMPLETE WIPE IS REQUIRED] cd ~ # VBMETA CREATION [to disable Android Verified Boot (this is required for modify product.img.lz4)] cd ~/avb ./avbtool make_vbmeta_image --flags 2 --padding_size 4096 --output ~/vbmeta.img lz4 -B6 --content-size ~/vbmeta.img ~/vbmeta.img.lz4 cd ~ [COPY THE FILE product.img.lz4 in ~ (extract it from the CSC...tar.md5)] unlz4 ~/product.img.lz4 ~/product.img ~/android-simg2img/simg2img ~/product.img ~/product.img.raw mkdir ~/product mount -t ext4 -o loop ~/product.img.raw ~/product [===================== modify what you want in ~/product *** see SELINUX NOTE above =====================] ## (replace ITV with your SIM country code) # this is to remove preloaded apps (if you like) rm ~/product/preload/ITV/hidden_app/* echo "" > ~/product/omc/ITV/etc/hidden_apks_list.txt # CSC EDIT cd ~/product/omc/ITV/conf # DECODE CSC java -jar ~/omc-decoder.jar -i cscfeature.xml -o cscfeature_decoded.xml vi cscfeature_decoded.xml # modify xml code as your needs <CscFeature_......>....</CscFeature_......> # ENCODE CSC getfattr -n security.selinux cscfeature.xml ----> we get: security.selinux="u:object_r:vendor_configs_file:s0" [write down the part between double quotes] rm cscfeature.xml [ write down the permissions of the file with: ls -l cscfeature.xml ] should be these: -rw-r--r--. java -jar ~/omc-decoder.jar -e -i cscfeature_decoded.xml -o cscfeature.xml rm cscfeature_decoded.xml # between the double quotes insert the part found with getfattr setfattr -n security.selinux -v "u:object_r:vendor_configs_file:s0" cscfeature.xml # check the permissions are the same of the original cscfeature.xml ls -l cscfeature.xml [======================================== image modifications end here ============================] # NOW WE REPACK THE IMAGE cd ~ rm -rf ~/MOD mkdir ~/MOD umount ~/product ~/android-simg2img/img2simg ~/product.img.raw ~/MOD/product.img lz4 -B6 --content-size ~/MOD/product.img ~/MOD/product.img.lz4 Copy ~/MOD/product.img.lz4 on Windows (we are going to flash with odin) Copy the created ~/vbmeta.img.lz4 on Windows Extract with 7zip the CSC.tar.md5 containing the original product.img.lz4 and the other .img.lz4 files Replace product.img.lz4 with the ~/MOD/product.img.lz4 Add the created ~/vbmeta.img.lz4 together with the others .img.lz4 Select all tar extracted contents and recreate the CSC.tar with the same content of CSC.tar.md5 + vbmeta.img.lz4 (select all files -> 7zip -> add to.. -> CSC.tar) Flash CSC with CSC.tar with Odin 3.14 flash it together with the stock AP, BL and CP downloaded with the original CSC.tar.md5 Perform a complete WIPE to use the new CSC information (on the reboot, the phone will start automatically the recovery, select WIPE and reboot) Restart the phone. If you see the SAMSUNG logo at the center logo wait 5 minutes for the first start.