-
Notifications
You must be signed in to change notification settings - Fork 42
/
main.sh
503 lines (410 loc) · 19.6 KB
/
main.sh
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
#!/bin/bash
#Author: @github.com/raoshaab
#############Checking for pre-condition###########
#for Burpsuite
function burp(){
default_ip='127.0.0.1:8080'
check=$(curl -s http://${default_ip}/ 2>/dev/null |grep Burp -o|head -n1)
if [[ $check == Burp ]]
then
echo "+------------------------------------------+"
echo "| |"
echo "| Burpsuite Running done !! |"
echo -e "+------------------------------------------+\n\n"
else
echo -e "\033[1;91m"
echo "+----------------------------------------------- +"
echo "| Error |"
echo "| Burpsuite proxy not running at(127.0.0.1:8080) |"
echo -e "+-----------------------------------------------+\n\n"
#To enter other Ip address and port
echo "Enter the Burpsuite Ip and port i.e 192.168.1.1:9001"
exec < /dev/tty && read proxy && exec <&-
check=$(curl -s ${proxy} 2>/dev/null |grep Burp -o|head -n1)
if [[ $check == Burp ]]
then
echo "+------------------------------------------+"
echo "| |"
echo "| Burpsuite Running done !! |"
echo -e "+------------------------------------------+\n\n"
set default_ip=${proxy}
else
echo -e "\033[1;91m"
echo "+------------------------------------------------+"
echo "| Error |"
echo "| Burpsuite proxy not running at (${proxy})|"
echo -e "+---------------------------------------------+\n\n" && banner && exit
fi
fi
}
#For Internet connectivity
function net(){
ping 8.8.8.8 -c1 &>/dev/null
if [ $? == 0 ]; then
echo -e "\033[0;92m"
# echo "+------------------------------------------+"
# echo "| |"
# echo "| Internet Ready to go |"
# echo -e "+------------------------------------------+\n\n"
else
echo -e "\033[1;91m"
echo "+------------------------------------------+"
echo "| Error |"
echo "| No Internet |"
echo -e "+------------------------------------------+\n\n"&& banner && exit
fi
}
####### For adb & Root Acess
function adb_check(){
adb get-state >/dev/null 2>&1
if [ $? == 0 ];then
echo "+------------------------------------------+"
echo "| |"
echo "| adb Connected !! |"
echo -e "+------------------------------------------+\n\n"
else
echo -e "\033[1;91m"
echo "+------------------------------------------+"
echo "| adb is not running |"
echo "| oR |"
echo "| More than one emulator exits |"
echo -e "+------------------------------------------+\n\n"&& banner && exit
fi
#checking root access
adb shell -n 'su -c ""' >/dev/null 2>&1
if [ $? == 0 ]; then
echo ' '
else
echo "+------------------------------------------+"
echo "| |"
echo "| Give root Access to adb from Superuser |"
echo "| |"
echo "| If using Android Studio Emulator |"
echo "| ==> https://github.com/newbit1/rootAVD|"
echo "| For genymotion https://t.ly/n_5F |"
echo -e "+------------------------------------------+\n\n"&& banner && exit
fi
}
#====================================================================Before Starting ===================================================================
#https://github.com/whalehub/custom-certificate-authorities
#https://pswalia2u.medium.com/install-burpsuites-or-any-ca-certificate-to-system-store-in-android-10-and-11-38e508a5541a
############### Moving Certificate for android via adb -----------------------------------
function burpcer(){
cert_check=$(adb shell 'su -c "ls /system/etc/security/cacerts|grep 9a5ba575.0"')
res='y'
#checking existing Burpsuite certificate
if [[ "$cert_check" == "9a5ba575.0" ]]
then
echo -e "\033[1;91m"
echo -e "Already Burpsuite Certificate found, this will replace existing one\n"
echo -e "\033[0;92mIf you want to replace it press Y if not then N/n "
exec < /dev/tty && read res && exec <&-
fi
if [[ $res == 'N' || $res == 'n' ]]
then
echo 'No changes in Burp Certificate '
elif [[ $res == 'Y' || $res == 'y' ]] ;then
wget --quiet ${default_ip}/cert -O cacert.der
openssl x509 -inform DER -in cacert.der -out cacert.pem
name=$(echo $(openssl x509 -inform PEM -subject_hash_old -in cacert.pem | head -1).0)
mv cacert.pem $name
adb push $name /sdcard/ >/dev/null 2>&1
adb remount >/dev/null 2>&1
adb shell -n "su -c 'remount'" >/dev/null 2>&1
if [ $? == 0 ];then
echo ' '
else
adb shell -n "su -c 'mount -o r,w /'" >/dev/null 2>&1
fi
adb shell -n "su -c 'mv /sdcard/$name /system/etc/security/cacerts'" >/dev/null 2>&1
adb shell -n "su -c 'chmod 644 /system/etc/security/cacerts/$name'" >/dev/null 2>&1
echo "+------------------------------------------+"
echo "| |"
echo "| Certificate Move Successfully |"
echo -e "+------------------------------------------+\n\n"
echo "Device will reboot now :><: "
echo "adb reboot &"
fi
}
#All Apps
############### Proxy toggle-----------------------
function andro_apps(){
prox_app=$(adb shell "pm list packages -3|cut -f 2 -d ":"|grep com.kinandcarta.create.proxytoggle"|tr -d '\r')
if [[ "$prox_app" = "com.kinandcarta.create.proxytoggle" ]]
then
echo 'ProxyToggle Already installed'
else
wget --quiet https://github.com/theappbusiness/android-proxy-toggle/releases/download/v1.0.1/Proxy.Toggle.v1.0.1.zip
unzip -q Proxy.Toggle.v1.0.1.zip
adb install -t -r proxy-toggle.apk >/dev/null 2>&1
adb shell pm grant com.kinandcarta.create.proxytoggle android.permission.WRITE_SECURE_SETTINGS
echo "+------------------------------------------+"
echo "| |"
echo "| Proxy App installed |"
echo -e "+------------------------------------------+\n\n"
fi
############### ADB WIFI -------------------------
prox_app=$(adb shell "pm list packages -3|cut -f 2 -d ":"|grep com.sujanpoudel.adbwifi"|tr -d '\r')
if [[ "$prox_app" == "com.sujanpoudel.adbwifi" ]]
then
echo 'ADB Wifi Already installed'
else
wget -q https://github.com/raoshaab/Andro_set/raw/main/assets/adb_wifi.apk -O wifiadb.apk
adb install -t -r wifiadb.apk
echo "+------------------------------------------+"
echo "| |"
echo "| ADB Wifi App installed |"
echo -e "+------------------------------------------+\n\n"
fi
##############Proxy Droid -----------------------
prox_app=$(adb shell "pm list packages -3|cut -f 2 -d ":"|grep org.proxydroid"|tr -d '\r')
if [[ "$prox_app" == "org.proxydroid" ]]
then
echo 'ProxyDroid Already installed'
else
wget -q https://github.com/raoshaab/Andro_set/raw/main/assets/org.proxydroid.apk -O proxydroid.apk
adb install -t -r proxydroid.apk
echo "+------------------------------------------+"
echo "| |"
echo "| ProxyDroid App installed |"
echo -e "+------------------------------------------+\n\n"
fi
}
#Pc tools
function pc_tools(){
################ JADX - Dex to Java decompiler, apktool
################ Android Screen Share
(jadx --version | scrcpy -v && apktool -version) &>/dev/null
if [[ $? != 0 ]]
then
echo 'Installing Pc Tools '
apt-get -qq install jadx scrcpy apktool -y &>/dev/null
echo "+------------------------------------------+"
echo "| |"
echo "| JADX~Apktool~Scrcpy installed |"
echo -e "+------------------------------------------+\n\n"
else
echo "+------------------------------------------+"
echo "| |"
echo "| JADX~Apktool~Scrcpy already installed |"
echo -e "+------------------------------------------+\n\n"
fi
(frida --version && objection version )>&/dev/null
if [ $? == 0 ];then
echo "+------------------------------------------+"
echo "| |"
echo "| Frida Objection already installed |"
echo -e "+------------------------------------------+\n\n"
else
pip3 install frida frida-tools objection &>/dev/null
echo "+------------------------------------------+"
echo "| |"
echo "| Frida Setup Ready |"
echo -e "+------------------------------------------+\n\n"
fi
}
#android
# not able match android_cpu with frida, use ~= ,using regex to match
#if magisk is available then frida_magisk module will install
function magisk_module(){
#frida
magisk_version=$(curl -IkLs -o /dev/null -w %{url_effective} https://github.com/ViRb3/magisk-frida/releases/latest|grep -o "[^/]*$"| sed "s/v//g")
baseurl="https://github.com/ViRb3/magisk-frida/releases/download/$magisk_version/MagiskFrida-$magisk_version.zip"
echo ' Downloading Module .....'
wget --quiet $baseurl -O frida_module.zip
adb push frida_module.zip /data/local/tmp/ >/dev/null 2>&1
echo ' Flashing MagsikFrida .......'
echo -e '\n\n ********************************************
* MagiskFrida *
********************************************'
adb shell -n "su -c 'magisk --install-module /data/local/tmp/frida_module.zip' " >/dev/null 2>&1
#trust
wget -q https://github.com/NVISOsecurity/MagiskTrustUserCerts/releases/download/v0.4.1/AlwaysTrustUserCerts.zip -O trust_module.zip
adb push trust_module.zip /data/local/tmp >/dev/null 2>&1
adb shell -n "su -c 'magisk --install-module /data/local/tmp/trust_module.zip'" >/dev/null 2>&1
echo "Frida Module installed on Device"
}
function frida_manual(){
android_cpu=$(adb shell getprop | egrep "ro.product.cpu.abi]"|awk '{print $2}'|sed 's/\[//g'|sed 's/\]//g')
frida_version=$(curl -IkLs -o /dev/null -w %{url_effective} https://github.com/frida/frida/releases/latest|grep -o "[^/]*$"| sed "s/v//g")
##choose frida server matches android cpu---------------------------
baseurl="https://github.com/frida/frida/releases/download/$frida_version/frida-server-$frida_version-android-"
if [[ $android_cpu =~ ^x86 ]]; then
server_download="x86"
elif [[ $android_cpu =~ ^arm64 ]]; then
server_download="arm64"
elif [[ $android_cpu =~ ^x86_64 ]]; then
server_download="x86_64"
elif [[ $android_cpu =~ ^arm ]]; then
server_download="arm"
else
echo something is wrong
fi
## Download frida-server and copy to android /data/local/tmp/
echo 'Downloading Frida server'
wget -q $baseurl$server_download.xz -O frida-server.xz
unxz frida-server.xz >/dev/null 2>&1
adb push frida-server /data/local/tmp/ >/dev/null 2>&1
adb shell -n "su -c 'chmod 777 /data/local/tmp/frida-server'" >/dev/null 2>&1
adb remount >/dev/null 2>&1
adb shell -n "su -c 'remount'" >/dev/null 2>&1
if [ $? == 0 ];then
echo ' '
else
adb shell -n "su -c 'mount -o r,w /'" >/dev/null 2>&1
fi
adb shell -n "su -c 'mv /data/local/tmp/frida-server /system/xbin/frida-server'"
echo 'Frida Server copied to Android system'
echo "+------------------------------------------+"
echo "| |"
echo "| Setup Ready with Android frida |"
echo -e "+------------------------------------------+\n\n\n"
echo "To Check version of frida server ,run command "
echo -e "adb shell -n \"su -c 'frida-server --version'\"\n\n\n"
echo "To run the frida-sever run below command "
echo -e "adb shell -n \"su -c 'frida-server '\"\n\n\n"
}
function frida_ando(){
#Checking for frida-server in android
frida_android=$(adb shell "frida-server --version" 2>/dev/null )
check=$(echo $frida_android |grep -o '\.'|head -n1)
if [[ $check = '.' ]]
then
echo -e "\033[1;91mFrida-server already Installed with version ${frida_android} \n\n \033[0;92mIf you want to upgrade or reinstall Press Y/y "
exec < /dev/tty && read res && exec <&-
if [[ $res == 'Y' || $res == 'y' ]]
then
magisk_version=$(adb shell "magisk -v|cut -d ':' -f2" 2>/dev/null)
if [[ $magisk_version == "MAGISK" ]]
then
#magisk will flash frida server module which autostart on reboot
magisk_module
else
frida_manual
fi
else
echo 'Frida-server already Installed'
fi
elif [[ $check = '' ]]
then
magisk_version=$(adb shell "magisk -v|cut -d ':' -f2" 2>/dev/null)
if [[ $magisk_version == "MAGISK" ]]
then
#magisk will flash frida server module which autostart on reboot
magisk_module
else
#downloading frida-server from source
frida_manual
fi
else
echo function not working
fi
}
## To install magisk in Genymotion
#will add this in future
function install_magisk(){
# if device ==genymotion
# then
adb push magisk.zip /sdcard/
adb shell "/system/bin/flash-archive.sh /sdcard/magisk.zip"
}
#frida version mismatch
function frida_mismatch(){
lat_frida_version=$(curl -IkLs -o /dev/null -w %{url_effective} https://github.com/frida/frida/releases/latest|grep -o "[^/]*$"| sed "s/v//g")
pc_version=$(frida --version 2>/dev/null )
android_version=$(adb shell -n 'sh -c "/data/local/tmp/frida-server --version"' 2>/dev/null)
echo -e " Latest Version => ${lat_frida_version} \n Pc version => ${pc_version} \n Android Version => ${android_version}"
if [[ ${pc_version} != ${android_version} ]]
then
if [[ ${lat_frida_version} != ${pc_version} ]]
then
echo -e "\n\tPc Version is outdated\n"
echo "Downloading latest version ......."
pip3 install frida --upgrade &>/dev/null
echo -e "\n\nLatest version installed "
elif [[ ${lat_frida_version} != ${android_version} ]]
then
frida_android
fi
elif [[ ${android_version} == ${pc_version} ]]
then
echo -e "\n\n Same Version in Android (${android_version}) and Pc (${pc_version})"
fi
}
function all(){
burp
net
adb_check
pc_tools
andro_apps
frida_ando
burpcer
echo "Reboot Android device to reflect changes"
#adb reboot
}
function apk_pull(){
version=$(curl -IkLs -o /dev/null -w %{url_effective} https://github.com/REAndroid/APKEditor/releases/latest|grep -o "[^/]*$"| sed "s/V//g")
base_url="https://github.com/REAndroid/APKEditor/releases/download/V${version}/APKEditor-${version}.jar"
wget --quiet $base_url -O apk-editor.jar
ap k_pull=$(java -jar apk-editor.jar -i )
}
################ All neccesary functions must defined above ###################
function banner(){
#Color change everytime
echo -e "\e[3$(( $RANDOM * 6 / 32767 + 1 ))m"
bann0='
mmmmm mm # mmmm
# "# mmm m mm ## m mm mmm# m mm m" "m
#mmm#" #" # #" # # # #" # #" "# #" " # m #
# #"""" # # """ #mm# # # # # # # #
# "#mm" # # # # # # "#m## # #mm#
#Author: github.com/@raoshaab'
bann1='
_____ _ _
| __ \ /\ | | / _ \
| |__) |___ _ __ ______ / \ _ __ __| |_ __| | | |
| ___// _ \ _ \______/ /\ \ | _ \ / _ | __| | | |
| | | __/ | | | / ____ \| | | | (_| | | | |_| |
|_| \___|_| |_| /_/ \_\_| |_|\__,_|_| \___/
'
while IFS= read -r -n 1 -d '' c; do printf '\e[38;5;%dm%s\e[0m' "$((RANDOM%255+1))" "$c"; done <<<$bann0
}
function start(){
#cooking script directory,
banner
base_dir='/tmp/android_pentest_ready'
cd /tmp/
rm -rf android_pentest_ready >/dev/null 2>&1
mkdir android_pentest_ready >/dev/null 2>&1 && cd android_pentest_ready
echo -e "\033[0;37m"
echo -e "\n1. All"
echo "2. Move Burpsuite Certificate to Android root folder"
echo "3. Pc Tools (JADX, frida, objection, Android Screen Control & Mirror "
echo "4. Android Frida Server"
echo "5. Fix Frida Server Version mismatch"
echo "6. Android Apps(proxytoogle, proxydroid, ADBwifi)"
echo "0. Exit "
echo -e "\e[3$(( $RANDOM * 6 / 32767 + 1 ))m"
echo -e "I want to install :-"
# Allows us to read user input below, assigns stdin to keyboard and then again to script
exec < /dev/tty && read option && exec <&- && clear
#Acting on the user input
case $option in
1) all
;;
2) net; adb_check;burp;burpcer
;;
3) net; pc_tools;
;;
4) net; adb_check ;frida_ando
;;
5) net; adb_check;frida_mismatch;
;;
6) net; adb_check; andro_apps
;;
0) banner;exit
;;
esac
start
}
start