Script revisão


SUBMITTED BY: cleitongabriel

DATE: Dec. 18, 2023, 5:31 p.m.

UPDATED: Dec. 20, 2023, 6:52 p.m.

FORMAT: Text only

SIZE: 16.5 kB

HITS: 506

  1. #!/usr/bin/python
  2. # -*- codificação: utf-8 -*-
  3. importar subprocesso, os, random, string, sys, shutil, socket
  4. do ciclo de importação do itertools, izip
  5. rDownloadURL = {"principal": "https://xtreamui.net/ck/main_xtreamcodes_reborn.tar.gz", "sub": "https://xtreamui.net/ck/sub_xtreamcodes_reborn.tar.gz" }
  6. rPackages = ["libcurl3", "libxslt1-dev", "libgeoip-dev", "e2fsprogs", "wget", "mcrypt", "nscd", "htop", "zip" ;, "descompactar", "mc", "servidor mysql"]
  7. rInstall = {"MAIN": "principal", "LB": "sub"}
  8. rMySQLCnf = "IyBYdHJlYW0gQ29kZXMKCltjbGllbnRdCnBvcnQgICAgICAgICAgICA9IDMzMDYKCltteXNxbGRfc2FmZV0KbmljZSAgICAgICAgICAgID0gMAoKW215c3FsZF0KdXNlciAgICAgICAgICAgID0gbX lzcWwKcG9ydCAgICAgICAgICAgID0gNzk5OQpiYXNlZGlyICAgICAgICAgPSAvdXNyCmRhdGFkaXIgICAgICAgICA9IC92YXIvbGliL215c3FsCnRtcGRpciAgICAgICAgICA9IC90bXAKbGMtbWVzc2FnZXMtZGlyID 0gL3Vzci9zaGFyZS9teXNxbApza2lwLWV4dGVybmFsLWxvY2tpbmcKc2tpcC1uYW1lLXJlc29sdmU9MQoKYmluZC1hZGRyZXNzICAgICAgICAgICAgPSAqCmtleV9idWZmZXJfc2l6ZSA9IDEyOE0KC m15aXNhbV9zb3J0X2J1ZmZlcl9zaXplID0gNE0KbWF4X2FsbG93ZWRfcGFja2V0ICAgICAgPSA2NE0KbXlpc2FtLXJlY292ZXItb3B0aW9ucyA9IEJBQ0tVUAptYXhfbGVuZ3RoX2Zvcl9zb3J0X2 RhdGEgPSA4MTkyCnF1ZXJ5X2NhY2hlX2xpbWl0ICAgICAgID0gNE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10Ka2V5X2J1ZmZlcl9zaXplICAgICAgICAgICAgICA9IDE2TQo=".decode("base64")
  9. coluna de classe:
  10. CABEÇALHO = '\033[95m'
  11. OKAZUL = '\033[94m'
  12. OKVERDE = '\033[92m'
  13. AVISO = '\033[93m'
  14. FALHA = '\033[91m'
  15. ENDC = '\033[0m'
  16. NEGRO = '\033[1m'
  17. SUBLINHADO = '\033[4m'
  18. def gerar (comprimento = 16): retornar ''.join (random.choice (string.ascii_letters + string.digits) para i no intervalo (comprimento))
  19. def getIP():
  20. s = soquete.socket(socket.AF_INET, soquete.SOCK_DGRAM)
  21. s.connect(("8.8.8.8", 80))
  22. retornar s.getsockname()[0]
  23. def getVersão():
  24. tente: return subprocess.check_output("lsb_release -d".split()).split(":")[-1].strip()
  25. exceto: retornar "
  26. def printc(rText, rColour=col.OKBLUE, rPadding=0):
  27. imprimir "%s ┌────────────────────────────────────── ────┐% é" % (rCor, col.ENDC)
  28. para i no intervalo (rPadding): imprime "%s │ │ %s" % (rCor, col.ENDC)
  29. imprima "%s │ %s%s%s │ %s" % (rColour, " "*(20-(len(rText)/2)), rText, " "*(40-(20-(len(rText)/2))-len(rText)) , col.ENDC)
  30. para i no intervalo (rPadding): imprime "%s │ │ %s" % (rCor, col.ENDC)
  31. imprimir "%s └────────────────────────────────────── ────┘% é" % (rCor, col.ENDC)
  32. imprimir " "
  33. def prepare(rType="MAIN"):
  34. rPackages globais
  35. se rType <> "PRINCIPAL": rPackages = rPackages[:-1]
  36. printc("Preparando a Instalação")
  37. para rFile em ["/var/lib/dpkg/lock-frontend", "/var/cache/apt/archives/lock", "/var/lib/dpkg/lock"]:
  38. tente: os.remove(rFile)
  39. exceto: passar
  40. os.system("apt-get update> /dev/null")
  41. printc("Removendo libcurl4 se instalado")
  42. os.system("apt-get remove --auto-remove libcurl4 -y > /dev/null")
  43. para rPackage em rPackages:
  44. printc("Instalando %s" % rPackage)
  45. os.system("apt-get install %s -y > /dev/null" % rPackage)
  46. printc("Instalando libpng")
  47. os.system("wget -q -O /tmp/libpng12.deb https://xtreamui.net/ck/libpng12-0_1.2.54-1ubuntu1_amd64.deb")
  48. os.system("dpkg -i /tmp/libpng12.deb > /dev/null")
  49. os.system("apt-get install -y > /dev/null") # Limpe acima
  50. tente: os.remove("/tmp/libpng12.deb")
  51. exceto: passar
  52. tentar:
  53. subprocess.check_output("getent passwd xtreamcodes> /dev/null".split())
  54. exceto:
  55. # Criar usuário
  56. printc("Criando xtreamcodes de usuário")
  57. os.system("adduser --system --shell /bin/false --group --disabled-login xtreamcodes > /dev/null")
  58. se não, os.path.exists("/home/xtreamcodes"): os.mkdir("/home/xtreamcodes")
  59. retornar verdadeiro
  60. def install(rType="MAIN"):
  61. instalação global, rDownloadURL
  62. printc("Baixando Software")
  63. tente: rURL = rDownloadURL[rInstall[rType]]
  64. exceto:
  65. printc("URL de download inválido!", col.FAIL)
  66. retorna falso
  67. os.system('wget -q -O "/tmp/xtreamcodes.tar.gz" "%s"' % rURL)
  68. se os.path.exists("/tmp/xtreamcodes.tar.gz"):
  69. printc("Instalando Software")
  70. os.system('tar -zxvf "/tmp/xtreamcodes.tar.gz" -C "/home/xtreamcodes/" > /dev/null')
  71. tente: os.remove("/tmp/xtreamcodes.tar.gz")
  72. exceto: passar
  73. retornar verdadeiro
  74. printc("Falha ao baixar o arquivo de instalação!", col.FAIL)
  75. retorna falso
  76. def mysql(rNome de usuário, rSenha):
  77. rMySQLCnf global
  78. printc("Configurando MySQL")
  79. rCriar = Verdadeiro
  80. se os.path.exists("/etc/mysql/my.cnf"):
  81. if open("/etc/mysql/my.cnf", "r").read(14) == "# Códigos Xtream": rCreate = False
  82. se rCreate:
  83. shutil.copy("/etc/mysql/my.cnf", "/etc/mysql/my.cnf.xc")
  84. rFile = open("/etc/mysql/my.cnf", "w")
  85. rFile.write(rMySQLCnf)
  86. rArquivo.close()
  87. os.system("service mysql restart > /dev/null")
  88. printc("Digite a senha raiz do MySQL:", col.WARNING)
  89. para i no intervalo (5):
  90. rMySQLRoot = raw_input(" ")
  91. imprimir " "
  92. if len(rMySQLRoot) > 0: rExtra = " -p%s" % rMySQLRoot
  93. senão: rExtra = ""
  94. printc("Descartar banco de dados existente e criar? S/N", col.WARNING)
  95. if raw_input(" ").upper() == "Y": rDrop = True
  96. senão: rDrop = Falso
  97. tentar:
  98. se rDrop:
  99. os.system('mysql -u root%s -e "DROP DATABASE SE EXISTE xtream_iptvpro; CRIAR BANCO DE DADOS SE NÃO EXISTE xtream_iptvpro; > /dev/null' % rExtra)
  100. os.system("mysql -u root%s xtream_iptvpro < /home/xtreamcodes/iptv_xtream_codes/database.sql > /dev/null" % rExtra)
  101. os.system('mysql -u root%s -e "USE xtream_iptvpro; UPDATE configurações SET live_streaming_pass = \'%s\', unique_id = \'%s\& #39;, crypt_load_balancing = \'%s\';" > /dev/null' % (rExtra, gerar(20), gerar(10), gerar(20)))
  102. os.system('mysql -u root%s -e "USE xtream_iptvpro; REPLACE INTO streaming_servers (id, server_name, domain_name, server_ip, vpn_ip, ssh_password, ssh_port, diff_time_main, http_broadcast_port, total_clients, system_os, network_interface, latência , status, enable_geoip, geoip_countries, last_check_ago, can_delete, server_hardware, total_services, persistente_connections, rtmp_port, geoip_type, isp_names, isp_type, enable_isp, boost_fpm, http_ports_add, network_guaranteed_speed, https_broadcast_port, https_ports_add, whitelist_ips, watchdog_data, timeshift_only) VA LUES (1, \ 39;Servidor Principal\', \'\', \'%s\', \'\', NULL, NULL, 0 , 25461, 1000, \'%s\', \'eth0\', 0, 1, 0, \'\', 0, 0 , \'{}\', 3, 0, 25462, \'baixa_prioridade\', \'\', \'baixa_prioridade\ ', 0, 1, \'\', 1000, 25463, \'\', \'[\"127.0.0.1\" ,\"\"]\', \'{}\', 0);" > /dev/null' % (rExtra, getIP(), getVersion ()))
  103. os.system('mysql -u root%s -e "USE xtream_iptvpro; REPLACE INTO reg_users (id, nome de usuário, senha, email, member_group_id, verificado, status) VALORES (1, \'admin\ ', \'\$6\$rounds=20000\$xtreamcodes\$XThC5OwfuS0YwS4ahiifzF14vkGbGsFF1w7ETL4sRRC5sOrAWCjWvQJDromZUQoQuwbAXAFdX3h3Cp3vqulpS0\', \'admin@website.com\ ', 1, 1, 1 );" > /dev/null' % rExtra)
  104. os.system('mysql -u root%s -e "CONCEDER TODOS OS PRIVILÉGIOS EM *.* PARA \'%s\'@\'%%\' ; IDENTIFICADO POR \'%s\' COM GRANT OPTION; FLUSH PRIVILEGES;" > /dev/null' % (rExtra, rUsername, rPassword))
  105. tente: os.remove("/home/xtreamcodes/iptv_xtream_codes/database.sql")
  106. exceto: passar
  107. retornar verdadeiro
  108. exceto: printc("Senha inválida! Tente novamente", col.FAIL)
  109. retorna falso
  110. def criptografar(rHost="127.0.0.1", rUsername="user_iptvpro", rPassword="", rDatabase="xtream_iptvpro", rServerID=1, rPort=7999):
  111. printc("Criptografando...")
  112. tente: os.remove("/home/xtreamcodes/iptv_xtream_codes/config")
  113. exceto: passar
  114. rf = open('/home/xtreamcodes/iptv_xtream_codes/config', 'wb')
  115. rf.write(''.join(chr(ord(c)^ord(k)) for c,k in izip('{\"host\":\" %s\",\"db_user\":\"%s\",\"db_pass\":\"%s\",\"db_name\":\" ;%s\",\"server_id\":\"%d\", \"db_port\":\"%d\"}' % (rHost, rUsername , rPassword, rDatabase, rServerID, rPort), ciclo('5709650b0d7806074842c6de575025b1'))).encode('base64').replace('\n', ' 39;'))
  116. rf.fechar()
  117. def configurar():
  118. printc("Configurando o Sistema")
  119. se não "/home/xtreamcodes/iptv_xtream_codes/" em open("/etc/fstab").read():
  120. rFile = open("/etc/fstab", "a")
  121. rFile.write("tmpfs /home/xtreamcodes/iptv_xtream_codes/streams padrões tmpfs,noatime,nosuid,nodev,noexec,mode=1777,size=90% 0 0\ntmpfs /home/xtreamcodes/iptv_xtream_codes/tmp padrões tmpfs,noatime ,nosuid,nodev,noexec,mode=1777,tamanho=2G 0 0")
  122. rArquivo.close()
  123. se não "xtreamcodes" em open("/etc/sudoers").read():
  124. os.system('echo "xtreamcodes ALL=(root) NOPASSWD: /sbin/iptables, /usr/bin/chattr" >> /etc/sudoers')
  125. se não, os.path.exists("/etc/init.d/xtreamcodes"):
  126. rStart = open("/etc/init.d/xtreamcodes", "w")
  127. rStart.write("#!/bin/bash\n### BEGIN INIT INFO\n# Fornece: xtreamcodes\n# Início obrigatório: $all\n# Parada obrigatória:\n# Início padrão: 2 3 4 5\n# Default-Stop:\n# Breve descrição: Execute /etc/init.d/xtreamcodes se existir\n### END INIT INFO\nsleep 1\n/home/xtreamcodes/iptv_xtream_codes/start_services .sh > /dev/null")
  128. rStart.close()
  129. os.system("chmod +x /etc/init.d/xtreamcodes")
  130. os.system("padrões de update-rc.d xtreamcodes")
  131. os.system("update-rc.d xtreamcodes enable")
  132. tente: os.remove("/usr/bin/ffmpeg")
  133. exceto: passar
  134. se não, os.path.exists("/home/xtreamcodes/iptv_xtream_codes/tv_archive"): os.mkdir("/home/xtreamcodes/iptv_xtream_codes/tv_archive/")
  135. os.system("ln -s /home/xtreamcodes/iptv_xtream_codes/bin/ffmpeg /usr/bin/")
  136. os.system("chown xtreamcodes:xtreamcodes -R /home/xtreamcodes> /dev/null")
  137. os.system("chmod -R 0777 /home/xtreamcodes> /dev/null")
  138. os.system("chmod +x /home/xtreamcodes/iptv_xtream_codes/start_services.sh > /dev/null")
  139. os.system("chattr -i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb> /dev/null")
  140. os.system("montar -a")
  141. se não "api.xtream-codes.com" em open("/etc/hosts").read(): os.system('echo "127.0.0.1 api.xtream-codes.com" >> /etc/hosts')
  142. se não "downloads.xtream-codes.com" em open("/etc/hosts").read(): os.system('echo "127.0.0.1 downloads.xtream-codes.com" >> /etc/hosts')
  143. se não " xtream-codes.com" em open("/etc/hosts").read(): os.system('echo "127.0.0.1 xtream-codes.com" >> /etc/hosts')
  144. os.system('apt-get install descompacte e2fsprogs python-paramiko -y && chattr -i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb && rm -rf /home/xtreamcodes/iptv_xtream_codes/ admin 2>/dev/null && rm -rf /home/xtreamcodes/iptv_xtream_codes/pytools 2>/dev/null && wget -q "https://xtreamui.net/ck/update.zip" ; -O /tmp/update.zip -o /dev/null && descompacte /tmp/update.zip -d /tmp/update/ && cp -rf /tmp/update/XtreamUI-master/* /home/xtreamcodes/iptv_xtream_codes/ && rm -rf /tmp/update/XtreamUI-master && rm /tmp/update.zip && rm -rf /tmp/update && chown - R xtreamcodes:xtreamcodes /home/xtreamcodes/ && chmod +x /home/xtreamcodes/iptv_xtream_codes/permissions.sh && /home/xtreamcodes/iptv_xtream_codes/permissions.sh && find /home/xtreamcodes/ -type d -not \( -name .update -prune \) -exec chmod -R 777 {} +')
  145. os.system("sed -i 's|echo \"Xtream Codes Reborn\";|header(\"Localização: https://www.google.com/\");| g' /home/xtreamcodes/iptv_xtream_codes/wwwdir/index.php")
  146. os.system("sudo wget -q https://xtreamui.net/ck/youtube-dl -O /usr/local/bin/youtube-dl")
  147. os.system("sudo chmod a+rx /usr/local/bin/youtube-dl")
  148. def início(primeiro=Verdadeiro):
  149. se primeiro: printc("Iniciando códigos Xtream")
  150. else: printc("Reiniciando códigos Xtream")
  151. os.system("/home/xtreamcodes/iptv_xtream_codes/start_services.sh 2>/dev/null")
  152. os.system("chattr +i /home/xtreamcodes/iptv_xtream_codes/GeoLite2.mmdb")
  153. def modificarNginx():
  154. printc("Modificando Nginx")
  155. rPath = "/home/xtreamcodes/iptv_xtream_codes/nginx/conf/nginx.conf"
  156. rPrevData = open(rPath, "r").read()
  157. se não "ouça 25500" em rPrevData:
  158. shutil.copy(rPath, "%s.xc"% rPath)
  159. rData = "}".join(rPrevData.split("}")[:-1]) + "\n server {\n listen 25500;\n index index.php index.html index.htm ;\n root /home/xtreamcodes/iptv_xtream_codes/admin/;\n\n location ~ \.php$ {\n limit_req zone=one burst=8;\n try_files $uri =404;\n fastcgi_index index.php; \n fastcgi_pass php;\n include fastcgi_params;\n fastcgi_buffering ativado;\n fastcgi_buffers 96 32k;\n fastcgi_buffer_size 32k;\n fastcgi_max_temp_file_size 0;\n fastcgi_keep_conn ativado;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n fastcgi _param SCRIPT_NAME $ fastcgi_script_name;\n }\n }\n#CONFIGURAÇÃO DO ISP\n\n servidor {\n escutar 8805;\n root /home/xtreamcodes/iptv_xtream_codes/isp/;\n localização / {\n permitir 127.0.0.1;\ n negar tudo;\n }\n localização ~ \.php$ {\n limit_req zone=one burst=8;\n try_files $uri =404;\n fastcgi_index index.php;\n fastcgi_pass php;\n include fastcgi_params ;\n fastcgi_buffering ativado;\n fastcgi_buffers 96 32k;\n fastcgi_buffer_size 32k;\n fastcgi_max_temp_file_size 0;\n fastcgi_keep_conn ativado;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n fastcgi_param SCRIPT_NAME $fastcgi_script_name;\n }\n }\ n}"
  160. rArquivo = abrir(rPath, "w")
  161. rArquivo.write(rData)
  162. rArquivo.close()
  163. se __nome__ == "__main__":
  164. printc("CK41 MOD - Renascido por DRMStuff.com", col.OKGREEN, 2)
  165. rType = raw_input(" Tipo de instalação [MAIN, LB]: ")
  166. imprimir " "
  167. se rType.upper() em ["MAIN", "LB"]:
  168. se rType.upper() == "LB":
  169. rHost = raw_input(" Endereço IP do servidor principal: ")
  170. rPassword = raw_input(" Senha do MySQL: ")
  171. tente: rServerID = int(raw_input(" ID do servidor do balanceador de carga: "))
  172. exceto: rServerID = -1
  173. imprimir " "
  174. outro:
  175. rHost = "127.0.0.1"
  176. rSenha = gerar()
  177. rServerID = 1
  178. rUsername = "user_iptvpro"
  179. rDatabase = "xtream_iptvpro"
  180. rPort = 7999
  181. if len(rHost) > 0 e len(rPassword) > 0 e rServerID> -1:
  182. printc("Iniciar instalação? S/N", col.WARNING)
  183. se raw_input(" ").upper() == "Y":
  184. imprimir " "
  185. rRet = prepare(rType.upper())
  186. se não instalar(rType.upper()): sys.exit(1)
  187. if rType.upper() == "PRINCIPAL":
  188. se não for mysql (rUsername, rPassword): sys.exit (1)
  189. criptografar (rHost, rUsername, rPassword, rDatabase, rServerID, rPort)
  190. configurar()
  191. if rType.upper() == "PRINCIPAL": modificarNginx()
  192. começar()
  193. printc("Xtream UI 22 CK41 MOD Reborn", col.OKGREEN, 2)
  194. printc("IU do administrador: http://%s:25500" % getIP())
  195. if rType.upper() == "PRINCIPAL":
  196. printc("Por favor, armazene sua senha do MySQL!")
  197. printc(rSenha)
  198. senão: printc("Instalação cancelada", col.FAIL)
  199. else: printc("Entradas inválidas", col.FAIL)
  200. else: printc("Tipo de instalação inválido", col.FAIL)

comments powered by Disqus