-
Notifications
You must be signed in to change notification settings - Fork 56
/
android-chisel.sh
109 lines (95 loc) · 3.83 KB
/
android-chisel.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
red='\033[0;31m'
bblue='\033[0;34m'
yellow='\033[0;33m'
green='\033[0;32m'
plain='\033[0m'
red(){ echo -e "\033[31m\033[01m$1\033[0m";}
green(){ echo -e "\033[32m\033[01m$1\033[0m";}
yellow(){ echo -e "\033[33m\033[01m$1\033[0m";}
blue(){ echo -e "\033[36m\033[01m$1\033[0m";}
white(){ echo -e "\033[37m\033[01m$1\033[0m";}
bblue(){ echo -e "\033[34m\033[01m$1\033[0m";}
rred(){ echo -e "\033[35m\033[01m$1\033[0m";}
readtp(){ read -t5 -n26 -p "$(yellow "$1")" $2;}
readp(){ read -p "$(yellow "$1")" $2;}
CHISEL_DIR="$HOME/chisel"
CONFIG_FILE="$CHISEL_DIR/config.json"
LATEST_VERSION=$(curl -sL https://github.com/jpillora/chisel/releases/latest | grep -Eo 'v[0-9]+\.[0-9]+\.[0-9]+' | awk '{sub(/^v/, ""); print; exit}')
if [ -n "$(find "$CHISEL_DIR" -maxdepth 1 -type f -name 'chisel_*' -print -quit)" ]; then
INSTALLED_VERSION=$(basename "$(find "$CHISEL_DIR" -maxdepth 1 -type f -name 'chisel_*' -print -quit)" | cut -d_ -f2)
CHISEL_BIN="chisel_${INSTALLED_VERSION}_linux_arm64"
fi
INSTALL_CHISEL=0
if [ ! -d "$CHISEL_DIR" ]; then
mkdir "$CHISEL_DIR" && cd "$CHISEL_DIR"
INSTALL_CHISEL=1
else
if [ "$INSTALLED_VERSION" != "$LATEST_VERSION" ]; then
yellow "Updating chisel $INSTALLED_VERSION -> $LATEST_VERSION"
if [ -f "$CHISEL_DIR/$CHISEL_BIN" ]; then
rm "$CHISEL_DIR/$CHISEL_BIN"
fi
INSTALL_CHISEL=1
else
:
fi
fi
load_config() {
SOCKS5_PORT=$(jq -r '.SOCKS5_PORT' $CONFIG_FILE)
DOMAIN=$(jq -r '.DOMAIN' $CONFIG_FILE)
echo
echo "----------------Current Config-----------------"
echo -e "${plain} Proxy Port:${yellow} $SOCKS5_PORT${plain}"
echo -e "${plain} Domain:${yellow} $DOMAIN${plain}"
echo "--------------------------------------------"
echo
}
get_user_input() {
if [ -f "$CONFIG_FILE" ]; then
load_config
readp "Do you want to change Chisel configuration? (y/n): " CHANGE_CONFIG
if [ "$CHANGE_CONFIG" == "y" ]; then
:
else
return
fi
else
SOCKS5_PORT=443
DOMAIN="example.com"
fi
readp "Enter SOCKS5 port (default $SOCKS5_PORT): " USER_SOCKS5_PORT
SOCKS5_PORT=${USER_SOCKS5_PORT:-$SOCKS5_PORT}
readp "Enter domain: " USER_DOMAIN
DOMAIN=${USER_DOMAIN:-$DOMAIN}
echo -e "{\n\"SOCKS5_PORT\": \"$SOCKS5_PORT\", \n\"DOMAIN\": \"$DOMAIN\"\n}" > "$CONFIG_FILE"
}
echo
white "---------------------------------------------"
echo
bblue " █████╗ ██╗ ██████╗ "
bblue " ██╔══██╗██║██╔═══██╗ "
bblue " ███████║██║██║ ██║ "
bblue " ██╔══██║██║██║ ██║ "
bblue " ██║ ██║██║╚██████╔╝ "
bblue " ╚═╝ ╚═╝╚═╝ ╚═════╝ "
bblue " All-in-one Proxy Tool "
white " Created by Hosy "
white "---------------------------------------------"
echo
cd "$CHISEL_DIR"
if [[ "$INSTALL_CHISEL" -eq '1' ]]; then
yellow "Installing Chisel ver ($LATEST_VERSION)"
curl -LO "https://github.com/jpillora/chisel/releases/download/v${LATEST_VERSION}/chisel_${LATEST_VERSION}_linux_arm64.gz"
gunzip "chisel_${LATEST_VERSION}_linux_arm64.gz"
chmod +x "chisel_${LATEST_VERSION}_linux_arm64"
else
yellow "Chisel already latest version ($LATEST_VERSION)"
fi
get_user_input
green "Run Nekobox using these values:"
white "---------------------------------------------"
white "server: 127.0.0.1"
white "Remote Port: 5050"
white "---------------------------------------------"
termux-chroot "./chisel_${LATEST_VERSION}_linux_arm64" client "http://$DOMAIN" "5050:127.0.0.1:$SOCKS5_PORT"