aboutsummaryrefslogtreecommitdiff
path: root/utils/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'utils/scripts')
-rwxr-xr-xutils/scripts/add_to_fs.sh29
-rwxr-xr-xutils/scripts/list_packages.sh7
-rwxr-xr-xutils/scripts/modify_apk.sh50
3 files changed, 86 insertions, 0 deletions
diff --git a/utils/scripts/add_to_fs.sh b/utils/scripts/add_to_fs.sh
new file mode 100755
index 0000000..037c5e6
--- /dev/null
+++ b/utils/scripts/add_to_fs.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [ "$#" -lt 3 ]; then
+ echo "Incorrect arguments!"
+ echo " Using: $0 <PARTITION_NAME> <FILE_INPUT> <FILE_LOCATION> [FTYPE (d,f,x)] [SELINUX_DOMAIN]"
+ exit 1
+fi
+
+PARTITION_NAME=$1
+FILE_INPUT=$2
+FILE_LOCATION=$3
+FTYPE=$4
+SELINUX_DOMAIN=$5
+
+
+FS_CONFIG_DIR="unpacked/mnt/config/"
+PERMISSION=0644
+
+if [[ -z ${SELINUX_DOMAIN} ]]; then
+ SELINUX_DOMAIN="system_file"
+fi
+
+echo "/${PARTITION_NAME}/${FILE_LOCATION}/${FILE_INPUT} u:object_r:$SELINUX_DOMAIN:s0" >> ${FS_CONFIG_DIR}/${PARTITION_NAME}_file_contexts
+
+# PART_NAME_fs_config
+if [[ -d $FILE_INPUT || $FTYPE == 1 ]]; then
+ PERMISSION=0755
+fi
+echo "${PARTITION_NAME}/${FILE_LOCATION}/${FILE_INPUT} 0 0 ${PERMISSION}" >> ${FS_CONFIG_DIR}/${PARTITION_NAME}_fs_config
diff --git a/utils/scripts/list_packages.sh b/utils/scripts/list_packages.sh
new file mode 100755
index 0000000..78fe462
--- /dev/null
+++ b/utils/scripts/list_packages.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+MNT_DIR="unpacked/mnt/"
+
+for i in $(find $MNT_DIR -name "*.apk"); do
+ echo -e "$( aapt dump badging $i | awk '/package/{gsub("name=|'"'"'",""); print $2}' ) : $i"
+done
diff --git a/utils/scripts/modify_apk.sh b/utils/scripts/modify_apk.sh
new file mode 100755
index 0000000..e682598
--- /dev/null
+++ b/utils/scripts/modify_apk.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+TMP_DIR="/tmp/driedlamu/modify_apk"
+
+decompile() {
+ local file="$1"
+ local file_name="$(basename "$file" .apk)"
+ local working_dir="$TMP_DIR/$file_name"
+
+ mkdir -p "$working_dir"
+
+ if ! java -Xmx2048m -jar "./utils/jar/apktool.jar" d -q -f "$file" -o "$working_dir/decompile"; then
+ echo "Error: Failed to decompile $file with apktool"
+ exit 1
+ fi
+}
+
+repack() {
+ local file="$1"
+ local file_name="$(basename "$file" .apk)"
+ local output_location="$2"
+ local working_dir="$TMP_DIR/$file_name"
+ local modified_apk="$working_dir/${file_name}_unsigned.apk"
+
+ if ! java -Xmx2048m -jar "./utils/jar/apktool.jar" b -q -f "$working_dir/decompile" -o "$working_dir/${file_name}_unsigned.apk"; then
+ echo "Error: Failed to recompile $file with apktool"
+ exit 1
+ fi
+
+ apksigcopier copy "$file" "$modified_apk" "${output_location}/${file_name}.apk"
+}
+
+mkdir -p $TMP_DIR
+
+apk_cli() {
+ case $1 in
+ unpack)
+ decompile "$2"
+ ;;
+ repack)
+ repack "$2" "$3"
+ ;;
+ *)
+ echo "Please specify a valid type of task you wish to do (unpack, repack)."
+ exit 1
+ ;;
+ esac
+}
+
+apk_cli "$1" "$2" "$3"