sockspy.sh 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #!/bin/bash
  2. #19/05/2020
  3. clear
  4. msg -bar
  5. stop_all () {
  6. ck_py=$(lsof -V -i tcp -P -n | grep -v "ESTABLISHED" |grep -v "COMMAND"|grep "python")
  7. if [[ -z $(echo "$ck_py" | awk '{print $1}' | head -n 1) ]]; then
  8. print_center -verm "Puertos PYTHON no encontrados"
  9. msg -bar
  10. else
  11. ck_port=$(echo "$ck_py" | awk '{print $9}' | awk -F ":" '{print $2}')
  12. for i in $ck_port; do
  13. systemctl stop python.${i} &>/dev/null
  14. systemctl disable python.${1} &>/dev/null
  15. rm /etc/systemd/system/python.${i}.service &>/dev/null
  16. done
  17. print_center -verd "Puertos PYTHON detenidos"
  18. msg -bar
  19. fi
  20. sleep 3
  21. }
  22. stop_port () {
  23. clear
  24. STPY=$(lsof -V -i tcp -P -n | grep -v "ESTABLISHED" |grep -v "COMMAND"|grep "python" | awk '{print $9}' | awk -F ":" '{print $2}')
  25. msg -bar
  26. print_center -ama "DETENER UN PUERTO"
  27. msg -bar
  28. n=1
  29. for i in $STPY; do
  30. echo -e " \033[1;32m[$n] \033[1;31m> \033[1;37m$i\033[0m"
  31. pypr[$n]=$i
  32. let n++
  33. done
  34. msg -bar
  35. echo -ne "$(msg -verd " [0]") $(msg -verm2 ">") " && msg -bra "\033[1;41mVOLVER"
  36. msg -bar
  37. echo -ne "\033[1;37m opcion: " && read prpy
  38. tput cuu1 && tput dl1
  39. [[ $prpy = "0" ]] && return
  40. systemctl stop python.${pypr[$prpy]} &>/dev/null
  41. systemctl disable python.${pypr[$prpy]} &>/dev/null
  42. rm /etc/systemd/system/python.${pypr[$prpy]}.service &>/dev/null
  43. print_center -verd "PUERTO PYTHON ${pypr[$prpy]} detenido"
  44. msg -bar
  45. sleep 3
  46. }
  47. colector(){
  48. clear
  49. msg -bar
  50. print_center -azu "Selecciona Puerto Principal, para Proxy"
  51. msg -bar
  52. while [[ -z $porta_socket ]]; do
  53. echo -ne "\033[1;37m Digite el Puerto: " && read porta_socket
  54. tput cuu1 && tput dl1
  55. [[ $(mportas|grep -w "${porta_socket}") = "" ]] && {
  56. echo -e "\033[1;33m $(fun_trans "Puerto python:")\033[1;32m ${porta_socket} OK"
  57. msg -bar3
  58. } || {
  59. echo -e "\033[1;33m $(fun_trans "Puerto python:")\033[1;31m ${porta_socket} FAIL" && sleep 2
  60. tput cuu1 && tput dl1
  61. unset porta_socket
  62. }
  63. done
  64. if [[ $1 = "PDirect" ]]; then
  65. print_center -azu "Selec Puerto Local SSH/DROPBEAR/OPENVPN"
  66. msg -bar3
  67. while [[ -z $local ]]; do
  68. echo -ne "\033[1;97m Digite el Puerto: \033[0m" && read local
  69. tput cuu1 && tput dl1
  70. [[ $(mportas|grep -w "${local}") = "" ]] && {
  71. echo -e "\033[1;33m $(fun_trans "Puerto local:")\033[1;31m ${local} FAIL" && sleep 2
  72. tput cuu1 && tput dl1
  73. unset local
  74. } || {
  75. echo -e "\033[1;33m $(fun_trans "Puerto local:")\033[1;32m ${local} OK"
  76. msg -bar3
  77. }
  78. done
  79. print_center -azu "Response personalizado (enter por defecto 200)"
  80. print_center -ama "NOTA : Para OVER WEBSOCKET escribe (101)"
  81. msg -bar3
  82. echo -ne "\033[1;97m Digite un Response: \033[0m" && read response
  83. tput cuu1 && tput dl1
  84. if [[ -z $response ]]; then
  85. response="200"
  86. echo -e "\033[1;33m $(fun_trans "Response:")\033[1;32m ${response} OK"
  87. else
  88. echo -e "\033[1;33m $(fun_trans "Response:")\033[1;32m ${response} OK"
  89. fi
  90. msg -bar3
  91. fi
  92. if [[ ! $1 = "PGet" ]] && [[ ! $1 = "POpen" ]]; then
  93. print_center -azu "Introdusca su Mini-Banner"
  94. msg -bar3
  95. print_center -azu "Introduzca un texto [Plano] o en [HTML]"
  96. echo ""
  97. read texto_soket
  98. fi
  99. if [[ $1 = "PPriv" ]]; then
  100. py="python3"
  101. IP=$(fun_ip)
  102. elif [[ $1 = "PGet" ]]; then
  103. echo "master=NetVPS" > ${ADM_tmp}/pwd.pwd
  104. while read service; do
  105. [[ -z $service ]] && break
  106. echo "127.0.0.1:$(echo $service|cut -d' ' -f2)=$(echo $service|cut -d' ' -f1)" >> ${ADM_tmp}/pwd.pwd
  107. done <<< "$(mportas)"
  108. porta_bind="0.0.0.0:$porta_socket"
  109. pass_file="${ADM_tmp}/pwd.pwd"
  110. py="python"
  111. else
  112. py="python"
  113. fi
  114. [[ ! -z $porta_bind ]] && conf="-b $porta_bind "|| conf="-p $porta_socket "
  115. [[ ! -z $pass_file ]] && conf+="-p $pass_file"
  116. [[ ! -z $local ]] && conf+="-l $local "
  117. [[ ! -z $response ]] && conf+="-r $response "
  118. [[ ! -z $IP ]] && conf+="-i $IP "
  119. [[ ! -z $texto_soket ]] && conf+="-t '$texto_soket'"
  120. echo -e "[Unit]
  121. Description=$1 Service by @Rufu99
  122. After=network.target
  123. StartLimitIntervalSec=0
  124. [Service]
  125. Type=simple
  126. User=root
  127. WorkingDirectory=/root
  128. ExecStart=/usr/bin/$py ${ADM_inst}/$1.py $conf
  129. Restart=always
  130. RestartSec=3s
  131. [Install]
  132. WantedBy=multi-user.target" > /etc/systemd/system/python.$porta_socket.service
  133. systemctl enable python.$porta_socket &>/dev/null
  134. systemctl start python.$porta_socket &>/dev/null
  135. if [[ $1 = "PGet" ]]; then
  136. [[ "$(ps x | grep "PGet.py" | grep -v "grep" | awk -F "pts" '{print $1}')" ]] && {
  137. print_center -verd "$(fun_trans "Gettunel Iniciado com Exito")"
  138. print_center -azu "$(fun_trans "Su Contraseña Gettunel es"): $(msg -ama "NetVPS")"
  139. msg -bar3
  140. } || {
  141. print_center -verm2 "$(fun_trans "Gettunel no fue iniciado")"
  142. msg -bar3
  143. }
  144. fi
  145. msg -bar
  146. print_center -verd "PYTHON INICIADO CON EXITO!!!"
  147. msg -bar
  148. sleep 3
  149. }
  150. iniciarsocks () {
  151. pidproxy=$(ps x | grep -w "PPub.py" | grep -v "grep" | awk -F "pts" '{print $1}') && [[ ! -z $pidproxy ]] && P1="\033[1;32m[ON]" || P1="\033[1;31m[OFF]"
  152. pidproxy2=$(ps x | grep -w "PPriv.py" | grep -v "grep" | awk -F "pts" '{print $1}') && [[ ! -z $pidproxy2 ]] && P2="\033[1;32m[ON]" || P2="\033[1;31m[OFF]"
  153. pidproxy3=$(ps x | grep -w "PDirect.py" | grep -v "grep" | awk -F "pts" '{print $1}') && [[ ! -z $pidproxy3 ]] && P3="\033[1;32m[ON]" || P3="\033[1;31m[OFF]"
  154. pidproxy4=$(ps x | grep -w "POpen.py" | grep -v "grep" | awk -F "pts" '{print $1}') && [[ ! -z $pidproxy4 ]] && P4="\033[1;32m[ON]" || P4="\033[1;31m[OFF]"
  155. pidproxy5=$(ps x | grep "PGet.py" | grep -v "grep" | awk -F "pts" '{print $1}') && [[ ! -z $pidproxy5 ]] && P5="\033[1;32m[ON]" || P5="\033[1;31m[OFF]"
  156. pidproxy6=$(ps x | grep "scktcheck" | grep -v "grep" | awk -F "pts" '{print $1}') && [[ ! -z $pidproxy6 ]] && P6="\033[1;32m[ON]" || P6="\033[1;31m[OFF]"
  157. print_center -ama "$(fun_trans "INSTALADOR SOCKS PYTHON")"
  158. msg -bar
  159. echo -ne "$(msg -verd " [1]") $(msg -verm2 ">") " && msg -azu "Socks Python SIMPLE $P1"
  160. echo -ne "$(msg -verd " [2]") $(msg -verm2 ">") " && msg -azu "Socks Python SEGURO $P2"
  161. echo -ne "$(msg -verd " [3]") $(msg -verm2 ">") " && msg -azu "Socks Python DIRETO $P3"
  162. echo -ne "$(msg -verd " [4]") $(msg -verm2 ">") " && msg -azu "Socks Python OPENVPN $P4"
  163. echo -ne "$(msg -verd " [5]") $(msg -verm2 ">") " && msg -azu "Socks Python GETTUNEL $P5"
  164. msg -bar
  165. py=6
  166. if [[ $(lsof -V -i tcp -P -n|grep -v "ESTABLISHED"|grep -v "COMMAND"|grep "python"|wc -l) -ge "2" ]]; then
  167. echo -e "$(msg -verd " [6]") $(msg -verm2 ">") $(msg -azu "DETENER TODOS") $(msg -verd " [7]") $(msg -verm2 ">") $(msg -azu "DETENER UN PUERTO")"
  168. py=7
  169. else
  170. echo -e "$(msg -verd " [6]") $(msg -verm2 ">") $(msg -azu "DETENER TODOS")"
  171. fi
  172. msg -bar
  173. echo -ne "$(msg -verd " [0]") $(msg -verm2 ">") " && msg -bra " \033[1;41m VOLVER \033[0m"
  174. msg -bar
  175. selection=$(selection_fun ${py})
  176. case ${selection} in
  177. 1)colector PPub;;
  178. 2)colector PPriv;;
  179. 3)colector PDirect;;
  180. 4)colector POpen;;
  181. 5)colector PGet;;
  182. 6)stop_all;;
  183. 7)stop_port;;
  184. 0)return 1;;
  185. esac
  186. return 1
  187. }
  188. iniciarsocks