IvanCastl

Bots Telegram

May 8th, 2025
2,173
0
Never
11
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.42 KB | Cybersecurity | 0 0
  1. import requests
  2. from bs4 import BeautifulSoup
  3. import re
  4. import os
  5.  
  6. # Palabras clave para buscar en JS
  7. patrones_telegram = [
  8.     r"telegram", r"TelegramBot", r"botFather", r"sendMessage", r"token",
  9.     r"Telegram\.WebApp", r"window\.Telegram"
  10. ]
  11.  
  12. def buscar_referencias_telegram_en_js(url):
  13.     try:
  14.         response = requests.get(url)
  15.         response.raise_for_status()
  16.     except requests.RequestException as e:
  17.         print(f"❌ Error al acceder a la URL: {e}")
  18.         return
  19.  
  20.     soup = BeautifulSoup(response.text, "html.parser")
  21.     scripts = soup.find_all("script")
  22.     hallazgos = []
  23.  
  24.     # Crear carpeta para guardar JS sospechosos
  25.     if not os.path.exists("js_sospechosos"):
  26.         os.makedirs("js_sospechosos")
  27.  
  28.     for script in scripts:
  29.         js_code = ""
  30.         source = ""
  31.  
  32.         if script.get("src"):  # Script externo
  33.             src = script["src"]
  34.             if not src.startswith("http"):
  35.                 src = requests.compat.urljoin(url, src)
  36.             try:
  37.                 js_response = requests.get(src, timeout=10)
  38.                 js_response.raise_for_status()
  39.                 js_code = js_response.text
  40.                 source = src
  41.             except:
  42.                 continue
  43.         else:  # Script inline
  44.             js_code = script.text
  45.             source = "[INLINE]"
  46.  
  47.         for patron in patrones_telegram:
  48.             coincidencias = re.findall(patron, js_code, re.IGNORECASE)
  49.             if coincidencias:
  50.                 hallazgos.append({
  51.                     'archivo_js': source,
  52.                     'coincidencias': list(set(coincidencias))
  53.                 })
  54.  
  55.                 # Guardar JS sospechoso
  56.                 filename = os.path.join("js_sospechosos", re.sub(r'\W+', '_', source[-50:]) + ".js")
  57.                 with open(filename, "w", encoding="utf-8") as f:
  58.                     f.write(js_code)
  59.                 break
  60.  
  61.     if hallazgos:
  62.         print("🚨 Se detectaron posibles referencias a Telegram:")
  63.         for h in hallazgos:
  64.             print(f"\n🔗 JS: {h['archivo_js']}")
  65.             print("📌 Coincidencias:", ', '.join(h['coincidencias']))
  66.     else:
  67.         print("✅ No se detectaron referencias a Telegram.")
  68.  
  69. # 👇 Cambia la URL para probar otro sitio
  70. url = input("🌐 Ingresa la URL a analizar: ").strip()
  71. buscar_referencias_telegram_en_js(url)
  72. #https://cuscatlanpagos.web.app/
  73. #https://cloudflare-cdn-kdbvm.pages.dev/
Tags: Bots
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment