Created
August 4, 2024 15:54
-
-
Save tunglam14/03c0e8a201d3a1234c662fc066c33736 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
random() { | |
tr </dev/urandom -dc A-Za-z0-9 | head -c5 | |
echo | |
} | |
array=(1 2 3 4 5 6 7 8 9 0 a b c d e f) | |
gen64() { | |
ip64() { | |
echo "${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}" | |
} | |
echo "$1:$(ip64):$(ip64):$(ip64):$(ip64)" | |
} | |
install_3proxy() { | |
echo "installing 3proxy" | |
URL="https://github.com/z3APA3A/3proxy/archive/refs/tags/0.8.13.tar.gz" | |
wget -qO- $URL | tar -xzf- | |
cd 3proxy-0.8.13 | |
make -f Makefile.Linux | |
mkdir -p /usr/local/etc/3proxy/{bin,logs,stat} | |
cp src/3proxy /usr/local/etc/3proxy/bin/ | |
cd $WORKDIR | |
} | |
gen_3proxy() { | |
cat <<EOF | |
daemon | |
maxconn 4000 | |
nserver 1.1.1.1 | |
nserver 8.8.4.4 | |
nserver 2001:4860:4860::8888 | |
nserver 2001:4860:4860::8844 | |
nscache 65536 | |
timeouts 1 5 30 60 180 1800 15 60 | |
setgid 65535 | |
setuid 65535 | |
stacksize 6291456 | |
flush | |
auth strong | |
users $(awk -F "/" 'BEGIN{ORS="";} {print $1 ":CL:" $2 " "}' ${WORKDATA}) | |
$(awk -F "/" '{print "auth strong\n" \ | |
"allow " $1 "\n" \ | |
"proxy -6 -n -a -p" $4 " -i" $3 " -e"$5"\n" \ | |
"flush\n"}' ${WORKDATA}) | |
EOF | |
} | |
gen_proxy_file_for_user() { | |
cat >proxy.txt <<EOF | |
$(awk -F "/" '{print $3 ":" $4 ":" $1 ":" $2 }' ${WORKDATA}) | |
EOF | |
} | |
gen_data() { | |
seq $FIRST_PORT $LAST_PORT | while read port; do | |
echo "user$port/$(random)/$IP4/$port/$(gen64 $IP6)" | |
done | |
} | |
gen_ifconfig() { | |
cat <<EOF | |
$(awk -F "/" '{print "ifconfig enp1s0 inet6 add " $5 "/64"}' ${WORKDATA}) | |
EOF | |
} | |
echo "installing apps" | |
service firewall-cmd stop | |
systemctl mask --now firewalld.service | |
systemctl disable --now firewalld.service | |
install_3proxy | |
echo "working folder = /home/bkns" | |
WORKDIR="/home/bkns" | |
WORKDATA="${WORKDIR}/data.txt" | |
mkdir -p $WORKDIR && cd $WORKDIR | |
IP4=$(curl -4 -s icanhazip.com) | |
IP6=$(curl -6 -s icanhazip.com | cut -f1-4 -d':') | |
echo "Internal IP = ${IP4}. External sub for IP6 = ${IP6}" | |
FIRST_PORT=22000 | |
LAST_PORT=22700 | |
gen_data >$WORKDIR/data.txt | |
gen_ifconfig >$WORKDIR/boot_ifconfig.sh | |
chmod +x boot_*.sh /etc/rc.d/rc.local | |
gen_3proxy >/usr/local/etc/3proxy/3proxy.cfg | |
cat >>/etc/rc.d/rc.local <<EOF | |
bash ${WORKDIR}/boot_ifconfig.sh | |
ulimit -n 10048 | |
/usr/local/etc/3proxy/bin/3proxy /usr/local/etc/3proxy/3proxy.cfg | |
EOF | |
chmod +x /etc/rc.d/rc.local | |
systemctl enable rc-local | |
systemctl start rc-local | |
gen_proxy_file_for_user | |
rm -rf /root/setup.sh | |
rm -rf /root/3proxy-3proxy-0.8.6 | |
echo "Starting Proxy" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment