|
|
import os |
|
|
import requests |
|
|
import urllib3 |
|
|
|
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) |
|
|
from dotenv import load_dotenv |
|
|
|
|
|
load_dotenv() |
|
|
|
|
|
|
|
|
WEBHOOK_URL = (os.getenv("WEBHOOK_URL") or "").strip() |
|
|
WEBHOOK_URL = WEBHOOK_URL.replace("ptb.discord.com", "discord.com").replace("canary.discord.com", "discord.com") |
|
|
|
|
|
|
|
|
DISCORD_IPS = ["162.159.135.232", "162.159.136.232", "162.159.137.232"] |
|
|
|
|
|
def notify_discord(message: str) -> tuple[bool, str]: |
|
|
"""Sends a notification to Discord. Returns (Success, status_message).""" |
|
|
if not WEBHOOK_URL: |
|
|
msg = "Warning: WEBHOOK_URL not set. Skipping notification." |
|
|
print(msg) |
|
|
return False, msg |
|
|
|
|
|
data = {"content": message} |
|
|
|
|
|
|
|
|
try: |
|
|
response = requests.post(WEBHOOK_URL, json=data, timeout=5) |
|
|
response.raise_for_status() |
|
|
return True, "Notification sent successfully (Standard DNS)." |
|
|
except requests.exceptions.RequestException as e: |
|
|
print(f"Standard DNS failed: {e}") |
|
|
|
|
|
|
|
|
|
|
|
from urllib.parse import urlparse |
|
|
parsed = urlparse(WEBHOOK_URL) |
|
|
path = parsed.path |
|
|
|
|
|
headers = {"Host": "discord.com"} |
|
|
|
|
|
for ip in DISCORD_IPS: |
|
|
try: |
|
|
|
|
|
bypass_url = f"https://{ip}{path}" |
|
|
print(f"Trying DNS Bypass with IP: {ip}") |
|
|
|
|
|
|
|
|
|
|
|
response = requests.post(bypass_url, json=data, headers=headers, verify=False, timeout=5) |
|
|
response.raise_for_status() |
|
|
return True, f"Notification sent successfully (DNS Bypass: {ip})" |
|
|
except Exception as bypass_e: |
|
|
print(f"Bypass {ip} failed: {bypass_e}") |
|
|
|
|
|
|
|
|
return False, f"All attempts failed. Standard Error: {e}" |
|
|
|