-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.sh
More file actions
executable file
·280 lines (242 loc) · 9.45 KB
/
Copy pathverify.sh
File metadata and controls
executable file
·280 lines (242 loc) · 9.45 KB
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
#!/bin/bash
set -euo pipefail
VERIFY_ROOT="$(cd "$(dirname "$0")" && pwd)"
source "$VERIFY_ROOT/lib.sh"
PASS=0
FAIL=0
WARN=0
check_pass() { echo " [PASS] $*"; PASS=$((PASS + 1)); }
check_fail() { echo " [FAIL] $*"; FAIL=$((FAIL + 1)); }
check_warn() { echo " [WARN] $*"; WARN=$((WARN + 1)); }
check_command() {
local name="$1"
if command -v "$name" >/dev/null 2>&1; then
check_pass "$name found: $(command -v "$name")"
else
check_fail "$name not found in PATH"
fi
}
check_command_warn() {
local name="$1"
local hint="${2:-}"
if command -v "$name" >/dev/null 2>&1; then
check_pass "$name found: $(command -v "$name")"
else
check_warn "$name not found${hint:+ — $hint}"
fi
}
check_file() {
local path="$1"
local desc="${2:-$path}"
if [[ -f "$path" ]]; then
check_pass "$desc exists"
else
check_fail "$desc missing: $path"
fi
}
check_dir() {
local path="$1"
local desc="${2:-$path}"
if [[ -d "$path" ]]; then
check_pass "$desc exists"
else
check_fail "$desc missing: $path"
fi
}
# ─── Static Checks ───────────────────────────────────────────────────────────
run_static_checks() {
local android_home
android_home=$(get_android_home)
local rc_file
rc_file=$(detect_shell_rc)
echo ""
echo "=== Environment ==="
if [[ -n "${ANDROID_HOME:-}" && -d "$ANDROID_HOME" ]]; then
check_pass "ANDROID_HOME set and directory exists: $ANDROID_HOME"
elif [[ -d "$HOME/android_sdk" ]]; then
check_warn "ANDROID_HOME not set — export it or run: source $rc_file (using $HOME/android_sdk for checks)"
else
check_fail "ANDROID_HOME not set and $HOME/android_sdk missing"
fi
check_dir "$android_home" "Android SDK directory ($android_home)"
echo ""
echo "=== Host prerequisites (setup.sh) ==="
check_command "git"
check_command "pipx"
check_command "openssl"
if command -v jadx >/dev/null 2>&1; then
check_pass "jadx found: $(command -v jadx)"
else
check_warn "jadx not in PATH (optional; install distro package for decompilation)"
fi
echo ""
echo "=== SDK Tools ==="
check_command "adb"
if command -v emulator >/dev/null 2>&1; then
check_pass "emulator found: $(command -v emulator)"
else
check_warn "emulator not in PATH — install with: sdkmanager --install \"emulator\" (then ensure PATH includes \$ANDROID_HOME/emulator)"
fi
check_command "sdkmanager"
check_command "avdmanager"
echo ""
echo "=== Pentesting tools (pipx) ==="
check_command "frida"
check_command "objection"
check_command "apkleaks"
if command -v pyapktool >/dev/null 2>&1; then
check_pass "pyapktool found: $(command -v pyapktool)"
elif command -v apktool >/dev/null 2>&1; then
check_pass "apktool found (standalone): $(command -v apktool)"
else
check_warn "neither pyapktool nor apktool in PATH — setup.sh installs pyapktool via pipx"
fi
echo ""
echo "=== Project files (repo directory) ==="
if [[ -f "$VERIFY_ROOT/burp.der" ]]; then
check_pass "burp.der present next to scripts ($VERIFY_ROOT/burp.der)"
else
check_warn "burp.der not found at $VERIFY_ROOT/burp.der (required before setup.sh for A10)"
fi
echo ""
echo "=== AVDs ==="
if command -v avdmanager >/dev/null 2>&1; then
local avd_list
avd_list=$(avdmanager list avd 2>/dev/null || true)
if echo "$avd_list" | grep -q "A10"; then
check_pass "AVD 'A10' exists"
else
check_fail "AVD 'A10' not found"
fi
if echo "$avd_list" | grep -q "A14PR"; then
check_pass "AVD 'A14PR' exists"
else
check_fail "AVD 'A14PR' not found"
fi
else
check_fail "avdmanager not available — cannot check AVDs"
fi
echo ""
echo "=== System images ==="
check_dir "$android_home/system-images/android-29" "Android 10 system image"
check_dir "$android_home/system-images/android-34" "Android 14 system image"
echo ""
echo "=== rootAVD + Magisk ==="
check_dir "$android_home/rootAVD" "rootAVD directory"
check_file "$android_home/rootAVD/Magisk.zip" "Magisk.zip (for A14PR / rootAVD)"
echo ""
echo "=== Shell configuration ==="
if [[ -f "$rc_file" ]] && grep -q 'ANDROID_HOME' "$rc_file" 2>/dev/null; then
check_pass "ANDROID_HOME configured in $rc_file"
else
check_fail "ANDROID_HOME not found in $rc_file"
fi
if [[ -f "$rc_file" ]] && grep -q 'alias A10=' "$rc_file" 2>/dev/null; then
check_pass "A10 alias configured in $rc_file"
else
check_fail "A10 alias not found in $rc_file"
fi
if [[ -f "$rc_file" ]] && grep -q 'alias A14PR=' "$rc_file" 2>/dev/null; then
check_pass "A14PR alias configured in $rc_file"
else
check_warn "A14PR alias not found in $rc_file"
fi
}
# ─── Live Checks (requires running emulator) ─────────────────────────────────
run_live_checks() {
local avd_name="$1"
echo ""
echo "=== Live check: $avd_name ==="
if ! adb devices 2>/dev/null | grep -q "emulator"; then
log_info "Starting $avd_name for live checks..."
local extra_flags=()
[[ "$avd_name" == "A10" ]] && extra_flags=("-writable-system")
start_emulator "$avd_name" "${extra_flags[@]}" || {
check_fail "$avd_name failed to start"
return
}
fi
local boot_status
boot_status=$(adb shell getprop sys.boot_completed 2>/dev/null | tr -d '\r\n' || true)
if [[ "$boot_status" == "1" ]]; then
check_pass "$avd_name is fully booted"
else
check_fail "$avd_name is not fully booted"
return
fi
# Prefer adb root + shell id (matches A10 adb root; A14PR may use su)
adb root 2>/dev/null || true
sleep 2
local shell_id
shell_id=$(adb shell id 2>/dev/null | tr -d '\r\n' || true)
if [[ "$shell_id" == *"uid=0"* ]]; then
check_pass "$avd_name adb shell as root (uid=0)"
else
local su_id
su_id=$(adb shell "su -c id" 2>/dev/null | tr -d '\r\n' || true)
if [[ "$su_id" == *"uid=0"* ]]; then
check_pass "$avd_name root via su"
else
check_warn "$avd_name root not confirmed (shell id: '${shell_id:-empty}', su: '${su_id:-empty}')"
fi
fi
if adb shell "test -f /data/local/tmp/frida-server" 2>/dev/null; then
check_pass "$avd_name frida-server at /data/local/tmp/"
else
check_warn "$avd_name frida-server not on device (not installed by setup; optional)"
fi
local proxy
proxy=$(adb shell settings get global http_proxy 2>/dev/null | tr -d '\r\n' || true)
if [[ "$avd_name" == "A10" ]]; then
if [[ -n "$proxy" && "$proxy" != "null" && "$proxy" != ":0" ]]; then
check_pass "$avd_name HTTP proxy set: $proxy"
else
check_warn "$avd_name HTTP proxy not set (setup configures 10.0.2.2 for Burp)"
fi
else
check_pass "$avd_name proxy check skipped (A14PR: Burp/proxy not applied by this setup)"
fi
if [[ "$avd_name" == "A10" ]]; then
local cert_count
cert_count=$(adb shell "ls /system/etc/security/cacerts/ 2>/dev/null | wc -l" | tr -d '\r\n ')
if [[ "$cert_count" =~ ^[0-9]+$ ]] && (( cert_count > 50 )); then
check_pass "$avd_name system CA store populated ($cert_count entries)"
else
check_warn "$avd_name system CA store looks unusual ($cert_count entries)"
fi
fi
if [[ "$avd_name" == "A14PR" ]]; then
if adb shell "command -v magisk" 2>/dev/null | grep -q "magisk"; then
check_pass "$avd_name Magisk on device"
else
check_warn "$avd_name Magisk binary not found in PATH (may still be installed)"
fi
fi
kill_emulator
sleep 3
}
# ─── Main ─────────────────────────────────────────────────────────────────────
echo "╔══════════════════════════════════════════════╗"
echo "║ Android-PT-Setup verification ║"
echo "╚══════════════════════════════════════════════╝"
run_static_checks
if [[ "${1:-}" == "--live" ]]; then
echo ""
echo "=== Live checks ==="
echo "(Starts emulators temporarily; ensure KVM / emulator works.)"
echo ""
run_live_checks "A10"
adb kill-server 2>/dev/null || true
sleep 3
run_live_checks "A14PR"
fi
echo ""
echo "════════════════════════════════════════════════"
echo " Results: $PASS passed, $FAIL failed, $WARN warnings"
echo "════════════════════════════════════════════════"
if (( FAIL > 0 )); then
echo " Some checks failed. Fix the items above or run setup.sh."
exit 1
fi
echo " All required checks passed (warnings are informational)."
exit 0