install.sh 3.1 KB

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