install.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. flush
  35. auth strong
  36. users $(awk -F "/" 'BEGIN{ORS="";} {print $1 ":CL:" $2 " "}' ${WORKDATA})
  37. $(awk -F "/" '{print "auth strong\n" \
  38. "allow " $1 "\n" \
  39. "proxy -6 -n -a -p" $4 " -i" $3 " -e"$5"\n" \
  40. "flush\n"}' ${WORKDATA})
  41. EOF
  42. }
  43. gen_proxy_file_for_user() {
  44. cat >proxy.txt <<EOF
  45. $(awk -F "/" '{print $3 ":" $4 ":" $1 ":" $2 }' ${WORKDATA})
  46. EOF
  47. }
  48. upload_proxy() {
  49. local PASS=$(random)
  50. zip --password $PASS proxy.zip proxy.txt
  51. URL=$(curl -s --upload-file proxy.zip https://transfer.sh/proxy.zip)
  52. echo "Proxy is ready! Format IP:PORT:LOGIN:PASS"
  53. echo "Download zip archive from: ${URL}"
  54. echo "Password: ${PASS}"
  55. }
  56. gen_data() {
  57. # echo "usr$(random)/pass$(random)/$IP4/$port/$(gen64 $IP6)"
  58. seq $FIRST_PORT $LAST_PORT | while read port; do
  59. echo "smile/girl/$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. # run `ifconifg -a` to get eth device name to replace ens3
  68. # or https://superuser.com/questions/203272/list-only-the-device-names-of-all-available-network-interfaces
  69. gen_ifconfig() {
  70. cat <<EOF
  71. $(awk -F "/" '{print "ifconfig eth0 inet6 add " $5 "/64"}' ${WORKDATA})
  72. EOF
  73. }
  74. echo "installing apps"
  75. yum -y install gcc net-tools bsdtar zip >/dev/null
  76. install_3proxy
  77. echo "working folder = /home/proxy-installer"
  78. WORKDIR="/home/proxy-installer"
  79. WORKDATA="${WORKDIR}/data.txt"
  80. mkdir $WORKDIR && cd $_
  81. IP4=$(curl -4 -s icanhazip.com)
  82. IP6=$(curl -6 -s icanhazip.com | cut -f1-4 -d':')
  83. echo "Internal ip = ${IP4}. Exteranl sub for ip6 = ${IP6}"
  84. echo "How many proxy do you want to create? Example 500 Max 50000"
  85. read COUNT
  86. FIRST_PORT=10000
  87. LAST_PORT=$(($FIRST_PORT + $COUNT))
  88. gen_data >$WORKDIR/data.txt
  89. gen_iptables >$WORKDIR/boot_iptables.sh
  90. gen_ifconfig >$WORKDIR/boot_ifconfig.sh
  91. chmod +x ${WORKDIR}/boot_*.sh /etc/rc.local
  92. gen_3proxy >/usr/local/etc/3proxy/3proxy.cfg
  93. cat >>/etc/rc.local <<EOF
  94. bash ${WORKDIR}/boot_iptables.sh
  95. bash ${WORKDIR}/boot_ifconfig.sh
  96. ulimit -n 50000
  97. service 3proxy start
  98. # systemctl stop firewalld
  99. # systemctl disable firewalld
  100. # systemctl disable firewalld.service
  101. EOF
  102. chmod +x ${WORKDIR}/boot_*.sh /etc/rc.local
  103. bash /etc/rc.local
  104. gen_proxy_file_for_user
  105. upload_proxy