Skip to content

Commit

Permalink
Make RunMeNg.sh and subscripts OSX compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Matioupi committed Jan 28, 2018
1 parent 7ddc0d6 commit 403e110
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 20 deletions.
59 changes: 54 additions & 5 deletions RunMeNg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,34 @@
# First argument : name of apk file in PutApkHere subdirectory
# Second argument :

# Check if we are running an OSX or Linux system
if uname -a|grep darwin>/dev/null
then
echo "========================================"
echo "Running script on an Linux system"
echo "========================================"
SYSTEMTYPE=LINUX
DISPLAYCMD="display"
else
echo "========================================"
echo "Running script on an OSX system"
echo "========================================"
SYSTEMTYPE=OSX
DISPLAYCMD="open -W"
GOPT_VER=$(getopt --version)
if [[ ! "$GOPT_VER" =~ "enhanced" ]]
then
echo "you need to use gnu-getopt to run this script correctly on OSX"
echo "this can be done with following commands if brew/homebrew package system is installed"
echo "brew install gnu-getopt"
echo "brew link --force gnu-getopt"
echo "additionnal information about brew/homebrew package system can be found at : https://brew.sh/index_fr.html"
echo "========================================"
echo
exit
fi
fi

function usage() {
echo "RunMeNg : script for patching some application"
echo ""
Expand Down Expand Up @@ -76,12 +104,32 @@ command -v dos2unix >/dev/null 2>&1 || { echo "I require dos2unix but it's not i
command -v getopt >/dev/null 2>&1 || { echo "I require getopt but it's not installed. Aborting." >&2; err=1; }
command -v convert >/dev/null 2>&1 || { echo "I require convert (imagemagick package) but it's not installed. Aborting." >&2; err=1; }
command -v dwebp >/dev/null 2>&1 || { echo "I require dwebp (webp package) but it's not installed. Aborting." >&2; err=1; }
command -v display >/dev/null 2>&1 || { echo "I require display (imagemagick package) but it's not installed. Aborting." >&2; err=1; }

if [ $SYSTEMTYPE == LINUX ]
then
command -v display >/dev/null 2>&1 || { echo "I require display (imagemagick package) but it's not installed. Aborting." >&2; err=1; }
fi

if [ $SYSTEMTYPE == OSX ]
then
command -v gsed >/dev/null 2>&1 || { echo "I require gsed (gnu-sed package) but it's not installed. Aborting." >&2; err=1; }
fi

if [ $err = 1 ]
then
echo "Missing package. See detailled message above."
exit 1
echo "Missing package. See detailled message above."
echo "on your system, missing packages can be installed with a command like : "
if [ $SYSTEMTYPE == OSX ]
then
echo "brew install missing_package_name"
echo "additionnal information about brew/homebrew package system can be found at : https://brew.sh/index_fr.html"
else
echo "sudo apt-get install missing_package_name"
echo "or"
echo "sudo yum install missing_package_name"
echo "or other command depending on your linux distribution and settingsÒ"
fi
exit 1
fi

SPLIT_ARG_TEMP=`getopt -o ha:w:o:k:d:p:c:i:r:t: --longoptions help,apkname:,work-directory:,output-apk:,keep-temp:,decompile-step:,patch-step:,clone-step:,iconmod-step:,repack-step:,timestamp: -u -n 'RunMeNg.sh' -- "$@"`
Expand Down Expand Up @@ -203,7 +251,7 @@ message=$message"\\n"
printf '%b\n' "$message"
echo "Do you agree with steps above ?"
echo ""
if [[ "$OSTYPE" =~ ^darwin ]];then
if [ "$SYSTEMTYPE" = OSX ];then
read -p "Agree (y/n)" -n 1 test_continue
else
read -p "Agree (y/n)" -N 1 test_continue
Expand Down Expand Up @@ -274,8 +322,9 @@ then
read -r -p "Enter value betwen 0 and 200 : " hue_shift
echo ""
echo "A window with image should open, when ready close it and choose to keep or try a new color value"
echo "on OSX you have to close the windows with cmd+Q to return to script execution"
convert /tmp/test-$unique_rnd.png -modulate 100,100,$hue_shift /tmp/test-$unique_rnd-out.png
display /tmp/test-$unique_rnd-out.png
$DISPLAYCMD /tmp/test-$unique_rnd-out.png
echo ""
read -p "Keep this color or try a new one (y/n) ? " colorok
echo ""
Expand Down
2 changes: 0 additions & 2 deletions change_appicons_color.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#echo $1/appicon*
err=0
command -v convert >/dev/null 2>&1 || { echo "I require convert (imagemagick package) but it's not installed. Aborting." >&2; err=1; }
command -v dwebp >/dev/null 2>&1 || { echo "I require dwebp (webp package) but it's not installed. Aborting." >&2; err=1; }
command -v display-im6 >/dev/null 2>&1 || { echo "I require display-im6 (imagemagick package) but it's not installed. Aborting." >&2; err=1; }

if [ $err = 1 ]
then
Expand Down
15 changes: 14 additions & 1 deletion decompile_apk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
# Second argument : name of the output directory e.g. decompile_out
# Third argument : timestamp for generating the logs with autogeneration if empty

# Check if we are running an OSX or Linux system
if uname -a|grep darwin>/dev/null
then
SYSTEMTYPE=LINUX
else
SYSTEMTYPE=OSX
fi

if [ ! -f tools/apktool.jar ]
then
echo "apktool.jar not found, run download_tools.sh!"
Expand Down Expand Up @@ -45,7 +53,12 @@ echo "Output directory $2 already exist. Now you have to make a choice.
(1) delete existing directory and overwrite
(2) skip decompilation script
"
read -N 1 -p "Enter your choice : " overwrite_choice
if [ $SYSTEMTYPE = OSX ]
then
read -n 1 -p "Enter your choice : " overwrite_choice
else
read -N 1 -p "Enter your choice : " overwrite_choice
fi
echo ""
else
overwrite_choice="1"
Expand Down
42 changes: 30 additions & 12 deletions prepare_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,37 @@
#
# ./prepare_cloning.sh ijd.og.v5 decompile_out "AIzaSyB-ICOGgAOCBopE5MdBDJXEkljD27pBSiJ" "IJD OG 4.1.14 modded"

./decrypt_strings_one_file.py 2 "$1/smali_classes5/dji/pilot2/newlibrary/dshare/model/a\$a.smali"
./decrypt_strings_one_file.py 2 "$1/smali_classes5/dji/pilot2/scan/android/CaptureActivity\$11.smali"
./decrypt_strings_one_file.py 2 "$1/smali_classes2/com/dji/update/view/UpdateDialogActivity.smali"
./decrypt_strings_one_file.py 2 "$1/smali_classes3/dji/assets/b.smali"
./decrypt_strings_one_file.py 2 "$1/smali_classes4/dji/pilot/fpv/control/y.smali"
chmod +x ./defog_strings_one_file.py

# Check if we are running an OSX or Linux system
if uname -a|grep darwin>/dev/null
then
SYSTEMTYPE=LINUX
SED_CMD=sed
else
SYSTEMTYPE=OSX
OLD_LC_CTYPE=$LC_CTYPE
# fix because OSX "tr" does not work on arbitrary chars without that environment variable set
export LC_CTYPE=C
SED_CMD=gsed
fi

./defog_strings_one_file.py 2 "$1/smali_classes5/dji/pilot2/newlibrary/dshare/model/a\$a.smali"
./defog_strings_one_file.py 2 "$1/smali_classes5/dji/pilot2/scan/android/CaptureActivity\$11.smali"
./defog_strings_one_file.py 2 "$1/smali_classes2/com/dji/update/view/UpdateDialogActivity.smali"
./defog_strings_one_file.py 2 "$1/smali_classes3/dji/assets/b.smali"
./defog_strings_one_file.py 2 "$1/smali_classes4/dji/pilot/fpv/control/y.smali"

substitution_regex_packagename="s/dji.go.v4/$2/g"
substitution_regex_googleapi="s/AIzaSyB-ICOGgAOCBopE5MdBDJXEkljD27pBSiI/$3/g"

newfbnumber=$(cat /dev/urandom | tr -dc '0-9' | fold -w 16 | head -n 1)
substitution_regex_facebook="s/FacebookContentProvider1820832821495825/FacebookContentProvider$newfbnumber/g"
new_package_label=$(echo "$4"|sed -e 's/ /\\x20/g')
new_package_label=$(echo "$4"|$SED_CMD -e 's/ /\\x20/g')
substitution_regex_label="s/DJI\x20GO\x204/$new_package_label/g"

#replace dji.go.v4 by new package name in all files
find $1 -type f -exec sed -i $substitution_regex_packagename {} +
find $1 -type f -exec $SED_CMD -i $substitution_regex_packagename {} +

#Change specific parts in AndroidManifest.xml
#
Expand All @@ -56,9 +71,12 @@ find $1 -type f -exec sed -i $substitution_regex_packagename {} +
# Application Label
#

sed -i '/\s*<permission android:name="dji.permission.broadcast"\sandroid:protectionLevel="signature"\/>/d' $1/AndroidManifest.xml
sed -i $substitution_regex_googleapi $1/AndroidManifest.xml
sed -i $substitution_regex_facebook $1/AndroidManifest.xml
sed -i $substitution_regex_label $1/AndroidManifest.xml

$SED_CMD -i '/\s*<permission android:name="dji.permission.broadcast"\sandroid:protectionLevel="signature"\/>/d' $1/AndroidManifest.xml
$SED_CMD -i $substitution_regex_googleapi $1/AndroidManifest.xml
$SED_CMD -i $substitution_regex_facebook $1/AndroidManifest.xml
$SED_CMD -i $substitution_regex_label $1/AndroidManifest.xml

if [ $OSTYPE == OSX ]
then
export LC_CTYPE=$OLD_LC_CTYPE
fi

0 comments on commit 403e110

Please sign in to comment.