Skip to content

Commit

Permalink
Initial GH Release 🎉
Browse files Browse the repository at this point in the history
It was decided, It is finally open source !

issue ref: frknkrc44/BetterKnownInstalledGO#1 (comment)
  • Loading branch information
0x11DFE committed Feb 6, 2025
1 parent 45fdb6b commit 99e26a7
Show file tree
Hide file tree
Showing 17 changed files with 612 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# Auto detect text files and perform LF normalization
* text=auto

# Enforce LF line endings for build.prop and related files
*.sh text eol=lf
*.prop text eol=lf
*.config text eol=lf

# README.md should also have consistent line endings
README.md text eol=lf

# Mark shell scripts as text and enforce LF
*.sh text eol=lf

# Binary files
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.zip binary
31 changes: 31 additions & 0 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/sbin/sh

#################
# Initialization
#################

umask 022

# echo before loading util_functions
ui_print() { echo "$1"; }

require_new_magisk() {
ui_print "*******************************"
ui_print " Please install Magisk v20.4+! "
ui_print "*******************************"
exit 1
}

#########################
# Load util_functions.sh
#########################

OUTFD=$2
ZIPFILE=$3

[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
. /data/adb/magisk/util_functions.sh
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk

install_module
exit 0
1 change: 1 addition & 0 deletions META-INF/com/google/android/updater-script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#MAGISK
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,43 @@
# BetterKnownInstalled

# BetterKnownInstalled (BKI)

This Magisk/KernelSU/APatch module patches the `packages.xml` and cleans the `packages-warnings.xml` files to address DroidGuard's `UNKNOWN_INSTALLED` status. This helps resolve issues related to app installation and verification on devices with Play Services.

## Description

DroidGuard uses several attributes within the `packages.xml` file to track app installations. This module modifies these attributes to ensure that apps are recognized as properly installed, preventing the `UNKNOWN_INSTALLED` status and related problems. Specifically, it:

* Sets the `installer`, `installInitiator`, and `installerUid` attributes within each `<package>` tag in `packages.xml` to `com.android.vending` (the Google Play Store's package name identifier) and the corresponding user ID. This helps DroidGuard recognize the installation source as legitimate.
* Removes the `installOriginator` attribute, as it can sometimes cause conflicts.
* Cleans the `packages-warnings.xml` file by setting its content to an empty `<packages />` tag. This file can sometimes contain warnings that contribute to the `playProtectVerdict` issues.

This module uses `abx2xml` and `xml2abx` binaries if not in your system by default (provided by [rhythmcache/android-xml-converter](https://github.com/rhythmcache/android-xml-converter)) to convert between binary and text XML formats, as `packages.xml` is typically in binary XML format. The module includes architecture-specific binaries for `aarch64`, `armv7aeabi`, `i686`, and `x86_64`.

**Important Warning:** The environment check verdict modification implemented by this module is a relatively new technique. Google's implementation of this check is not yet robust enough to guarantee that all your packages will be correctly identified. It's possible that some apps might still trigger Play Protect warnings or behave unexpectedly, even after using this module. This is due to limitations and potential inconsistencies in how Google verifies app installations. Use this module with caution and be aware of the potential for these issues.

## Installation

1. Install this module through Magisk Manager, KernelSU, or APatch.
2. Reboot your device for the changes to take effect.

**Important:** Installation from recovery is *not* supported. You *must* install this module from within a running Android environment (Magisk/KernelSU/APatch).

## Usage

This module works automatically upon installation and reboot. No further user interaction is required. It modifies the necessary XML files during the boot process.

## Backups

The module creates backups of the original `packages.xml` and `packages-warnings.xml` files in `/data/adb/modules/BetterKnownInstalled/backup/` before making any changes. Up to five backups of each file type are kept, including the latest one. The backups are timestamped for easy identification.

## Logging

The module logs its activity to `/data/adb/modules/BetterKnownInstalled/BetterKnownInstalled.log`. This log file can be helpful for troubleshooting.

## Credits

* [rhythmcache aka winter](https://github.com/rhythmcache/android-xml-converter) for the `abx2xml` and `xml2abx` binaries.
* [@T3SL4](https://t.me/T3SL4) (Me) for creating this module.

## License

This project is licensed under the terms of the GNU General Public License v3.0. See the [LICENSE](./LICENSE) file for details.
28 changes: 28 additions & 0 deletions common/addon/abx/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/system/bin/busybox sh

# MODPATH is already defined in post-fs-data.sh
TOOL_PATH="$MODPATH/common/addon/abx/tools"

# Determine architecture
current_arch=$(get_arch)
get_arch_status=$?

if [ $get_arch_status -ne 0 ]; then
exit 1 # Exit if get_arch failed
fi

# Check if binaries exist in the determined path
if [ ! -f "$TOOL_PATH/abx2xml-$current_arch" ] || [ ! -f "$TOOL_PATH/xml2abx-$current_arch" ]; then
ui_print "Error: Binaries for $current_arch not found in $TOOL_PATH"
exit 1
fi

# Prepend the architecture-specific bin directory to PATH
export PATH="$TOOL_PATH:$PATH"

# Rename the right binaries arch to abx2xml and xml2abx
ln -sf "$TOOL_PATH/abx2xml-$current_arch" "$TOOL_PATH/abx2xml"
ln -sf "$TOOL_PATH/xml2abx-$current_arch" "$TOOL_PATH/xml2abx"

ui_print "Successfully installed abx tools for $current_arch."
ui_print "Credit: rhythmcache/android-xml-converter for the binaries."
Binary file added common/addon/abx/tools/abx2xml-aarch64
Binary file not shown.
Binary file added common/addon/abx/tools/abx2xml-armv7aeabi
Binary file not shown.
Binary file added common/addon/abx/tools/abx2xml-i686
Binary file not shown.
Binary file added common/addon/abx/tools/abx2xml-x86_64
Binary file not shown.
Binary file added common/addon/abx/tools/xml2abx-aarch64
Binary file not shown.
Binary file added common/addon/abx/tools/xml2abx-armv7aeabi
Binary file not shown.
Binary file added common/addon/abx/tools/xml2abx-i686
Binary file not shown.
Binary file added common/addon/abx/tools/xml2abx-x86_64
Binary file not shown.
14 changes: 14 additions & 0 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/system/bin/busybox sh

enforce_install_from_app() {
if [ ! "$BOOTMODE" ]; then
ui_print "****************************************************"
ui_print "! Install from Recovery is NOT supported !"
ui_print "! Please install from Magisk / KernelSU / APatch !"
abort "****************************************************"
fi
}

enforce_install_from_app

ui_print "- Restart your device to confirm changes."
6 changes: 6 additions & 0 deletions module.prop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id=BetterKnownInstalled
name=BetterKnownInstalled (BKI)
version=v1.3.3
versionCode=1337
author=@T3SL4
description=Patching (installer, installerUid, installInitiator, installOriginator) in packages.xml and cleaning packaga-warnings.xml for defeating DroidGuard: UNKNOWN_INSTALLED
Loading

0 comments on commit 99e26a7

Please sign in to comment.