#!/bin/bash

function print_color() {
  local color=$1
  shift
  echo -e "\033[${color}m$@\033[0m"
}

# 检查用户是否为root用户
if [ $(id -u) != 0 ]; then
    echo "\n请使用Root权限执行 !"
    exit 1
fi

sleep 0.3

cp -f libBC.so /data/data/com.pubg.krmobile/
chmod 755 /data/data/com.pubg.krmobile/libBC.so*

cp -f inject_arm64 /data/data/com.pubg.krmobile/
chmod 777 /data/data/com.pubg.krmobile/inject_arm64*

cp -f inject_arm32 /data/data/com.pubg.krmobile/
chmod 777 /data/data/com.pubg.krmobile/inject_arm32*

# 检查文件是否存在并且权限为755
if [ -f /data/data/com.pubg.krmobile/libBC.so ] && [ "$(stat -c '%a' /data/data/com.pubg.krmobile/libBC.so)" = "755" ]; then
    echo "[+] 动态库文件正常"
else
    echo "[-] 动态库文件不正确"
    exit 1
fi

if [ -f /data/data/com.pubg.krmobile/inject_arm64 ] && [ "$(stat -c '%a' /data/data/com.pubg.krmobile/inject_arm64)" = "777" ]; then
    echo "[+] 劫持文件正常"
else
    echo "[-] 劫持文件不正确"
    exit 1
fi

echo -e "\n"

print_color 41 "准备完毕!"

echo -e "\n"

sleep 0.5

am start com.pubg.krmobile/com.epicgames.ue4.SplashActivity

 sleep 8.0

echo -e "\n"

su -c /data/data/com.pubg.krmobile/inject_arm32
su -c /data/data/com.pubg.krmobile/inject_arm64 -n com.pubg.krmobile -so /data/data/com.pubg.krmobile/libBC.so