Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent script #37

Open
expelledboy opened this issue Jan 28, 2021 · 1 comment
Open

Equivalent script #37

expelledboy opened this issue Jan 28, 2021 · 1 comment

Comments

@expelledboy
Copy link

#!/usr/bin/env bash

export PATH=$PATH:$ANDROID_HOME/platform-tools

PKG_NAME=com.whatsapp
LEGACY_APK_FILE=WhatsApp.legacy.apk
BACKUP_APK_FILE=WhatsApp.backup.apk

info() {
	echo "==> [info] $*"
}

error() {
	echo "==> [error] $*"
	exit 1
}

install_apk() {
	local apk_filepath=$1

	if [ "$SDK_VERSION" -ge 17 ]; then
		adb install -r -d "$apk_filepath"
	else
		adb install -r "$apk_filepath"
	fi
}

uninstall_package() {
	local package=$1

	if [ "$SDK_VERSION" -ge 23 ]; then
		adb shell pm uninstall -k "$package"
	fi
}

stop_package() {
	local package=$1

	if [ "$SDK_VERSION" -ge 11 ]; then
		adb shell am force-stop "$package"
	else
		adb shell am kill "$package"
	fi

}

backup_package() {
	local package=$1

	if [ "$SDK_VERSION" -ge 23 ]; then
		adb backup -f whatsapp.ab "$package"
	else
		adb backup -f whatsapp.ab -noapk "$package"
	fi
}

cleanup() {
	if [ -f "$BACKUP_APK_FILE" ]; then
		install_apk "$BACKUP_APK_FILE"
	fi

	adb kill-server
}

trap cleanup EXIT

set -eu -o pipefail

info "Check for required binaries"

for cmd in adb curl grep java tar tr; do
	command -v $cmd || error "$cmd not available"
done

info "Please connect your Android device with USB Debugging enabled"

adb kill-server
adb start-server
adb wait-for-device

info "Checking script compatibility"

SDK_VERSION=$(adb shell getprop ro.build.version.sdk | tr -d '[:space:]')

if [ "$SDK_VERSION" -le 13 ]; then
	error "Unsupported Android Version - Require 4.0 or higher"
fi

APK_VERSION=$(adb shell dumpsys package com.whatsapp | sed -nE 's/.*versionName=(.*)/\1/p' || true)

if [ -z "$APK_VERSION" ]; then
	error "WhatsApp not installed on device"
fi

APK_PATH=$(adb shell pm path com.whatsapp | sed -nE 's/.*package:(.*)/\1/p')
BACKUP_DIR=$(adb shell "echo -e \$EXTERNAL_STORAGE/WhatsApp/Databases/.nomedia")

if [ ! -f $LEGACY_APK_FILE ]; then
	info "Downloading legacy WhatsApp version"
	curl -o $LEGACY_APK_FILE https://whatcrypt.com/WhatsApp-2.11.431.apk
fi

if [ "$(wc -c <$LEGACY_APK_FILE)" -lt 10000 ]; then
	error "Failed to download legacy WhatsApp apk"
fi

info "Running with configuration"

echo "APK_VERSION = '$APK_VERSION'"
echo "APK_PATH = '$APK_PATH'"
echo "BACKUP_DIR = '$BACKUP_DIR'"

info "Replacing WhatsApp ${APK_VERSION} with Legacy build"

if [ ! -f $BACKUP_APK_FILE ]; then
	info "Downloading installed WhatsApp version"
	adb pull "$APK_PATH" "$BACKUP_APK_FILE"
fi

stop_package $PKG_NAME
uninstall_package "$PKG_NAME"
install_apk $LEGACY_APK_FILE

info "Attempting backup using legacy whatsapp"

backup_package "$PKG_NAME"

info "Restoring WhatsApp"

cleanup
@SenCodeMaker
Copy link

thank you this helped me to install whatapps mod and get non encrypted backup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants