install.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/sh
  2. random() {
  3. tr </dev/urandom -dc A-Za-z0-9 | head -c5
  4. echo
  5. }
  6. array=(1 2 3 4 5 6 7 8 9 0 a b c d e f)
  7. gen64() {
  8. ip64() {
  9. echo "${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}"
  10. }
  11. echo "$1:$(ip64):$(ip64):$(ip64):$(ip64)"
  12. }
  13. gen112() {
  14. ip112() {
  15. echo "${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}"
  16. }
  17. echo "$1::$(ip112):$(ip112)"
  18. }
  19. install_3proxy() {
  20. echo "installing 3proxy"
  21. URL="https://github.com/z3APA3A/3proxy/archive/3proxy-0.8.6.tar.gz"
  22. wget -qO- $URL | bsdtar -xvf-
  23. cd 3proxy-3proxy-0.8.6
  24. make -f Makefile.Linux
  25. mkdir -p /usr/local/etc/3proxy/{bin,logs,stat}
  26. cp src/3proxy /usr/local/etc/3proxy/bin/
  27. cp ./scripts/rc.d/proxy.sh /etc/init.d/3proxy
  28. chmod +x /etc/init.d/3proxy
  29. chkconfig 3proxy on
  30. cd $WORKDIR
  31. }
  32. gen_3proxy() {
  33. # users $(awk -F "/" 'BEGIN{ORS="";} {print $1 ":CL:" $2 " "}' ${WORKDATA})
  34. cat <<EOF
  35. daemon
  36. maxconn 20000
  37. nscache 65536
  38. timeouts 1 5 30 60 180 1800 15 60
  39. setgid 65535
  40. setuid 65535
  41. flush
  42. auth strong
  43. users smile:CL:girl
  44. $(awk -F "/" '{print "auth strong\n" \
  45. "allow " $1 "\n" \
  46. "proxy -6 -n -a -p" $4 " -i" $3 " -e"$5"\n" \
  47. "flush\n"}' ${WORKDATA})
  48. EOF
  49. }
  50. gen_proxy_file_for_user() {
  51. cat >proxy.txt <<EOF
  52. $(awk -F "/" '{print $3 ":" $4 ":" $1 ":" $2 }' ${WORKDATA})
  53. EOF
  54. }
  55. upload_proxy() {
  56. local PASS=$(random)
  57. zip --password $PASS proxy.zip proxy.txt
  58. URL=$(curl -s --upload-file proxy.zip https://transfer.sh/proxy.zip)
  59. echo "Proxy is ready! Format IP:PORT:LOGIN:PASS"
  60. echo "Download zip archive from: ${URL}"
  61. echo "Password: ${PASS}"
  62. }
  63. gen_data() {
  64. # echo "usr$(random)/pass$(random)/$IP4/$port/$(gen64 $IP6)"
  65. seq $FIRST_PORT $LAST_PORT | while read port; do
  66. echo "smile/girl/$IP4/$port/$(gen112 $IP6)"
  67. done
  68. }
  69. gen_iptables() {
  70. cat <<EOF
  71. $(awk -F "/" '{print "iptables -I INPUT -p tcp --dport " $4 " -m state --state NEW -j ACCEPT"}' ${WORKDATA})
  72. EOF
  73. }
  74. # run `ifconifg -a` to get eth device name to replace ens3
  75. # or https://superuser.com/questions/203272/list-only-the-device-names-of-all-available-network-interfaces
  76. gen_ifconfig() {
  77. cat <<EOF
  78. $(awk -F "/" '{print "ifconfig eth0 inet6 add " $5 "/64"}' ${WORKDATA})
  79. EOF
  80. }
  81. echo "installing apps"
  82. # yum -y install gcc net-tools bsdtar zip wget make >/dev/null
  83. yum -y install gcc net-tools bsdtar zip wget make
  84. install_3proxy
  85. echo "working folder = /home/proxy-installer"
  86. WORKDIR="/home/proxy-installer"
  87. WORKDATA="${WORKDIR}/data.txt"
  88. mkdir $WORKDIR && cd $_
  89. IP4=$(curl -4 -s icanhazip.com)
  90. IP6=$(curl -6 -s icanhazip.com | cut -f1-4 -d':')
  91. echo "Internal ip = ${IP4}. Exteranl sub for ip6 = ${IP6}"
  92. echo "How many proxy do you want to create? Example 500 Max 20000"
  93. read COUNT
  94. FIRST_PORT=10001
  95. LAST_PORT=$(($FIRST_PORT + $COUNT - 1))
  96. gen_data >$WORKDIR/data.txt
  97. gen_iptables >$WORKDIR/boot_iptables.sh
  98. gen_ifconfig >$WORKDIR/boot_ifconfig.sh
  99. chmod +x ${WORKDIR}/boot_*.sh /etc/rc.local
  100. gen_3proxy >/usr/local/etc/3proxy/3proxy.cfg
  101. cat >>/etc/rc.local <<EOF
  102. bash ${WORKDIR}/boot_iptables.sh
  103. bash ${WORKDIR}/boot_ifconfig.sh
  104. ulimit -n 50000
  105. service 3proxy start
  106. # systemctl stop firewalld
  107. # systemctl disable firewalld
  108. # systemctl disable firewalld.service
  109. EOF
  110. chmod +x ${WORKDIR}/boot_*.sh /etc/rc.local
  111. bash /etc/rc.local
  112. gen_proxy_file_for_user
  113. upload_proxy