-
Notifications
You must be signed in to change notification settings - Fork 30
/
r1.sh
executable file
·109 lines (89 loc) · 3.18 KB
/
r1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
install_debian() {
sudo apt update
[[ -x "$(command -v git)" ]] || sudo apt install -y git
[[ -x "$(command -v python3)" ]] || sudo apt install -y python3
[[ -x "$(command -v pip3)" ]] || sudo apt install -y python3-pip
[[ -x "$(command -v dos2unix)" ]] || sudo apt install -y dos2unix
[[ -x "$(command -v curl)" ]] || sudo apt install -y curl
[[ -x "$(command -v unzip)" ]] || sudo apt install -y unzip
}
install_arch() {
sudo pacman -Sy --noconfirm
[[ -x "$(command -v git)" ]] || sudo pacman -S --noconfirm git
[[ -x "$(command -v python3)" ]] || sudo pacman -S --noconfirm python
[[ -x "$(command -v dos2unix)" ]] || sudo pacman -S --noconfirm dos2unix
[[ -x "$(command -v curl)" ]] || sudo pacman -S --noconfirm curl
[[ -x "$(command -v unzip)" ]] || sudo pacman -S --noconfirm unzip
[[ -x "$(command -v virtualenv)" ]] || sudo pacman -S --noconfirm python-virtualenv
}
install_fedora() {
sudo dnf update -y
[[ -x "$(command -v git)" ]] || sudo dnf install -y git
[[ -x "$(command -v python3)" ]] || sudo dnf install -y python3
[[ -x "$(command -v pip3)" ]] || sudo dnf install -y python3-pip
[[ -x "$(command -v dos2unix)" ]] || sudo dnf install -y dos2unix
[[ -x "$(command -v curl)" ]] || sudo dnf install -y curl
[[ -x "$(command -v unzip)" ]] || sudo dnf install -y unzip
}
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt-get &>/dev/null; then
install_debian
elif command -v pacman &>/dev/null; then
install_arch
elif command -v dnf &>/dev/null; then
install_fedora
else
echo "Unsupported Linux distribution"
exit 1
fi
else
echo "Unsupported OS"
exit 1
fi
if [[ "$OSTYPE" != "linux-gnu"* || ! "$(command -v pacman)" ]]; then
pip3 show virtualenv &>/dev/null || pip3 install virtualenv
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt-get &>/dev/null; then
sudo apt install -y adb fastboot
elif command -v pacman &>/dev/null; then
sudo pacman -S --noconfirm android-tools
elif command -v dnf &>/dev/null; then
sudo dnf install -y android-tools
fi
fi
# Setup virtualenv and install requirements
python3 -m venv venv
source venv/bin/activate
chmod x mtkbootcmd.py
# Download mtkclient
REPO_URL="https://github.com/AgentFabulous/mtkclient"
REPO_NAME=$(basename "$REPO_URL" .git)
git clone "$REPO_URL"
cd "$REPO_NAME" || exit
pip3 install -r requirements.txt
rm -f frp.bin
read -p "[*] Power off your device, press ENTER plug it into your PC"
# Read FRP
sudo python3 mtk r frp frp.bin
sudo chown $USER frp.bin
LAST_BYTE=$(xxd -p -l 1 -s -1 frp.bin)
if [[ "$LAST_BYTE" == "00" ]]; then
printf '\x01' | dd of=frp.bin bs=1 seek=$(($(stat -c%s frp.bin) - 1)) conv=notrunc
fi
# Write FRP
sudo python3 mtk w frp frp.bin
read -p "[*] Unplug your device, press ENTER, plug it back in"
cd ..
sudo ./mtkbootcmd.py FASTBOOT
echo "[*] Waiting for fastboot..."
while ! fastboot devices | grep -q "fastboot"; do
sleep 1
done
fastboot flashing unlock
fastboot -w
fastboot flash --disable-verity --disable-verification vbmeta vbmeta.img
fastboot reboot-fastboot
fastboot flash system system.img
fastboot reboot