install.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. cat <<EOF
  28. daemon
  29. maxconn 1000
  30. nscache 65536
  31. timeouts 1 5 30 60 180 1800 15 60
  32. setgid 65535
  33. setuid 65535
  34. stacksize 262144
  35. flush
  36. auth strong
  37. users $(awk -F "/" 'BEGIN{ORS="";} {print $1 ":CL:" $2 " "}' ${WORKDATA})
  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. seq $FIRST_PORT $LAST_PORT | while read port; do
  59. echo "usr$(random)/pass$(random)/$IP4/$port/$(gen64 $IP6)"
  60. done
  61. }
  62. gen_iptables() {
  63. cat <<EOF
  64. $(awk -F "/" '{print "iptables -I INPUT -p tcp --dport " $4 " -m state --state NEW -j ACCEPT"}' ${WORKDATA})
  65. EOF
  66. }
  67. gen_ifconfig() {
  68. cat <<EOF
  69. $(awk -F "/" '{print "ifconfig eth0 inet6 add " $5 "/64"}' ${WORKDATA})
  70. EOF
  71. }
  72. echo "installing apps"
  73. yum -y install gcc net-tools bsdtar zip >/dev/null
  74. install_3proxy
  75. echo "working folder = /home/proxy-installer"
  76. WORKDIR="/home/proxy-installer"
  77. WORKDATA="${WORKDIR}/data.txt"
  78. mkdir $WORKDIR && cd $_
  79. IP4=$(curl -4 -s ifconfig.co)
  80. IP6=$(curl -6 -s ifconfig.co | cut -f1-4 -d':')
  81. echo "Internal ip = ${IP4}. Exteranl sub for ip6 = ${IP6}"
  82. echo "How many proxy do you want to create? Example 500"
  83. read COUNT
  84. FIRST_PORT=10000
  85. LAST_PORT=$(($FIRST_PORT + $COUNT))
  86. gen_data >$WORKDIR/data.txt
  87. gen_iptables >$WORKDIR/boot_iptables.sh
  88. gen_ifconfig >$WORKDIR/boot_ifconfig.sh
  89. chmod +x boot_*.sh /etc/rc.local
  90. gen_3proxy >/usr/local/etc/3proxy/3proxy.cfg
  91. cat >>/etc/rc.local <<EOF
  92. bash ${WORKDIR}/boot_iptables.sh
  93. bash ${WORKDIR}/boot_ifconfig.sh
  94. ulimit -n 65536
  95. service 3proxy start
  96. EOF
  97. bash /etc/rc.local
  98. gen_proxy_file_for_user
  99. upload_proxy