-
Notifications
You must be signed in to change notification settings - Fork 15
/
extract.sh
62 lines (49 loc) · 1.52 KB
/
extract.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
#!/bin/bash
mkdir -p Bins
IPAs=$(find . -iname "*.ipa")
echo ${#IPAs[@]}
for ipaName in $IPAs
do
echo "#########"
echo "extract $ipaName"
rm -rf tmp
unzip -o -u $ipaName -d tmp &> /dev/null
appFilename=$(find tmp -iname "*.app")
appFilename=${appFilename[0]}
echo $appFilename
plist="$appFilename/Info.plist"
echo "$plist"
if ! [ -e $plist ] ; then
echo "ERROR: No .plist file"
continue
fi
bundleID=$(/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" $plist)
if [ $? -eq 1 ] ; then
bundleID=$(/usr/libexec/PlistBuddy -c "Print CFBundleName" $plist)
fi
echo $bundleID
displayName=$(/usr/libexec/PlistBuddy -c "Print CFBundleDisplayName" $plist)
if [ $? -eq 1 ] ; then
displayName=$(/usr/libexec/PlistBuddy -c "Print itemName" $plist)
fi
echo $displayName
binaryName=$(/usr/libexec/PlistBuddy -c "Print CFBundleExecutable" $plist)
echo $binaryName
if [ -e "Bins/$binaryName" ] ; then
i=0
newBinaryName="$binaryName$i"
while [ -e "Bins/$newBinaryName" ]
do
i=$(($i+1))
newBinaryName="$binaryName$i"
done
cp $appFilename/$binaryName $appFilename/$newBinaryName
binaryName="$newBinaryName"
echo "ERROR: file exists $binaryName"
fi
echo "copy $binaryName"
cp $appFilename/$binaryName Bins/$binaryName
echo "$displayName;$bundleID;$binaryName" >> Bins/info.csv
echo "$binaryName" >> Bins/binaries.txt
rm -rf tmp
done