ssl 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #/bin/bash
  2. sshports=`netstat -tunlp | grep sshd | grep 0.0.0.0: | awk '{print substr($4,9); }' > /tmp/ssh.txt && echo | cat /tmp/ssh.txt | tr '\n' ' ' > /etc/adm-lite/sshports.txt && cat /etc/adm-lite/sshports.txt`;
  3. mportas () {
  4. unset portas
  5. portas_var=$(lsof -V -i tcp -P -n | grep -v "ESTABLISHED" |grep -v "COMMAND" | grep "LISTEN")
  6. while read port; do
  7. var1=$(echo $port | awk '{print $1}') && var2=$(echo $port | awk '{print $9}' | awk -F ":" '{print $2}')
  8. [[ "$(echo -e $portas|grep "$var1 $var2")" ]] || portas+="$var1 $var2\n"
  9. done <<< "$portas_var"
  10. i=1
  11. echo -e "$portas"
  12. }
  13. fun_bar () {
  14. comando[0]="$1"
  15. comando[1]="$2"
  16. (
  17. [[ -e $HOME/fim ]] && rm $HOME/fim
  18. ${comando[0]} -y > /dev/null 2>&1
  19. ${comando[1]} -y > /dev/null 2>&1
  20. touch $HOME/fim
  21. ) > /dev/null 2>&1 &
  22. echo -ne "\033[1;33m ["
  23. while true; do
  24. for((i=0; i<18; i++)); do
  25. echo -ne "\033[1;31m##"
  26. sleep 0.1s
  27. done
  28. [[ -e $HOME/fim ]] && rm $HOME/fim && break
  29. echo -e "\033[1;33m]"
  30. sleep 1s
  31. tput cuu1
  32. tput dl1
  33. echo -ne "\033[1;33m ["
  34. done
  35. echo -e "\033[1;33m]\033[1;31m -\033[1;32m 100%\033[1;37m"
  36. }
  37. sleep 1
  38. fun_bar 'apt-get update -y' 'yum update -y'
  39. fun_bar 'apt-get install openssh-server -y' 'apt-get install curl -y'
  40. fun_bar 'yum install openssh-server -y' 'apt-get install openssh-client -y'
  41. fun_bar 'yum install openssh-client -y' 'apt-get install stunnel4 -y'
  42. fun_bar 'yum install stunnel4 -y'
  43. fun_bar 'apt-get install stunnel -y' 'yum install stunnel -y'
  44. ip=$(curl https://api.ipify.org/)
  45. echo -e "Paquetes Instalados"
  46. sleep 1
  47. openssl genrsa 2048 > stunnel.key
  48. openssl req -new -key stunnel.key -x509 -days 1000 -out stunnel.crt
  49. sleep 1
  50. rm /etc/stunnel/stunnel.conf
  51. clear
  52. rm /etc/default/stunnel4
  53. clear
  54. cat stunnel.crt stunnel.key > stunnel.pem
  55. mv stunnel.pem /etc/stunnel/
  56. clear
  57. sslports=`netstat -tunlp | grep stunnel4 | grep 0.0.0.0: | awk '{print substr($4,9); }' > /tmp/ssl.txt && echo | cat /tmp/ssl.txt | tr '\n' ' ' > /etc/adm-lite/sslports.txt && cat /etc/adm-lite/sslports.txt`;
  58. cowsay -f stegosaurus "BIENVENIDO Y GRACIAS POR UTILIZAR ⌐╦╦═─ ☆ CHUMOGH ☆ ADM SCRIPT "| lolcat
  59. echo -e "${cor[1]}=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠" | lolcat
  60. echo -e "${cor[2]}STUNNEL ACTIVO en Puertos: $sslports " | lolcat
  61. echo -e "${cor[1]}=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠" | lolcat
  62. echo -e "\033[1;33m Selecione un Puerto De Redirecionamento Interna"
  63. echo -e "\033[1;33m Ingrese su Puerta Servidor Para o SSL/TLS"
  64. echo -e "$barra"
  65. pt=$(netstat -nplt |grep 'sshd' | awk -F ":" NR==1{'print $2'} | cut -d " " -f 1)
  66. while true; do
  67. echo -ne "\033[1;37m"
  68. echo " Ingresa el Puerto Local de tu VPS (Default 22) "
  69. read -p " Local-Port: " -e -i $pt portx
  70. tput cuu1 >&2 && tput dl1 >&2
  71. [[ $(mportas | grep $portx) ]] && break
  72. echo -e "\033[1;33m El puerto seleccionado no existe"
  73. unset portx
  74. echo -e "$barra"
  75. done
  76. echo -e "$barra"
  77. DPORT="$(mportas|grep $portx|awk '{print $2}'|head -1)"
  78. echo -e "\033[1;33m Digite el Puerto SSL, que Va a USAR:"
  79. echo -e "$barra"
  80. while true; do
  81. echo -ne "\033[1;37m"
  82. echo " Ingresa Puerto SSl/TLS a USAR (Recomendado 110-442-444) "
  83. read -p " Listen-SSL: " SSLPORT
  84. tput cuu1 >&2 && tput dl1 >&2
  85. [[ $(mportas | grep $SSLPORT) ]] || break
  86. echo -e "\033[1;33m El puerto seleccionado ya se encuentra en uso"
  87. unset SSLPORT
  88. echo -e "$barra"
  89. done
  90. echo -e "$barra"
  91. clear
  92. echo "client = no " >> /etc/stunnel/stunnel.conf
  93. echo "[ssh] " >> /etc/stunnel/stunnel.conf
  94. echo "cert = /etc/stunnel/stunnel.pem " >> /etc/stunnel/stunnel.conf
  95. echo "accept = $SSLPORT " >> /etc/stunnel/stunnel.conf
  96. echo "connect = 127.0.0.1:$portx" >> /etc/stunnel/stunnel.conf
  97. sleep 1
  98. echo "ENABLED=1 " >> /etc/default/stunnel4
  99. echo "FILES="/etc/stunnel/*.conf" " >> /etc/default/stunnel4
  100. echo "OPTIONS="" " >> /etc/default/stunnel4
  101. echo "PPP_RESTART=0" >> /etc/default/stunnel4
  102. echo -e "\033[1;33m Instalando SSL/TLS [ $portx -> $SSLPORT ] : $(curl -sSL ipinfo.io > info && cat info | grep country | awk '{print $2}' | sed -e 's/[^a-z0-9 -]//ig')"
  103. service stunnel4 restart
  104. sslports=`netstat -tunlp | grep stunnel4 | grep 0.0.0.0: | awk '{print substr($4,9); }' > /tmp/ssl.txt && echo | cat /tmp/ssl.txt | tr '\n' ' ' > /etc/adm-lite/sslports.txt && cat /etc/adm-lite/sslports.txt`;
  105. echo -e "${cor[1]}=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠" | lolcat
  106. echo -e "${cor[2]}STUNNEL ACTIVO en Puertos:" $sslports " Escojido " $port | lolcat
  107. echo -e "${cor[1]}=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠=≠" | lolcat
  108. echo -e "\033[1;34m #####################################################"
  109. echo -e "\033[1;37m I N I C I A N D O - STUNNEL4 - SSL/TLS Custom Cert"
  110. echo -e "\033[1;34m #####################################################"
  111. sleep 1
  112. echo -ne "REINICIANDO SERIVICIOS" &&
  113. ( service ssh restart 1>/dev/null 2 /dev/null
  114. service stunnel4 start 1>/dev/null 2 /dev/null
  115. service stunnel4 restart 1>/dev/null 2 /dev/null ) && echo "OK" || echo "FAILS"
  116. echo -e "\033[1;34m ###################################"
  117. echo -e "\033[1;31mCONFIGURACION SSL ACEPTADA CON EXITO"
  118. echo -e "\033[1;34m ###################################"
  119. echo -e "SU IP HOST DEL SERVIDOR:\033[1;30m $ip"
  120. echo -e "Reinicie su VPS (Opcional) - sudo reboot"
  121. read -p " Presiona ENTER para continuar"