forked from OMGnotThatGuy/ios_internal_urls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecode_plists_poc.sh
executable file
·90 lines (69 loc) · 2.12 KB
/
decode_plists_poc.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
#!/usr/bin/env bash
set -o errexit
BASE_DIR='/Library/Developer/CoreSimulator/Volumes/iOS_21F79/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.5.simruntime/Contents/Resources'
ROOT_DIR="${BASE_DIR}/RuntimeRoot"
function warn() {
echo "$1" 1>&2
}
function err() {
echo "$*" 1>&2
exit 99
}
function check_effective_uid() {
# Some files require root to read
if [ "$EUID" -ne 0 ]; then
warn "Not running as root! Re-running with sudo."
sudo "$0"
exit
fi
}
function check_ios_root() {
if [ ! -d "$ROOT_DIR" ]; then
warn "Directory not found: $ROOT_DIR"
err '--->Can''t find working dir. Is Xcode installed?<---'
fi
}
function print_ios_version() {
local sim_plist="${BASE_DIR}/profile.plist"
local ios_version
if [ -f "$sim_plist" ]; then
ios_version="$(plutil -p "$sim_plist" | grep defaultVersionString | awk '{print $NF}' | tr -d '"')"
if [ -n "$ios_version" ]; then
printf "$ios_version"
return 0
fi
fi
printf "UNKNOWN_FIX_ME"
}
function print_header() {
echo "file_count|filename|key|url"
}
function print_footer() {
printf '"# %s\t\tiOS %s\t\tExtracted:%s"\n' "OMGnotThatGuy" "$(print_ios_version)" "$(date '+%Y-%m-%d')"
}
function process_plist() {
# Some URLs look like they have spaces in them. Weird. Clean them up. Test later...
# SettingsSearchManifest-HomeScreeniPad.plist: "prefs:root= HOME_SCREEN_DOCK#BADGES_IN_APP_LIBRARY"
plutil -p "$1" \
| egrep '"(prefs|bridge):' \
| perl -pe 's/ //g and s/=>/|/g and s/^\s*(.*)/$ENV{i}|$ENV{path}|\1/g'
return ${PIPESTATUS[0]}
}
##############
### main() ###
##############
export path
export i=0
check_effective_uid
check_ios_root
cd "$ROOT_DIR" || err "Couldn't cd to \$ROOT_DIR"
print_header
while IFS= read -r -d $'\0' path
do
let "i = i + 1"
process_plist "$path" || warn "FAILED to decode file: $path"
done < <(find -L . -type f -name '*.plist' -print0)
print_footer
# For only searching SettingsSearchManifest plist files
# done < <(find . -name '*SettingsSearchManifest*plist' -print0)
# print_footer