├── bin
├── lpmake
├── lpunpack
├── magiskboot
└── simg2img
├── setup.sh
├── LICENSE
├── Scamsung.ipynb
├── README.md
└── scamsung.sh
/bin/lpmake:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravindu644/Scamsung/HEAD/bin/lpmake
--------------------------------------------------------------------------------
/bin/lpunpack:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravindu644/Scamsung/HEAD/bin/lpunpack
--------------------------------------------------------------------------------
/bin/magiskboot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravindu644/Scamsung/HEAD/bin/magiskboot
--------------------------------------------------------------------------------
/bin/simg2img:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ravindu644/Scamsung/HEAD/bin/simg2img
--------------------------------------------------------------------------------
/setup.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ################################################################################
3 | # Copyright (c) [2023] [Ravindu Deshan]
4 | #
5 | # Unauthorized publication is prohibited. Forks and personal use are allowed.
6 | #
7 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
8 | ################################################################################
9 | rm -rf "$(pwd)/Scamsung"
10 | clone() {
11 | git clone https://github.com/ravindu644/Scamsung.git > /dev/null 2>&1
12 | cd Scamsung
13 | chmod +x -R bin/
14 | chmod +x scamsung.sh
15 | }
16 | clone
17 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Ravindu Deshan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Scamsung.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "metadata": {
6 | "id": "26XqRPjmLuzU"
7 | },
8 | "source": [
9 | "**Yet another Samsung device firmware extractor. Copies output files to Google Drive, getting necessary files to root with Magisk, and provides essential device files for developers.**\n",
10 | "\n",
11 | "(Click the little ▶️ Button to run)"
12 | ]
13 | },
14 | {
15 | "cell_type": "code",
16 | "execution_count": null,
17 | "metadata": {
18 | "id": "tZWABDspLr_K"
19 | },
20 | "outputs": [],
21 | "source": [
22 | "!export setup_dir=$(pwd); curl -LSs https://raw.githubusercontent.com/ravindu644/Scamsung/Samsung/setup.sh | bash && bash \"${setup_dir}/Scamsung/scamsung.sh\""
23 | ]
24 | },
25 | {
26 | "cell_type": "markdown",
27 | "metadata": {
28 | "id": "ik6isBGkMZ35"
29 | },
30 | "source": [
31 | "**Mounting the Google Drive**"
32 | ]
33 | },
34 | {
35 | "cell_type": "code",
36 | "execution_count": null,
37 | "metadata": {
38 | "id": "qLr7pxDXMZTq"
39 | },
40 | "outputs": [],
41 | "source": [
42 | "from google.colab import drive\n",
43 | "drive.mount('/content/drive')"
44 | ]
45 | },
46 | {
47 | "cell_type": "markdown",
48 | "metadata": {
49 | "id": "bqbZpHUtMjTy"
50 | },
51 | "source": [
52 | "**Copying the Output files to your Google Drive**"
53 | ]
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": 4,
58 | "metadata": {
59 | "id": "2jW2Nxn6MouI"
60 | },
61 | "outputs": [],
62 | "source": [
63 | "!cp -r output /content/drive/MyDrive"
64 | ]
65 | }
66 | ],
67 | "metadata": {
68 | "colab": {
69 | "provenance": []
70 | },
71 | "kernelspec": {
72 | "display_name": "Python 3",
73 | "name": "python3"
74 | },
75 | "language_info": {
76 | "name": "python"
77 | }
78 | },
79 | "nbformat": 4,
80 | "nbformat_minor": 0
81 | }
82 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Samsung Firmware Extractor 3.0 - (aka Scamsung)
2 |
3 | A simple way to root your Samsung device without wasting data and time... ❤️
4 |
5 |
6 |
7 | ## Quick Links 😌
8 |
9 | 01. [Features](https://github.com/ravindu644/Scamsung?tab=readme-ov-file#---features-%EF%B8%8F---)
10 | 02. [How to run](https://github.com/ravindu644/Scamsung?tab=readme-ov-file#how-to-run-%EF%B8%8F)
11 | 03. [How to run the script on a VPS or locally (if you are rich 🗿)](https://github.com/ravindu644/Scamsung?tab=readme-ov-file#how-to-run-the-script-on-a-vps-or-locally-if-you-are-rich-)
12 | 04. [How to root your Samsung device with the help of my Script? [NO TWRP!]](https://github.com/ravindu644/Scamsung/wiki/How-to-root-your-Samsung-device-with-help-of-my-Script%3F-%5B-NO-TWRP-!-%5D) 😉
13 |
14 | ## - Features ⚡️ -
15 |
16 | #### ✅ 01. Extracting only the required files for Magisk root > Saving in your GDrive.
17 | - No need to download the whole firmware package, just get files around 100MB.
18 | #### ✅ 02. Patch the stock recovery image to get fastbootd back...! (Might not work on every device)
19 | - Based on - [Patch-Recovery](https://github.com/Johx22/Patch-Recovery)
20 | #### ✅ 03. Downloading the images inside the AP and CSC without super/system images.
21 | #### ✅ 04. Unpacking the system, vendor, product, and odm images from super.img and Compressing the firmware package using extreme xz compression.
22 |
23 | ## More features are coming soon...
24 |
25 | ## How to run...? 🏃♂️
26 |
27 | #### 01. Open the Script in Google Colab: [](https://colab.research.google.com/github/ravindu644/Scamsung/blob/Samsung/Scamsung.ipynb)
28 | #### 02. Press all the play buttons (▶️).
29 | #### 03. The script will ask you a firmware link. You must put a direct link for the full firmware package. I prefer samfw.com for this.
30 | - Open samfw.com.
31 | - Type your model number > choose your current region (CSC).
32 | - Go to your phone's settings > about phone > software information > find the last digits of your build number.
33 |
34 | - Find the exact firmware version that matches your build number.
35 | - Click "Download on Samfw server" > once the download started, cancel it and go to the download page by pressing "ctrl + j".
36 | - Right-click on the canceled firmware file and choose "copy link"
37 | - Then give the link to the script.
38 | #### 04. Once my script downloaded the firmware of your device, it will ask for "What you want to do...?" like this:
39 |
40 |
41 | #### 05. If you want to dump only the files for root, just press 1, and the script will do the task for you.
42 | - Jump to the wiki to know how to use my script to root your device.
43 |
44 | ## How to run the script on a VPS or locally (if you are rich 🗿)
45 |
46 | ### Paste this in the terminal > Press enter :
47 |
48 | ```
49 | export setup_dir=$(pwd); curl -LSs https://raw.githubusercontent.com/ravindu644/Scamsung/Samsung/setup.sh | bash && bash "${setup_dir}/Scamsung/scamsung.sh"
50 | ```
51 |
52 | ### Yet another project by [@Ravindu_Deshan](https://t.me/Ravindu_Deshan) for [@SamsungTweaks](https://t.me/SamsungTweaks) ❤️
53 | #### Made with ❤️ in Sri Lanka 🇱🇰
54 |
--------------------------------------------------------------------------------
/scamsung.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ################################################################################
4 | # Copyright (c) [2023] [Ravindu Deshan]
5 | #
6 | # Unauthorized publication is prohibited. Forks and personal use are allowed.
7 | #
8 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
9 | ################################################################################
10 | WDIR=$(pwd)
11 | banner (){
12 | echo -e "\n\033[1;34mSamsung Firmware Extractor 3.0 - By Ravindu Deshan\033[0m"
13 | echo -e "\t\033[1;31mInstalling requirements...\033[0m\n"
14 | }
15 |
16 | dependencies() {
17 | sudo apt update > /dev/null 2>&1
18 | sudo apt install simg2img make lz4 openssl python3 python-is-python3 > /dev/null 2>&1
19 | compiling_lz4(){
20 | echo -e "\t\033[1;31mCompiling lz4...\033[0m\n"
21 | git clone https://github.com/lz4/lz4.git > /dev/null 2>&1
22 | cd lz4 && make > /dev/null && make install > /dev/null 2>&1
23 | cd "$WDIR"
24 | }
25 | compiling_lz4
26 | echo -e "\n\033[1;32mRequirements Installation Finished..!\033[0m"
27 | }
28 |
29 | variables(){
30 | echo -e "\033[1;37m[+] Enter your Device Name : \033[0m\n"
31 | read DEVICE_NAME
32 | BASE_TAR_NAME="Base files - $DEVICE_NAME.tar"
33 | }
34 |
35 | get_link(){
36 | echo -e "\033[1;37m[i] Enter your firmware link [from samfw.com]: \n\033[0m"
37 | read FIRMWARE_LINK
38 | }
39 |
40 | directories(){
41 | cd "$WDIR"
42 | rm -rf Downloads Workplace output super recovery
43 | echo -e "\033[1;31m[+] Creating directories...\n\033[0m"
44 | mkdir Downloads Workplace output super recovery > /dev/null 2>&1
45 | echo -e "\033[1;32m[i] Done..!\033[0m"
46 | }
47 |
48 | downloading() {
49 | cd "$WDIR/Downloads" # Change directory
50 | get_link
51 | echo -e "\033[1;31m[+] Downloading firmware.zip...\n\033[0m"
52 | if curl -# -o firmware.zip "$FIRMWARE_LINK" --retry 3; then
53 | echo -e "\033[1;32m[i] Download Completed..!\033[0m"
54 | else
55 | echo -e "\033[1;31m[x] Error: Download failed. Enter a valid link :\033[0m"
56 | get_link
57 | fi
58 | }
59 |
60 | extracting(){
61 | cd "$WDIR/Downloads" # Change directory
62 | echo -e "\033[1;31m[+] Extracting the firmware Zip...\n\033[0m"
63 | unzip firmware.zip && rm firmware.zip
64 |
65 | for file in *.tar.md5; do
66 | tar -xvf "$file" && rm "$file"
67 | done
68 |
69 | if [ -e "$WDIR/Downloads/recovery.img.lz4" ]; then
70 | cp "$WDIR/Downloads/recovery.img.lz4" "$WDIR/recovery"
71 | else
72 | cp "$WDIR/Downloads/recovery.img" "$WDIR/recovery"
73 | fi
74 | echo -e "\n\033[1;32m[i]Zip Extraction Completed..!\033[0m"
75 |
76 | chk_lz4(){
77 | files=$(find . -name "*.lz4")
78 | if [ -n "$files" ]; then
79 | echo -e "\n\033[1;32m\n[i]Decompressing LZ4 files...\033[0m\n"
80 | lz4 -m *.lz4 > /dev/null 2>&1
81 | rm *.lz4 #cleaning
82 | fi
83 | }
84 |
85 | chk_lz4
86 | }
87 |
88 | is_dynamic(){
89 | cd "$WDIR/Downloads" # Change directory
90 | if [ -e super.img ]; then
91 | PARTITION_SCHEME=1
92 | echo -e "\033[1;32m[i] Dynamic Partition Device Detected..!\033[0m"
93 | IMG="super.img"
94 | CMD(){
95 | mv $IMG "$WDIR/super"
96 | }
97 |
98 | elif [ -e system.img ] && [ -e vendor.img ]; then
99 | PARTITION_SCHEME=2
100 | echo -e "\033[1;32m[i] Non-Dynamic Partition Device Detected..!\033[0m"
101 | IMG="system.img"
102 | CMD(){
103 | mv $IMG "$WDIR/super"
104 | mv vendor.img "$WDIR/super"
105 | mv product.img "$WDIR/super"
106 | }
107 |
108 | elif [ -e system.img ] || [ -e system.img.ext4 ] && [ ! -e vendor.img ] ; then
109 | is_legacy=1
110 | CMD(){
111 | echo -e "\n\033[1;32mCurrently only supports Base files extracting for Legacy Devices..!\033[0m\n"
112 | sleep 2
113 | echo -e "\033[1;32m[i] Restarting..!\033[0m"
114 | sleep 2
115 | user_selection
116 | }
117 |
118 | else
119 | echo "An Internal Error occured..!"
120 | exit 1
121 | fi
122 | }
123 |
124 | LCMD(){
125 | if [ "$is_legacy" == 1 ]; then
126 | echo -e "\n\033[1;32mCurrently only supports Base files extracting for Legacy Devices..!\033[0m\n"
127 | sleep 2
128 | echo -e "\033[1;32m[i] Restarting..!\033[0m"
129 | sleep 2
130 | user_selection
131 | fi
132 | }
133 |
134 | recovery_patch(){
135 | echo -e "\n\033[1;31m[+] Patching the recovery to get Fastbootd back..!\n\033[0m"
136 | chmod a+x $WDIR/Scamsung/bin/*
137 | cd "$WDIR" && cd recovery
138 | cp "$WDIR/Downloads/recovery.img" .
139 | if [ -f recovery.img.lz4 ];then
140 | lz4 -B6 --content-size -f recovery.img.lz4 recovery.img
141 | fi
142 |
143 | off=$(grep -ab -o SEANDROIDENFORCE recovery.img |tail -n 1 |cut -d : -f 1)
144 | dd if=recovery.img of=r.img bs=4k count=$off iflag=count_bytes
145 |
146 | if [ ! -f phh.pem ];then
147 | openssl genrsa -f4 -out phh.pem 4096
148 | fi
149 |
150 | mkdir unpack
151 | cd unpack
152 | $WDIR/Scamsung/bin/magiskboot unpack ../r.img
153 | $WDIR/Scamsung/bin/magiskboot cpio ramdisk.cpio extract
154 | # Reverse fastbootd ENG mode check
155 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery e10313aaf40300aa6ecc009420010034 e10313aaf40300aa6ecc0094 # 20 01 00 35
156 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery eec3009420010034 eec3009420010035
157 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 3ad3009420010034 3ad3009420010035
158 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 50c0009420010034 50c0009420010035
159 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 080109aae80000b4 080109aae80000b5
160 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 20f0a6ef38b1681c 20f0a6ef38b9681c
161 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 23f03aed38b1681c 23f03aed38b9681c
162 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 20f09eef38b1681c 20f09eef38b9681c
163 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 26f0ceec30b1681c 26f0ceec30b9681c
164 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 24f0fcee30b1681c 24f0fcee30b9681c
165 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 27f02eeb30b1681c 27f02eeb30b9681c
166 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery b4f082ee28b1701c b4f082ee28b970c1
167 | $WDIR/Scamsung/bin/magiskboot hexpatch system/bin/recovery 9ef0f4ec28b1701c 9ef0f4ec28b9701c
168 | $WDIR/Scamsung/bin/magiskboot cpio ramdisk.cpio 'add 0755 system/bin/recovery system/bin/recovery'
169 | $WDIR/Scamsung/bin/magiskboot repack ../r.img new-boot.img
170 | mv new-boot.img ../recovery-patched.img; cd ..
171 |
172 | python3 "$WDIR/Scamsung/bin/avbtool" extract_public_key --key phh.pem --output phh.pub.bin
173 | python3 "$WDIR/Scamsung/bin/avbtool" add_hash_footer --partition_name recovery --partition_size $(wc -c recovery.img |cut -f 1 -d ' ') --image recovery-patched.img --key phh.pem --algorithm SHA256_RSA4096
174 | mv recovery-patched.img "$WDIR/output/recovery.img"
175 | #tar cvf fastbootd-recovery.tar "$WDIR/output/recovery.img"
176 | echo -e "\033[1;32m\n[i] Patching Done..!\n"
177 | cd "$WDIR/output" #changed dir
178 |
179 | }
180 |
181 | base_files(){
182 | echo -e "\033[1;31m[+] Copying the Required files for Magisk/Developement...\n\033[0m"
183 |
184 | fastbootd_function(){
185 |
186 | echo -e "\033[1;32m[i] Do you want to patch your recovery to get Fastbootd..?\n\t1.yes\n\t2.no\n\033[0m"
187 | read -p "Choose value (1,2) : " fastbootd_input
188 | if [ "$fastbootd_input" == 1 ]; then
189 | recovery_patch
190 | else
191 | echo "Skipping Fastbootd patch.."
192 | fi
193 | }
194 |
195 | if [ "$is_legacy" == 1 ] && [ -e system.img ] || [ -e system.img.ext4 ]; then
196 | cd "$WDIR/Downloads" #changed dir
197 | cp boot.img recovery.img "$WDIR/output/"
198 | cd "$WDIR/output" #changed dir
199 | tar cvf "$BASE_TAR_NAME" boot.img recovery.img ; rm *.img #cleaning
200 |
201 | elif [ "$PARTITION_SCHEME" == 1 ]; then
202 | cd "$WDIR/Downloads" #changed dir
203 | cp boot.img vbmeta.img recovery.img dtbo.img "$WDIR/output/"
204 | cd "$WDIR/output" #changed dir
205 | fastbootd_function
206 | tar cvf "$BASE_TAR_NAME" boot.img vbmeta.img recovery.img dtbo.img; rm *.img #cleaning
207 | else
208 | cd "$WDIR/Downloads" #changed dir
209 | dt_check(){
210 | if [ -e dt.img ]; then
211 | is_dt=1
212 | fi
213 | if [ -e dtbo.img ]; then
214 | is_dtbo=1
215 | fi
216 | }
217 | dt_check
218 | if [ "$is_dt" == 1 ] && [ $is_dtbo == 1 ]; then
219 | cp boot.img vbmeta.img recovery.img dtbo.img dt.img "$WDIR/output/"
220 | cd "$WDIR/output" #changed dir
221 | fastbootd_function
222 | tar cvf "$BASE_TAR_NAME" boot.img vbmeta.img recovery.img dtbo.img dt.img; rm *.img #cleaning
223 | elif [ ! "$is_dt" == 1 ] && [ $is_dtbo == 1 ]; then
224 | cp boot.img.lz4 vbmeta.img.lz4 recovery.img.lz4 dtbo.img.lz4 "$WDIR/output/"
225 | cd "$WDIR/output" #changed dir
226 | fastbootd_function
227 | tar cvf "$BASE_TAR_NAME" boot.img vbmeta.img recovery.img dtbo.img ; rm *.img #cleaning
228 | else
229 | cp boot.img vbmeta.img recovery.img "$WDIR/output/"
230 | cd "$WDIR/output" #changed dir
231 | fastbootd_function
232 | tar cvf "$BASE_TAR_NAME" boot.img vbmeta.img recovery.img ; rm *.img #cleaning
233 | fi
234 |
235 | fi
236 | zip "${BASE_TAR_NAME}.zip" "$BASE_TAR_NAME"
237 | rm "$BASE_TAR_NAME"
238 | echo -e "\n\033[1;32m[i] Zip file created: ${BASE_TAR_NAME}.zip\033[0m"
239 | }
240 |
241 | ### EXTRACTING SYSTEM PARTITION ####
242 |
243 | super_extract(){
244 | if [ ! "$is_legacy" == 1 ]; then
245 | echo -e "\033[1;31m[+] Moving files to super directory...\n\033[0m"
246 | cd "$WDIR/Downloads"
247 | CMD
248 | cd "$WDIR/super" #changed dir
249 | echo -e "\033[1;32m[i] Cleaned up and you are now in the super directory !\n\033[0m"
250 | echo -e "\033[1;31m[+] Decompressing ${IMG}...\n\033[0m"
251 | lz4 "$IMG"
252 | rm "$IMG"
253 | echo -e "\n\033[1;32m[i] Decompression completed!\n\033[0m"
254 |
255 | if [ "$PARTITION_SCHEME" == 1 ]; then
256 | echo -e "\033[1;31m[+] Converting the super image to a RAW image...\n\033[0m"
257 | chmod +x "$WDIR/Scamsung/bin/simg2img"
258 | "$WDIR/Scamsung/bin/simg2img" super.img super.img.raw
259 | rm super.img
260 | echo -e "\033[1;32m[i] Conversion completed!\n\033[0m"
261 | echo -e "\033[1;32m[i] Your super partition size is : $(stat -c '%n %s' super.img.raw) bytes\n\033[0m"
262 | echo -e "\033[1;31m[+] Extracting system, vendor, product, odm partitions from super.img.raw...\n\033[0m"
263 | chmod +x "$WDIR/Scamsung/bin/lpunpack"
264 | "$WDIR/Scamsung/bin/lpunpack" super.img.raw && rm super.img.raw
265 | echo -e "\n\033[1;32m[i]Extraction completed!\033[0m"
266 | elif [ "$PARTITION_SCHEME" == 2 ]; then
267 | echo -e "\033[1;32m[i] Your System partition size is : $(stat -c '%n %s' system.img) bytes\n\033[0m"
268 |
269 | fi
270 | else
271 | LCMD
272 | fi
273 | }
274 |
275 | repacking(){
276 | if [ ! "$is_legacy" == 1 ]; then
277 | echo -e "\033[1;31m[+] Creating System TAR file...\n\033[0m"
278 | TAR_NAME="System - $DEVICE_NAME.tar"
279 | if [ "$PARTITION_SCHEME" == 1 ]; then
280 | tar cf "$TAR_NAME" system.img vendor.img odm.img product.img
281 | elif [ "$PARTITION_SCHEME" == 2 ]; then
282 | tar cf "$TAR_NAME" system.img vendor.img product.img
283 | fi
284 | echo -e "\nChoose a compression method\n1.ZIP\n2.TAR.XZ (Slower)"
285 | read -p "Enter value (1,2) : " compression_method
286 |
287 | compression_method_input(){
288 | if [ "$compression_method" == 2 ]; then
289 | echo -e "\n[i] Compressing objects using XZ compression.."
290 | xz -9 --threads=0 "$TAR_NAME"
291 | echo -e "\033[1;32m[i] TAR file created: ${TAR_NAME}.xz\n\033[0m"
292 | echo -e "\033[1;31m[+] Moving TAR file to Output...\n\033[0m" && mv "${TAR_NAME}.xz" "$WDIR/output"
293 | elif [ "$compression_method" == 1 ]; then
294 | echo -e "\n[i] Compressing objects using ZIP compression.."
295 | zip -r "${TAR_NAME}.zip" "$TAR_NAME"
296 | echo -e "\033[1;32m[i] ZIP file created: ${TAR_NAME}.zip\n\033[0m"
297 | echo -e "\033[1;31m[+] Moving TAR file to Output...\n\033[0m" && mv "${TAR_NAME}.zip" "$WDIR/output"
298 | else
299 | echo -e "Invalid Input. Try Again..!"
300 | compression_method_input
301 | fi
302 | }
303 | compression_method_input
304 | echo -e "\033[1;32m[i] Firmware extraction for device ${DEVICE_NAME} is completed!"
305 | else
306 | LCMD
307 | fi
308 | }
309 |
310 | cleanup(){
311 | cd "$WDIR"
312 | rm -rf Downloads Workplace super
313 | echo -e "\033[1;32m\n[i] Cleaned..!\n\033[0m"
314 | sleep 2
315 | read -p "Wanna restart the Script ? (1,2) : " confirmation
316 | if [ "$confirmation" == 1 ]; then
317 | restart
318 | else
319 | echo "Good bye..!"
320 | exit 1
321 | fi
322 | }
323 |
324 | no_super(){
325 | if [ ! "$is_legacy" == 1 ]; then
326 | echo -e "\033[1;31m[+] Making a Compressed Firmware package without Super/system...\033[0m"
327 | cd "$WDIR/Downloads"
328 | rm $IMG
329 | NON_SUPER="No ${IMG} + AP + CSC - ${DEVICE_NAME}"
330 | echo -e "\nChoose a compression method : \n1.ZIP (Faster) \n2.XZ (Slower, also lower size)"
331 | read -p "Enter value (1,2) : " super_compression
332 |
333 | input_no_super(){
334 | if [ "$super_compression" == 1 ]; then
335 | zip "${NON_SUPER}.zip" *.img
336 | mv "${NON_SUPER}.zip" "$WDIR/output"
337 | elif [ "$super_compression" == 2 ]; then
338 | tar -cvf "${NON_SUPER}.tar" *.img
339 | xz -9 --threads=0 "${NON_SUPER}.tar"
340 | mv "${NON_SUPER}.tar.xz" "$WDIR/output"
341 | else
342 | echo "Wrong input..! Try Again..."
343 | input_no_super
344 | fi
345 | }
346 | input_no_super
347 | echo -e "\033[1;32m\n[i] Task completed and saved in ${WDIR}/output..!\n[i] Restarting the Script in 5 seconds..!"
348 | sleep 5
349 | cleanup
350 | else
351 | LCMD
352 | fi
353 | }
354 |
355 |
356 | user_selection(){
357 | echo -e "\n\033[1;34m - Main menu -\033[0m"
358 | echo -e "\nWhat you want to do?\n\n1. Create a Base Zip file containing all the required files for Magisk\n2. Extracting the super.img or system.img\n3. Full firmware extraction.\n4. Extract the firmware without ${IMG} (Includes files from CSC and AP)\n5. Exit\n6. Cleanup."
359 | read -p "Choose a value (1,2,3,4,5) : " USER_INPUT
360 |
361 | if [ "$USER_INPUT" == 1 ]; then
362 | base_files
363 | user_selection
364 | elif [ "$USER_INPUT" == 2 ]; then
365 | super_extract
366 | repacking
367 | user_selection
368 | elif [ "$USER_INPUT" == 3 ]; then
369 | base_files
370 | super_extract
371 | repacking
372 | user_selection
373 | elif [ "$USER_INPUT" == 4 ]; then
374 | base_files
375 | no_super
376 | elif [ "$USER_INPUT" == 5 ]; then
377 | echo "Good bye..!"
378 | exit 1
379 | elif [ "$USER_INPUT" == 6 ]; then
380 | cleanup
381 | else
382 | echo -e "Wrong input..! Try Again"
383 | user_selection
384 | fi
385 | }
386 |
387 | restart(){
388 | banner
389 | dependencies
390 | variables
391 | directories
392 | downloading
393 | extracting
394 | is_dynamic
395 | user_selection
396 | }
397 |
398 | ### STARTING SCRIPT HERE ###
399 |
400 | banner
401 | dependencies
402 | variables
403 | directories
404 | downloading
405 | extracting
406 | is_dynamic
407 | user_selection
408 |
409 | # Copyright (c) [2023] [Ravindu Deshan]
410 |
--------------------------------------------------------------------------------