script


SUBMITTED BY: Guest

DATE: June 9, 2023, 4:15 p.m.

FORMAT: Text only

SIZE: 15.4 kB

HITS: 430

  1. #!/bin/bash
  2. function msg {
  3. BRAN='\033[1;37m' && RED='\e[31m' && GREEN='\e[32m' && YELLOW='\e[33m'
  4. BLUE='\e[34m' && MAGENTA='\e[35m' && MAG='\033[1;36m' && BLACK='\e[1m' && SEMCOR='\e[0m'
  5. case $1 in
  6. -ne) cor="${RED}${BLACK}" && echo -ne "${cor}${2}${SEMCOR}" ;;
  7. -ama) cor="${YELLOW}${BLACK}" && echo -e "${cor}${2}${SEMCOR}" ;;
  8. -verm) cor="${YELLOW}${BLACK}[!] ${RED}" && echo -e "${cor}${2}${SEMCOR}" ;;
  9. -azu) cor="${MAG}${BLACK}" && echo -e "${cor}${2}${SEMCOR}" ;;
  10. -verd) cor="${GREEN}${BLACK}" && echo -e "${cor}${2}${SEMCOR}" ;;
  11. -bra) cor="${RED}" && echo -ne "${cor}${2}${SEMCOR}" ;;
  12. -nazu) cor="${COLOR[6]}${BLACK}" && echo -ne "${cor}${2}${SEMCOR}" ;;
  13. -gri) cor="\e[5m\033[1;100m" && echo -ne "${cor}${2}${SEMCOR}" ;;
  14. "-bar2" | "-bar") cor="${RED}————————————————————————————————————————————————————" && echo -e "${SEMCOR}${cor}${SEMCOR}" ;;
  15. esac
  16. }
  17. function fun_bar {
  18. comando="$1"
  19. _=$(
  20. $comando >/dev/null 2>&1
  21. ) &
  22. >/dev/null
  23. pid=$!
  24. while [[ -d /proc/$pid ]]; do
  25. echo -ne " \033[1;33m["
  26. for ((i = 0; i < 20; i++)); do
  27. echo -ne "\033[1;31m##"
  28. sleep 0.5
  29. done
  30. echo -ne "\033[1;33m]"
  31. sleep 1s
  32. echo
  33. tput cuu1
  34. tput dl1
  35. done
  36. echo -e " \033[1;33m[\033[1;31m########################################\033[1;33m] - \033[1;32m100%\033[0m"
  37. sleep 1s
  38. }
  39. function print_center {
  40. if [[ -z $2 ]]; then
  41. text="$1"
  42. else
  43. col="$1"
  44. text="$2"
  45. fi
  46. while read line; do
  47. unset space
  48. x=$(((54 - ${#line}) / 2))
  49. for ((i = 0; i < $x; i++)); do
  50. space+=' '
  51. done
  52. space+="$line"
  53. if [[ -z $2 ]]; then
  54. msg -azu "$space"
  55. else
  56. msg "$col" "$space"
  57. fi
  58. done <<<$(echo -e "$text")
  59. }
  60. function title {
  61. clear
  62. msg -bar
  63. if [[ -z $2 ]]; then
  64. print_center -azu "$1"
  65. else
  66. print_center "$1" "$2"
  67. fi
  68. msg -bar
  69. }
  70. function stop_install {
  71. [[ ! -e /bin/pweb ]] && {
  72. title "INSTALAÇÃO CANCELADA"
  73. clear
  74. cat /dev/null > ~/.bash_history && history -c
  75. rm /bin/ubuinst* > /dev/null 2>&1
  76. exit;
  77. } || {
  78. title "INSTALAÇÃO CANCELADA"
  79. clear
  80. cat /dev/null > ~/.bash_history && history -c
  81. rm /bin/ubuinst* > /dev/null 2>&1
  82. exit;
  83. }
  84. }
  85. function os_system {
  86. system=$(cat -n /etc/issue | grep 1 | cut -d ' ' -f6,7,8 | sed 's/1//' | sed 's/ //')
  87. distro=$(echo "$system" | awk '{print $1}')
  88. case $distro in
  89. Debian) vercion=$(echo $system | awk '{print $3}' | cut -d '.' -f1) ;;
  90. Ubuntu) vercion=$(echo $system | awk '{print $2}' | cut -d '.' -f1,2) ;;
  91. esac
  92. }
  93. function dependencias {
  94. soft="python bc screen at nano unzip lsof netstat net-tools dos2unix nload jq python3 python-pip"
  95. for i in $soft; do
  96. leng="${#i}"
  97. puntos=$((21 - $leng))
  98. pts="."
  99. for ((a = 0; a < $puntos; a++)); do
  100. pts+="."
  101. done
  102. msg -nazu " INSTALANDO $i$(msg -ama "$pts")"
  103. if apt install $i -y &>/dev/null; then
  104. msg -verd " INSTALADO"
  105. else
  106. msg -verm2 " ERRO"
  107. sleep 2
  108. tput cuu1 && tput dl1
  109. print_center -ama "APLICANDO FIX A $i"
  110. dpkg --configure -a &>/dev/null
  111. sleep 2
  112. tput cuu1 && tput dl1
  113. msg -nazu " INSTALANDO $i$(msg -ama "$pts")"
  114. if apt install $i -y &>/dev/null; then
  115. msg -verd " INSTALADO"
  116. else
  117. msg -verm2 " ERRO"
  118. fi
  119. fi
  120. done
  121. }
  122. function install_start {
  123. if [[ -e "/var/www/html/pages/system/pass.php" ]]; then
  124. clear
  125. msg -bar
  126. echo -e "\033[1;31mPAINEL JÁ INSTALDO EM SUA VPS, RECOMENDO\033[0m"
  127. echo -e "\033[1;31mUMA FORMATAÇÃO PARA UMA NOVA INSTALÇÃO!\033[0m"
  128. msg -bar
  129. sleep 5
  130. systemctl restart apache2 > /dev/null 2>&1
  131. cat /dev/null > ~/.bash_history && history -c
  132. rm /bin/ubuinst* > /dev/null 2>&1
  133. exit;
  134. else
  135. echo -e 'by: alanssh' >/usr/lib/telegram
  136. msg -bar
  137. echo -e "\e[1;97m \e[5m\033[1;100m ATUALIZAÇÃO DO SISTEMA \033[1;37m"
  138. msg -bar
  139. print_center -ama "O sistema será atualizado.\n Pode demorar um pouco e pedir algumas confirmações.\n"
  140. msg -bar3
  141. msg -ne "\n Você deseja continuar? [S/n]: "
  142. read opcion
  143. [[ "$opcion" != @(s|S) ]] && stop_install
  144. clear && clear
  145. os_system
  146. msg -bar
  147. echo -e "\e[1;97m \e[5m\033[1;100m ATUALIZAÇÃO DO SISTEMA \033[1;37m"
  148. msg -bar
  149. apt install software-properties-common
  150. apt update -y
  151. apt install figlet -y
  152. apt install lolcat -y
  153. apt install curl -y
  154. add-apt-repository ppa:ondrej/php -y
  155. apt update -y
  156. apt upgrade -y
  157. clear
  158. msg -bar
  159. echo -e "\e[1;97m \e[5m\033[1;100m ATUALIZAÇÃO DO SISTEMA CONCLUÍDA COM SUCESSO!\033[1;37m"
  160. msg -bar
  161. sleep 3
  162. clear
  163. fi
  164. }
  165. function install_continue {
  166. os_system
  167. msg -bar
  168. echo -e " \e[5m\033[1;100m CONCLUINDO PACOTES PARA O SCRIPT \033[1;37m"
  169. msg -bar
  170. print_center -ama "$distro $vercion"
  171. print_center -verd "INSTALANDO DEPENDÊNCIAS"
  172. msg -bar3
  173. dependencias
  174. msg -bar3
  175. print_center -azu "Removendo pacotes obsoletos"
  176. apt autoremove -y &>/dev/null
  177. sleep 2
  178. tput cuu1 && tput dl1
  179. msg -bar
  180. print_center -ama "Se algumas das dependências falharem!!!\nQuando terminar, você pode tentar instalar\no mesmo manualmente usando o seguinte comando\napt install nome_do_pacote"
  181. msg -bar
  182. read -t 60 -n 1 -rsp $'\033[1;39m << Pressione enter para continuar >>\n'
  183. }
  184. function install_continue2 {
  185. cd /bin || exit
  186. rm pweb > /dev/null 2>&1
  187. wget https://raw.githubusercontent.com/ScottBrabo/aNoobisPweb/main/raw/painel/install/pweb > /dev/null 2>&1
  188. chmod 777 pweb > /dev/null 2>&1
  189. clear
  190. [[ ! -d /bin/ppweb ]] && mkdir /bin/ppweb
  191. cd /bin/ppweb || exit
  192. rm *.sh ver* > /dev/null 2>&1
  193. wget https://raw.githubusercontent.com/ScottBrabo/aNoobisPweb/main/raw/painel/install/verifatt.sh > /dev/null 2>&1
  194. wget https://raw.githubusercontent.com/ScottBrabo/aNoobisPweb/main/raw/painel/install/verpweb > /dev/null 2>&1
  195. wget https://raw.githubusercontent.com/ScottBrabo/aNoobisPweb/main/raw/painel/install/verweb > /dev/null 2>&1
  196. verp=$(sed -n '1 p' /bin/ppweb/verpweb| sed -e 's/[^0-9]//ig') &>/dev/null
  197. verw=$(sed -n '1 p' /bin/ppweb/verweb| sed -e 's/[^0-9]//ig') &>/dev/null
  198. echo -e "$verp" >/bin/ppweb/attpweb
  199. echo -e "$verw" >/bin/ppweb/attweb
  200. chmod 777 *.sh > /dev/null 2>&1
  201. [[ ! -e /etc/autostart ]] && {
  202. echo '#!/bin/bash
  203. clear
  204. #INICIO AUTOMATICO' >/etc/autostart
  205. chmod +x /etc/autostart
  206. }
  207. }
  208. function inst_base {
  209. echo -e "\n\033[1;36mINSTALANDO O APACHE2 \033[1;33mAGUARDE...\033[0m"
  210. apt install apache2 -y > /dev/null 2>&1
  211. apt install dirmngr apt-transport-https -y > /dev/null 2>&1
  212. apt install php8.1 libapache2-mod-php8.1 php8.1-xml php8.1-mcrypt php8.1-curl php8.1-mbstring php8.1-cli -y > /dev/null 2>&1
  213. systemctl restart apache2 > /dev/null 2>&1
  214. apt-get install mariadb-server -y > /dev/null 2>&1
  215. cd || exit
  216. echo -e "\n\033[1;36mINSTALANDO O MySQL \033[1;33mAGUARDE...\033[0m"
  217. mysqladmin -u root password "$pwdroot" > /dev/null 2>&1
  218. mysql -u root -p"$pwdroot" -e "UPDATE mysql.user SET Password=PASSWORD('$pwdroot') WHERE User='root'" > /dev/null 2>&1
  219. mysql -u root -p"$pwdroot" -e "FLUSH PRIVILEGES" > /dev/null 2>&1
  220. mysql -u root -p"$pwdroot" -e "DELETE FROM mysql.user WHERE User=''" > /dev/null 2>&1
  221. mysql -u root -p"$pwdroot" -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'" > /dev/null 2>&1
  222. mysql -u root -p"$pwdroot" -e "FLUSH PRIVILEGES" > /dev/null 2>&1
  223. mysql -u root -p"$pwdroot" -e "CREATE DATABASE sshplus;" > /dev/null 2>&1
  224. mysql -u root -p"$pwdroot" -e "GRANT ALL PRIVILEGES ON sshplus.* To 'root'@'localhost' IDENTIFIED BY '$pwdroot';" > /dev/null 2>&1
  225. mysql -u root -p"$pwdroot" -e "FLUSH PRIVILEGES" > /dev/null 2>&1
  226. echo '[mysqld]
  227. max_connections = 1000' >> /etc/mysql/my.cnf
  228. apt install php8.1-mysql -y > /dev/null 2>&1
  229. phpenmod mcrypt > /dev/null 2>&1
  230. systemctl restart apache2 > /dev/null 2>&1
  231. ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin > /dev/null 2>&1
  232. apt install php8.1-ssh2 -y > /dev/null 2>&1
  233. php -m | grep ssh2 > /dev/null 2>&1
  234. curl -sS https://getcomposer.org/installer | php > /dev/null 2>&1
  235. mv composer.phar /usr/local/bin/composer > /dev/null 2>&1
  236. chmod +x /usr/local/bin/composer > /dev/null 2>&1
  237. cd /var/www/html || exit
  238. wget https://raw.githubusercontent.com/ScottBrabo/aNoobisPweb/main/raw/painel/install/gestorssh.zip > /dev/null 2>&1
  239. apt-get install unzip > /dev/null 2>&1
  240. unzip gestorssh.zip > /dev/null 2>&1
  241. (echo yes; echo yes; echo yes; echo yes) | composer install > /dev/null 2>&1
  242. (echo yes; echo yes; echo yes; echo yes) | composer require phpseclib/phpseclib:~2.0 > /dev/null 2>&1
  243. ln -s /usr/share/phpmyadmin/ /var/www/html > /dev/null 2>&1
  244. chmod 777 -R /var/www/html > /dev/null 2>&1
  245. rm gestorssh.zip index.html > /dev/null 2>&1
  246. systemctl restart mysql
  247. clear
  248. }
  249. function phpmadm {
  250. cd /usr/share || exit
  251. wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip > /dev/null 2>&1
  252. unzip phpMyAdmin-5.2.0-all-languages.zip > /dev/null 2>&1
  253. mv phpMyAdmin-5.2.0-all-languages phpmyadmin > /dev/null 2>&1
  254. chmod -R 0777 phpmyadmin > /dev/null 2>&1
  255. ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin > /dev/null 2>&1
  256. systemctl restart apache2 > /dev/null 2>&1
  257. rm phpMyAdmin-5.2.0-all-languages.zip > /dev/null 2>&1
  258. cd /root || exit
  259. }
  260. function pconf {
  261. sed "s/1020/$pwdroot/" /var/www/html/pages/system/pass.php > /tmp/pass
  262. mv /tmp/pass /var/www/html/pages/system/pass.php
  263. }
  264. function inst_db {
  265. sleep 1
  266. if [[ -e "/var/www/html/bdgestorssh.sql" ]]; then
  267. mysql -h localhost -u root -p"$pwdroot" --default_character_set utf8 sshplus < /var/www/html/bdgestorssh.sql > /dev/null 2>&1
  268. rm /var/www/html/bdgestorssh.sql > /dev/null 2>&1
  269. else
  270. clear
  271. echo -e "\033[1;31m ERRO CRÍTICO\033[0m"
  272. sleep 2
  273. systemctl restart apache2 > /dev/null 2>&1
  274. cat /dev/null > ~/.bash_history && history -c
  275. rm /bin/ubuinst* > /dev/null 2>&1
  276. clear
  277. exit;
  278. fi
  279. clear
  280. }
  281. function cron_set {
  282. crontab -l > cronset > /dev/null 2>&1
  283. echo "
  284. @reboot /etc/autostart
  285. * * * * * /etc/autostart
  286. * * * * * cd /var/www/html/pages/system/ && bash cron.userteste.sh && cd /root
  287. * * * * * /usr/bin/php /var/www/html/pages/system/cron.online.ssh.php
  288. @daily /usr/bin/php /var/www/html/pages/system/cron.rev.php
  289. * * * * * /usr/bin/php /var/www/html/pages/system/cron.ssh.php
  290. * * * * * /usr/bin/php /var/www/html/pages/system/cron.php
  291. */30 * * * * /usr/bin/php /var/www/html/pages/system/hist.online.php" > cronset
  292. crontab cronset && rm cronset > /dev/null 2>&1
  293. }
  294. function fun_swap {
  295. swapoff -a
  296. rm -rf /bin/ram.img > /dev/null 2>&1
  297. fallocate -l 4G /bin/ram.img > /dev/null 2>&1
  298. chmod 600 /bin/ram.img > /dev/null 2>&1
  299. mkswap /bin/ram.img > /dev/null 2>&1
  300. swapon /bin/ram.img > /dev/null 2>&1
  301. echo 50 > /proc/sys/vm/swappiness
  302. echo '/bin/ram.img none swap sw 0 0' | tee -a /etc/fstab > /dev/null 2>&1
  303. sleep 2
  304. }
  305. function tst_bkp {
  306. cd || exit
  307. sed -i "s;1020;$pwdroot;g" /var/www/html/lib/Database/Connection.php > /dev/null 2>&1
  308. sed -i "s;49875103u;$pwdroot;g" /var/www/html/pages/system/config.php > /dev/null 2>&1
  309. sed -i "s;localhost;$IP;g" /var/www/html/pages/system/config.php > /dev/null 2>&1
  310. }
  311. clear
  312. install_start
  313. IP=$(wget -qO- ipv4.icanhazip.com)
  314. echo "America/Sao_Paulo" > /etc/timezone > /dev/null 2>&1
  315. ln -fs /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime > /dev/null 2>&1
  316. dpkg-reconfigure --frontend noninteractive tzdata > /dev/null 2>&1
  317. clear
  318. echo -e "\E[44;1;37m INSTALANDO PAINEL \E[0m"
  319. echo ""
  320. figlet "ALAN-PWEB" | lolcat
  321. echo -e " \033[1;31mFt: @scottssh\033[1;36m"
  322. echo ""
  323. chave=$(curl -sSL "https://raw.githubusercontent.com/ScottBrabo/aNoobisPweb/main/raw/painel/install/chave") &>/dev/null
  324. read -p "DIGITE A CHAVE DE INSTALAÇÃO: " key
  325. if [[ "$key" = "$chave" ]]
  326. then
  327. echo -e "[*] VALIDANDO A CHAVE DE INSTALAÇÃO"
  328. sleep 2
  329. echo $key > /bin/chave_inst
  330. echo -e "[*] CHAVE ACEITA"
  331. sleep 2
  332. else
  333. echo "[-] ESSA CHAVE NÃO É VÁLIDA!"
  334. sleep 3
  335. clear
  336. cat /dev/null > ~/.bash_history && history -c
  337. rm /bin/ubuinst* > /dev/null 2>&1
  338. exit;
  339. fi
  340. install_continue
  341. install_continue2
  342. [[ $(grep -c "prohibit-password" /etc/ssh/sshd_config) != '0' ]] && {
  343. sed -i "s/prohibit-password/yes/g" /etc/ssh/sshd_config
  344. } > /dev/null
  345. [[ $(grep -c "without-password" /etc/ssh/sshd_config) != '0' ]] && {
  346. sed -i "s/without-password/yes/g" /etc/ssh/sshd_config
  347. } > /dev/null
  348. [[ $(grep -c "#PermitRootLogin" /etc/ssh/sshd_config) != '0' ]] && {
  349. sed -i "s/#PermitRootLogin/PermitRootLogin/g" /etc/ssh/sshd_config
  350. } > /dev/null
  351. [[ $(grep -c "PasswordAuthentication" /etc/ssh/sshd_config) = '0' ]] && {
  352. echo 'PasswordAuthentication yes' > /etc/ssh/sshd_config
  353. } > /dev/null
  354. [[ $(grep -c "PasswordAuthentication no" /etc/ssh/sshd_config) != '0' ]] && {
  355. sed -i "s/PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  356. } > /dev/null
  357. [[ $(grep -c "#PasswordAuthentication no" /etc/ssh/sshd_config) != '0' ]] && {
  358. sed -i "s/#PasswordAuthentication no/PasswordAuthentication yes/g" /etc/ssh/sshd_config
  359. } > /dev/null
  360. echo ""
  361. figlet "ALAN-PWEB" | lolcat
  362. echo -e " \033[1;31mFt: @scottssh\033[1;36m"
  363. echo ""
  364. echo -e "\033[1;36mDEFINA UMA NOVA SENHA PARA\033[0m"
  365. echo -e "\033[1;36mO USUÁRIO ROOT DA VPS E\033[0m"
  366. echo -e "\033[1;36mPARA O USUÁRIO DO PHPMYADMIN!\033[0m"
  367. echo ""
  368. read -p "DIGITE UMA NOVA SENHA ROOT: " pwdroot
  369. echo "root:$pwdroot" | chpasswd
  370. echo -e "\n\033[1;36mINICIANDO INSTALAÇÃO \033[1;33mAGUARDE..."
  371. sleep 3
  372. clear
  373. inst_base
  374. phpmadm
  375. pconf
  376. inst_db
  377. cron_set
  378. fun_swap
  379. tst_bkp
  380. clear
  381. sed -i "s;upload_max_filesize = 2M;upload_max_filesize = 256M;g" /etc/php/8.1/apache2/php.ini > /dev/null 2>&1
  382. sed -i "s;post_max_size = 8M;post_max_size = 256M;g" /etc/php/8.1/apache2/php.ini > /dev/null 2>&1
  383. figlet "ALAN-PWEB" | lolcat
  384. echo -e " \033[1;31mFt: @scottssh\033[1;36m"
  385. echo ""
  386. echo -e "\033[1;32mPAINEL INSTALADO COM SUCESSO!"
  387. echo ""
  388. echo -e "------------------------------------------------------" | lolcat
  389. echo -e "\033[1;36m 🚀SEU PAINEL:\033[1;37m http://$IP/admin\033[0m"
  390. echo -e "\033[1;36m 👤USUÁRIO:\033[1;37m admin\033[0m"
  391. echo -e "\033[1;36m 🔑SENHA:\033[1;37m admin\033[0m"
  392. echo ""
  393. echo -e "\033[1;36m ⬇️LOJA DE APPS:\033[1;37m http://$IP/apps\033[0m"
  394. echo ""
  395. echo -e "\033[1;36m 💼PHPMYADMIN:\033[1;37m http://$IP/phpmyadmin\033[0m"
  396. echo -e "\033[1;36m 👤USUÁRIO:\033[1;37m root\033[0m"
  397. echo -e "\033[1;36m 🔑SENHA:\033[1;37m $pwdroot\033[0m"
  398. echo -e "------------------------------------------------------" | lolcat
  399. echo ""
  400. echo -e "\033[1;31m \033[1;33mCOMANDO PRINCIPAL: \033[1;32mpweb\033[0m"
  401. echo -e "\033[1;33m MAIS INFORMAÇÕES \033[1;31m(\033[1;36mTELEGRAM\033[1;31m): \033[1;37m@scottssh\033[0m"
  402. echo ""
  403. echo -ne "\n\033[1;31mENTER \033[1;33mpara retornar...\033[1;32m! \033[0m"; read
  404. systemctl restart apache2 > /dev/null 2>&1
  405. systemctl restart mysql > /dev/null 2>&1
  406. cat /dev/null > ~/.bash_history && history -c
  407. rm /bin/ubuinst* > /dev/null 2>&1
  408. clear

comments powered by Disqus