-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathXtrakt
executable file
·546 lines (521 loc) · 13.9 KB
/
Xtrakt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#!/bin/bash
printf '\e[8;33;80t]'
#
# Custom build script
# Copyright © 2017, Nana Iyke Quame "iyke"
#
#Android_Matrix_Development
#DroidPeepz™ Inc
#
# NOTE : This Is Meant For The Good & Ease Of Kernel Development,
# - Please You Are Free To Edit And Make It Better, But DO NOT STEAL !
# -
#
#--------------------------
# Updated On : 2017/09/23
# by : @artificerpi
# reason : Change to use `relative path`
# commit : https://github.com/iykequame/android_system_extraction_and_repack_tool/pull/3/commits/4c8691b17c407a6d5eae9d408ba69c473e0f06c6
# commit-ID : 4c8691b17c407a6d5eae9d408ba69c473e0f06c6
#--------------------------
user=$(echo "$(whoami | gawk '{ print $1 }')")
PROJECT_DIR=`realpath "$0" | sed 's|\(.*\)/.*|\1|'`
flicx="$PROJECT_DIR/.flicx/flicx.sh";
permsda=chmod 755 $PROJECT_DIR/tools/sdat2img.py
permimg=chmod 755 $PROJECT_DIR/tools/img2simg.py
permext=chmod 755 $PROJECT_DIR/tools/make_ext4fs
permext=chmod 755 $PROJECT_DIR/tools/img2simg.py
#-------------------
#START - HOME
START(){
clear
echo -e " \033[0;34m "
cecho P"" " \e[4m*||_http://www.droidpeepz.xyz_||*"
echo
cecho P "" " \e[7m================================="
cecho C "" " \e[7m===!! Android System Extraction/Repack Tool. !!==="
cecho G "" " \e[7mFor"
cecho C "" " \e[7m*..MediaTek & Qualcomm Devices..*"
echo
echo " ========*****************========"
cecho G "" " ---> DroidPeepz™ Inc "
cecho P "" " ---> by : Nana Iyke Quame "
echo " ========*****************========"
echo " Credit Goes To:"
cecho Y "" " **ANDROID MATRIX DEVELOPMENT**"
cecho P "" " & @xpirt, @Mesaj, @matrix, @artificerpi "
echo
echo
CT="$(date +"%r")"
DT="$(date +"%b-%d-%Y")"
cecho B "" " \e[7m\e[3mMenu" " \033[0;36m\e[3m|| Time : $CT"
cecho C "" " \e[3mHost System : $HOSTNAME" " \033[0;36m\e[3m|| Date : $DT"
echo
cecho Y " \033[0mf - " "Convert file_contexts "
echo
cecho C " i - " "Unpack "system.new.dat" "
cecho R "" " NOTE : This process will request for your "sudo" password! "
echo
cecho G " y - " "Repack To "system.new.dat" "
echo
cecho C " v - " "View Credits + info"
echo
cecho R " x - " "Exit"
echo
}
#MENU
EXT_MAIN(){
while :
do
clear
START
read -p " Enter option: " CHOICE
case "$CHOICE" in
Y|y ) RePck;;
F|f ) FILCX;;
I|i ) UnPck;;
V|v) V_CREDIT;;
X|x) EXIT;;
*) cecho R "" " Invalid option"; sleep 0.3; continue;;
esac
done
}
PAGE(){
clear
echo -e " \033[0;34m "
cecho P"" " \e[4m*||_http://www.droidpeepz.xyz_||*"
echo
echo
cecho P "" " \e[7m================================="
cecho C "" " \e[7m===!! Android System Extraction/Repack Tool. !!==="
cecho G "" " \e[7mFor"
cecho C "" " \e[7m*..MediaTek & Qualcomm Devices..*"
echo
echo
echo
}
TIME(){
CT="$(date +"%r")"
DT="$(date +"%b-%d-%Y")"
cecho B "" " \e[7m\e[3mMenu" " \033[0;36m\e[3m|| Time : $CT"
cecho C "" " \e[3mHost System : $HOSTNAME" " \033[0;36m\e[3m|| Date : $DT"
}
# File_context_zone
COTEXTDIR=./file_context_zone
CONFOLDER=./file_context_zone/convert
REVFOLDER=./file_context_zone/revert
BINNAME=file_contexts.bin
NEWBINFILE=new-$(date +%Y%m%d)-$BINNAME
#ST_DEB
FILCX(){
clear
PAGE
echo
cecho P "" " \e[7m*||_File_contexts.bin Convert Zone_||*"
echo
echo " ========*****************========"
echo " Credit Goes To:"
cecho C "" " [email protected] - source script "
cecho B "" " Pom Kritsada @MTK THAI Developers "
echo " ========*****************========"
echo
TIME
echo
cecho Y " \033[0mv - " "View Credits & info"
echo
cecho C " c - " "Convert"
echo
cecho G " r - " "Revert "
echo
cecho R " h - " "go to home"
echo
echo
read -p " Enter option: " x
case "$x" in
V|v) V_CREDIT;;
C|c) CONVERT_FILCX;;
R|r) REVERT_FILCX;;
H|h ) START;;
*) cecho R "" " Invalid option"; sleep 0.3; continue;;
esac
FILCX
}
CONVERT_FILCX(){
clear
PAGE
echo -e " \033[0;34m "
echo " Please wait"
mkdir -p $CONFOLDER
sleep 1.0;
if [ -f $CONFOLDER/file_contexts* ]
then
echo -e " \033[0;31m "
echo " File." "file_context already exist in folder; "
echo " continuing will be overwrite it !!! "
echo
read -p " to continue, press Enter ... "
fi
./tools/lib64/sefcontext -o $CONFOLDER/file_contexts $COTEXTDIR/$BINNAME > /dev/null
if [ $? == 0 ]
then
echo -e " \033[0;34m "
echo " !! DONE !!"
read -p "Press enter key to continue . . ."
echo
else
echo " !! Faild !!"
read -p "Press enter key to continue . . ."
fi
}
REVERT_FILCX() {
clear
PAGE
echo -e " \033[0;34m "
echo " Please wait"
mkdir -p $REVFOLDER
sleep 1.0;
if [ -f $REVFOLDER/file_contexts.bin* ]
then
echo -e " \033[0;31m "
echo " File." "file_context.bin already exist in folder; "
echo " continuing will be overwrite it !!! "
echo
read -p " to continue, press Enter ... "
fi
./tools/lib64/sefcontext_compile -o $REVFOLDER/$NEWBINFILE $CONFOLDER/file_contexts > /dev/null
if [ $? == 0 ]
then
echo -e " \033[0;34m "
echo " !! DONE !!"
read -p "Press enter key to continue . . ."
echo
else
echo " !! Faild !!"
read -p "Press enter key to continue . . ."
fi
}
#--------------------------
#converting to system image
#--------------------------
UnPck(){
sudo mkdir $PROJECT_DIR/convert-dat/out
printf '\e[8;33;80t]'
$permsda
clear
PAGE
echo " -----> Unpacking Image."
echo
if [ -f $PROJECT_DIR/convert-dat/system.transfer.list ]
then
echo
echo " system.transfer.list [FOUND]"
fi
if [ -f $PROJECT_DIR/convert-dat/system.new.dat ]
then
echo
echo " system.new.dat [FOUND]"
echo
sleep 0.6;
PAGE
echo " Few seconds to go... :)"
( tools/./sdat2img.py convert-dat/system.transfer.list convert-dat/system.new.dat convert-dat/system.img ) >> Unpack.log
mkdir -p /$hm/$user/$dsk/$tul/convert-dat/out
mkdir -p /$hm/$user/$dsk/$tul/convert-dat/tmpsparse
mkdir -p /$hm/$user/$dsk/$tul/convert-dat/rom_system
mkdir -p Finish-new.dat
echo
echo " -----> mounting system image..."
echo " Please Wait..."
echo
echo -e " \033[0;31m "
sudo mount -t ext4 -o loop convert-dat/system.img convert-dat/out/
echo
echo -e " \033[0;36m "
echo " -----> setting permission for modifications..."
echo " Please Wait..."
sudo chown -R $user:$user $PROJECT_DIR/convert-dat/out
( sudo cp -avr $PROJECT_DIR/convert-dat/out $PROJECT_DIR/convert-dat/rom_system ) >> x-log
sudo umount $PROJECT_DIR/convert-dat/out/
rm -rf $PROJECT_DIR/convert-dat/out
rm convert-dat/system.new.dat
rm convert-dat/system.transfer.list
echo
echo -e " \033[0;36m "
echo " -----> Please go to convert-dat/rom_system to edit your Rom "
echo
echo -e " \033[0;34m "
echo "============================="
echo " !! PROCESS TIME !! "
echo $[$SECONDS / 60]' minutes '$[$SECONDS % 60]' seconds'
echo "============================="
echo
echo
echo " !! DONE !!"
echo
echo
else
PAGE
echo -e " \033[0;31m "
echo "WARNING! WARNING!! WARNING!!!"
echo "Please Check & Trace Where Errors."
echo " There Is NO rom_system found"
echo
cecho R "" "system.new.dat -->> Missing !"
echo
cecho R "" "system.transfer.list -->> Missing !"
echo
echo
fi
read -p "Press enter key to continue . . ."
START " "
}
RePck(){
printf '\e[8;33;80t]'
PAGE
echo
#--------------------------
echo " -----> Repacking Image."
echo
echo " Few seconds to go... :)"
if [ -f $PROJECT_DIR/convert-dat/rom_system/build.prop ]
then
api=$(grep "ro.build.version.sdk" convert-dat/rom_system/build.prop | cut -d"=" -f2);
echo -e " \033[0;34m "
echo " Android SDK = $api "
echo
fi
if [ -f $PROJECT_DIR/convert-dat/file_contexts ]
then
echo " file_contexts [FOUND]"
echo
echo -e " \033[0;36m "
tools/./make_ext4fs -s -T -1 -S convert-dat/file_contexts -L system -l 2692743168 -a system convert-dat/system_new.img convert-dat/rom_system/
echo
clear
PAGE
echo " -----> Converting To Sparse Image."
if [[ $api = "21" ]];
then
argv="1"
elif [[ $api = "22" ]];
then
argv="2"
elif [[ $api = "23" ]];
then
argv="3"
elif [[ $api = "24" ]];
then
argv="4"
elif [[ $api = "25" ]];
then
argv="4"
fi
echo " Please Wait..."
./tools/img2sdat.py convert-dat/system_new.img Finish-new.dat $argv;
echo
echo " Few seconds to go... :)"
echo
echo " Thank You !!! :0"
rm $PROJECT_DIR/convert-dat/tmpsparse/system.*
rm $PROJECT_DIR/convert-dat/system.img
rm $PROJECT_DIR/convert-dat/system_new.img
echo
echo
if [ -f $PROJECT_DIR/Finish-new.dat/system.new.dat ]
then
PAGE
echo -e " \033[0;36m "
echo " PLEASE CHECK Finish-new.dat -Folder to see the following new files"
echo
echo " ************************************"
echo
ls Finish-new.dat
echo ""
echo -e " \033[0;34m "
echo "============================="
echo " !! PROCESS TIME !! "
echo $[$SECONDS / 60]' minutes '$[$SECONDS % 60]' seconds'
echo "============================="
echo
echo
echo " !! DONE !!"
echo
echo
echo
fi
else
PAGE
echo -e " \033[0;31m "
echo "WARNING! WARNING!! WARNING!!!"
echo "Please Check & Trace Where Errors."
echo " There Is NO rom_system found"
echo
cecho R "" "file_contexts -->> Missing !"
echo
cecho R "" "Android SDK -->> not detected !"
echo
read -p "Press enter key to continue . . ."
echo
PAGE
echo "WARNING! WARNING!! WARNING!!!"
echo "Please Check & Trace Where Errors."
echo
echo
cecho R "" "Repack ERRORS!"
echo
cecho R "" "Repack ERRORS!"
echo
cecho R "" "Repack ERRORS!"
echo
echo
fi
read -p "Press enter key to continue . . ."
START " "
}
#--------------------------
###-----------------------------------------
# ./sdat2img.py system.transfer.list system.new.dat system.img
# sudo mount -t ext4 -o loop system.img system/
# sudo chown -R iyke:iyke /home/iyke/Desktop/xe/tools/system
# ./make_ext4fs -T 0 -S file_contexts -l 1073741824 -a system system_new.img system/
#credit & info
V_CREDIT(){
clear
echo
PAGE
echo -e " \033[0;34m "
cecho P " "" \e[4m\e[7m@Xpirt [XDA]"
echo " for : sdat2img 1.0 - img2sdat 1.2"
echo " check thread link below >>"
cecho P"" " \033[0;33m\e[3m\e[4m*https://forum.xda-developers.com/android/software-hacking/how-to-conver-lollipop-dat-files-to-t2978952"
echo
echo
echo
cecho P " " "\e[3m "
read -p " Press enter key for next . . ."
clear
echo
PAGE
echo -e " \033[0;34m "
cecho P " "" \e[4m\e[7m@SuperR. [XDA]"
echo " for : Some binaries"
echo " check profile link below >>"
cecho P"" " \033[0;33m\e[3m\e[4m*https://forum.xda-developers.com/member.php?u=5787964"
echo
echo
echo
cecho P " " "\e[3m "
read -p " Press enter key for next . . ."
clear
echo
PAGE
echo -e " \033[0;34m "
cecho P " "" \e[4m\e[7m@Pom Kritsada [MTK THAI Developers]"
echo " for : file_context.bin conversion"
echo " check video link below >>"
cecho P"" " \033[0;33m\e[3m\e[4m*https://www.youtube.com/watch?v=Tw5f4iLUYhc"
echo
echo
echo
cecho P " " "\e[3m "
read -p " Press enter key to continue . . ."
clear
echo
PAGE
echo -e " \033[0;34m "
cecho P " "" \e[4m\e[7m#AMD [FACEBOOK]"
echo " Android Matrix Development"
echo " check group link below >>"
cecho P"" " \033[0;33m\e[3m\e[4m*https://web.facebook.com/groups/1024872487548231/"
echo
echo
echo
cecho P " " "\e[3m "
read -p " Press enter key for next . . ."
clear
echo
PAGE
echo -e " \033[0;34m "
cecho P " "" \e[4m\e[7mNana Yaa [Jennie]"
echo " for her time & motivation"
echo
echo
echo
cecho P " " "\e[3m "
read -p " Press enter key for next . . ."
echo
clear
echo
PAGE
echo -e " \033[0;33m "
echo -e " \e[3m[ THANKS FOR VIEWING ]"
echo -e " \e[3m[ OUR CREDIT !!! ]"
echo
sleep 2.0;
START
}
#WAIT
RELAX(){
PAGE
echo ""
echo -e " \033[0;34m "
echo "============================="
echo " !! PROCESS TIME !! "
echo $[$SECONDS / 60]' minutes '$[$SECONDS % 60]' seconds'
echo "============================="
echo
echo
echo " !! DONE !!"
echo
echo
read -p "Press enter key to continue . . ."
echo
HOME " "
}
#EXIT
EXIT(){
printf '\e[8;33;80t]'
clear
cecho C "" "Talent Is Nothing WIthout Ethics!!!"
sleep 1.0;
clear
exit
}
#COLOR
#Credit goes to @Matrix for his color codes
#USAGE: cecho TYPE=R|G|Y|B|P|C|W "msg1" "color_msg2" "msg3"
cecho ()
{
#Case didn't work out for me in cygwin
if [ "$1" == "R" ]
then
echo -e "$2""\033[0;91m$3\033[0m""$4" # Red
elif [ "$1" == "G" ]
then
echo -e "$2""\033[0;92m$3\033[0m""$4" # Green
elif [ "$1" == "Y" ]
then
echo -e "$2""\033[0;93m$3\033[0m""$4" # Yellow
elif [ "$1" == "B" ]
then
echo -e "$2""\033[0;94m$3\033[0m""$4" # Blue
elif [ "$1" == "P" ]
then
echo -e "$2""\033[0;95m$3\033[0m""$4" # Purple
elif [ "$1" == "C" ]
then
echo -e "$2""\033[0;96m$3\033[0m""$4" # Cyan
elif [ "$1" == "W" ]
then
echo -e "$2""\033[0;97m$3\033[0m""$4" # White
fi
}
#EXTRA_COLOR_OPTIONS
blue='\033[0;34m'
cyan='\033[0;36m'
yellow='\033[0;33m'
red='\033[0;31m'
nocol='\033[0m'
#DEPLOYING function
EXT_MAIN