shadowsocks.sh 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. #25/01/2021
  3. clear
  4. clear
  5. declare -A cor=( [0]="\033[1;37m" [1]="\033[1;34m" [2]="\033[1;31m" [3]="\033[1;33m" [4]="\033[1;32m" )
  6. SCPdir="/etc/VPS-MX"
  7. SCPfrm="${SCPdir}/herramientas" && [[ ! -d ${SCPfrm} ]] && exit
  8. SCPinst="${SCPdir}/protocolos"&& [[ ! -d ${SCPinst} ]] && exit
  9. mportas () {
  10. unset portas
  11. portas_var=$(lsof -V -i tcp -P -n | grep -v "ESTABLISHED" |grep -v "COMMAND" | grep "LISTEN")
  12. while read port; do
  13. var1=$(echo $port | awk '{print $1}') && var2=$(echo $port | awk '{print $9}' | awk -F ":" '{print $2}')
  14. [[ "$(echo -e $portas|grep "$var1 $var2")" ]] || portas+="$var1 $var2\n"
  15. done <<< "$portas_var"
  16. i=1
  17. echo -e "$portas"
  18. }
  19. fun_ip () {
  20. MEU_IP=$(ip addr | grep 'inet' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
  21. MEU_IP2=$(wget -qO- ipv4.icanhazip.com)
  22. [[ "$MEU_IP" != "$MEU_IP2" ]] && IP="$MEU_IP2" || IP="$MEU_IP"
  23. }
  24. fun_eth () {
  25. eth=$(ifconfig | grep -v inet6 | grep -v lo | grep -v 127.0.0.1 | grep "encap:Ethernet" | awk '{print $1}')
  26. [[ $eth != "" ]] && {
  27. msg -bar
  28. echo -e "${cor[3]} $(fun_trans ${id} "Aplicar Sistema Para Mejorar Paquetes SSH?")"
  29. echo -e "${cor[3]} $(fun_trans ${id} "Opcion Para Usuarios Avanzados")"
  30. msg -bar
  31. read -p " [S/N]: " -e -i n sshsn
  32. [[ "$sshsn" = @(s|S|y|Y) ]] && {
  33. echo -e "${cor[1]} $(fun_trans ${id} "Correccion de problemas de paquetes en SSH...")"
  34. echo -e " $(fun_trans ${id} "Cual es la Tasa de RX")"
  35. echo -ne "[ 1 - 999999999 ]: "; read rx
  36. [[ "$rx" = "" ]] && rx="999999999"
  37. echo -e " $(fun_trans ${id} "Cual es la Tasa de TX")"
  38. echo -ne "[ 1 - 999999999 ]: "; read tx
  39. [[ "$tx" = "" ]] && tx="999999999"
  40. apt-get install ethtool -y > /dev/null 2>&1
  41. ethtool -G $eth rx $rx tx $tx > /dev/null 2>&1
  42. }
  43. msg -bar
  44. }
  45. }
  46. fun_bar () {
  47. comando="$1"
  48. _=$(
  49. $comando > /dev/null 2>&1
  50. ) & > /dev/null
  51. pid=$!
  52. while [[ -d /proc/$pid ]]; do
  53. echo -ne " \033[1;33m["
  54. for((i=0; i<10; i++)); do
  55. echo -ne "\033[1;31m##"
  56. sleep 0.2
  57. done
  58. echo -ne "\033[1;33m]"
  59. sleep 1s
  60. echo
  61. tput cuu1
  62. tput dl1
  63. done
  64. echo -e " \033[1;33m[\033[1;31m####################\033[1;33m] - \033[1;32m100%\033[0m"
  65. sleep 1s
  66. }
  67. fun_shadowsocks () {
  68. [[ -e /etc/shadowsocks.json ]] && {
  69. [[ $(ps x|grep ssserver|grep -v grep|awk '{print $1}') != "" ]] && kill -9 $(ps x|grep ssserver|grep -v grep|awk '{print $1}') > /dev/null 2>&1 && ssserver -c /etc/shadowsocks.json -d stop > /dev/null 2>&1
  70. echo -e "\033[1;33m $(fun_trans ${id} "SHADOWSOCKS PARADO")"
  71. msg -bar
  72. rm /etc/shadowsocks.json
  73. return 0
  74. }
  75. while true; do
  76. msg -bar
  77. msg -tit
  78. msg -ama " INSTALADOR SHADOWSOCKS By @Kalix1"
  79. msg -bar
  80. echo -e "\033[1;33m $(fun_trans ${id} "Selecione una Criptografia")"
  81. msg -bar
  82. encript=(aes-256-gcm aes-192-gcm aes-128-gcm aes-256-ctr aes-192-ctr aes-128-ctr aes-256-cfb aes-192-cfb aes-128-cfb camellia-128-cfb camellia-192-cfb camellia-256-cfb chacha20-ietf-poly1305 chacha20-ietf chacha20 rc4-md5)
  83. for((s=0; s<${#encript[@]}; s++)); do
  84. echo -e " [${s}] - ${encript[${s}]}"
  85. done
  86. msg -bar
  87. while true; do
  88. unset cript
  89. read -p "Escoja una Criptografia: " -e -i 0 cript
  90. [[ ${encript[$cript]} ]] && break
  91. echo -e "$(fun_trans ${id} "Opcion Invalida")"
  92. done
  93. encriptacao="${encript[$cript]}"
  94. [[ ${encriptacao} != "" ]] && break
  95. echo -e "$(fun_trans ${id} "Opcion Invalida")"
  96. done
  97. #ESCOLHENDO LISTEN
  98. msg -bar
  99. echo -e "\033[1;33m $(fun_trans ${id} "Seleccione puerto para el Shadowsocks Escuchar")\033[0m"
  100. msg -bar
  101. while true; do
  102. unset Lport
  103. read -p " Puerto: " Lport
  104. [[ $(mportas|grep "$Lport") = "" ]] && break
  105. echo -e " ${Lport}: $(fun_trans ${id} "Puerto Invalido")"
  106. done
  107. #INICIANDO
  108. msg -bar
  109. echo -e "\033[1;33m $(fun_trans ${id} "Ingrese la contraseña Shadowsocks")\033[0m"
  110. read -p" Contraseña: " Pass
  111. msg -bar
  112. echo -e "\033[1;33m $(fun_trans ${id} "Iniciando Instalacion")"
  113. msg -bar
  114. fun_bar 'sudo apt-get install shadowsocks -y'
  115. fun_bar 'sudo apt-get install libsodium-dev -y'
  116. fun_bar 'sudo apt-get install python-pip -y'
  117. fun_bar 'sudo pip install --upgrade setuptools'
  118. fun_bar 'pip install --upgrade pip -y'
  119. fun_bar 'pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip -U'
  120. echo -ne '{\n"server":"' > /etc/shadowsocks.json
  121. echo -ne "0.0.0.0" >> /etc/shadowsocks.json
  122. echo -ne '",\n"server_port":' >> /etc/shadowsocks.json
  123. echo -ne "${Lport},\n" >> /etc/shadowsocks.json
  124. echo -ne '"local_port":1080,\n"password":"' >> /etc/shadowsocks.json
  125. echo -ne "${Pass}" >> /etc/shadowsocks.json
  126. echo -ne '",\n"timeout":600,\n"method":"' >> /etc/shadowsocks.json
  127. echo -ne "${encriptacao}" >> /etc/shadowsocks.json
  128. echo -ne '"\n}' >> /etc/shadowsocks.json
  129. msg -bar
  130. echo -e "\033[1;31m INICIANDO\033[0m"
  131. ssserver -c /etc/shadowsocks.json -d start > /dev/null 2>&1
  132. value=$(ps x |grep ssserver|grep -v grep)
  133. [[ $value != "" ]] && value="\033[1;32mINICIADO CON EXITO" || value="\033[1;31mERROR"
  134. msg -bar
  135. echo -e "${value}"
  136. msg -bar
  137. return 0
  138. }
  139. fun_shadowsocks