#!/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

# 0.3

echo -e "\033[1;33;40PRcc-天天开心\033[0m"
echo -e "\033[33;31m**************************************\033[0m"   	

# 0.2

cp -f arm64-v8a/libNPC.so /data/data/com.rekoo.pubgm/
chmod 755 /data/data/com.rekoo.pubgm/libNPC.so*

cp -f inject /data/data/com.rekoo.pubgm/
chmod 777 /data/data/com.rekoo.pubgm/inject*

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

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

echo -e "\n"

print_color 41 "准备完毕!"

echo -e "\n"

am start -n  com.rekoo.pubgm/com.epicgames.ue4.SplashActivity
# 4
sleep 2.5
/data/data/com.rekoo.pubgm/inject -n com.rekoo.pubgm -so /data/data/com.rekoo.pubgm/libNPC.so
