-
Notifications
You must be signed in to change notification settings - Fork 0
/
Appchaeologist.sh
executable file
·32 lines (25 loc) · 1.19 KB
/
Appchaeologist.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
#Inputs
#(Might be direct filename or path with filename)
INPUT_PARAMETER=$1
INPUT_FILENAME_WITH_EXTENSION=$(basename $INPUT_PARAMETER)
INPUT_FILENAME_WITHOUT_EXTENSION=$(echo $INPUT_FILENAME_WITH_EXTENSION | cut -f 1 -d '.')
INPUT_FOLDER_PATH=$(dirname "$(greadlink -m $INPUT_PARAMETER)")
#Temp/Interim
TEMP_ZIP_FILENAME="$INPUT_FILENAME_WITHOUT_EXTENSION.zip"
TEMP_EXTRACTION_FOLDER_NAME="$INPUT_FILENAME_WITHOUT_EXTENSION-EXTRACTION"
TEMP_EXTRACTION_FOLDER_PATH="$INPUT_FOLDER_PATH/$TEMP_EXTRACTION_FOLDER_NAME"
TEMP_PAYLOAD_FOLDER_PATH="$TEMP_EXTRACTION_FOLDER_PATH/Payload"
TEMP_APP_FOLDER_PATH="$TEMP_PAYLOAD_FOLDER_PATH/$INPUT_FILENAME_WITHOUT_EXTENSION.app"
#Outputs
OUTPUT_PAYLOAD_CONTENTS_FOLDER_PATH="$TEMP_EXTRACTION_FOLDER_PATH/PayloadContents"
#Create a interim copy and make it as a .zip file
cp $INPUT_PARAMETER $TEMP_ZIP_FILENAME
#Extract .ipa(zip) contents to Extraction folder
unzip $TEMP_ZIP_FILENAME -d $TEMP_EXTRACTION_FOLDER_PATH
#Put .app contents to PayloadContents folder
cp -r $TEMP_APP_FOLDER_PATH/. $OUTPUT_PAYLOAD_CONTENTS_FOLDER_PATH
#Clear artifacts
##Clear created interim .zip file
rm $TEMP_ZIP_FILENAME
##Clearing Payload as it is redundant
rm -rf $TEMP_PAYLOAD_FOLDER_PATH