-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathshsh2apt
executable file
·39 lines (35 loc) · 1.08 KB
/
shsh2apt
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
#!/bin/bash
set -e;
if [ $# -ge 1 ]; then
shsh="$1";
else
shsh=();
while read -r; do
if ! [ -z "$REPLY" ]; then
shsh+=("$REPLY");
fi;
done <<<"$(find . -type f -name '*.shsh')";
while read -r; do
if ! [ -z "$REPLY" ]; then
shsh+=("$REPLY");
fi;
done <<<"$(find . -type f -name '*.shsh2')";
if [ "${#shsh[@]}" -gt 1 ]; then
echo 'More than one shsh/shsh2 file found in current directory. Please specify one.';
exit 1;
elif [ "${#shsh[@]}" -lt 1 ]; then
echo 'No shsh/shsh2 file found in current directory. Please specify one.';
exit 1;
fi;
shsh="${shsh[0]}";
fi;
if [ $# -ge 2 ]; then
apticket="$2";
else
apticket='apticket.der';
fi;
if plutil -extract ApImg4Ticket xml1 -o - "$shsh" &>/dev/null; then # Img4 format
plutil -extract ApImg4Ticket xml1 -o - "$shsh" | xmllint -xpath '/plist/data/text()' - | base64 -D >"$apticket";
else # Img3 format
plutil -extract APTicket xml1 -o - "$shsh" | xmllint -xpath '/plist/data/text()' - | base64 -D >"$apticket";
fi;