From e92d765dde3ff526fbc48ffb5df6c00b7240856c Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Wed, 27 Mar 2024 22:51:56 +0300 Subject: [PATCH] New version 0.2.25 --- README-RU.md | 18 +++++- README.md | 18 +++++- ddec.py | 152 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 162 insertions(+), 26 deletions(-) diff --git a/README-RU.md b/README-RU.md index c55d12a..08fe8d6 100644 --- a/README-RU.md +++ b/README-RU.md @@ -130,7 +130,15 @@ Options: -trim, --trim-long-whois-text Trim long whois text of changes for a domain for Telegram (default is False) -t, --use-telegram Send a warning message through the Telegram (default is False) - -p URL, --proxy URL Proxy link (for Telegram only), for example: socks5://127.0.0.1:9150 (default is None) + -p URL, --proxy URL Proxy link for Telegram only (default is None) + for example: + user:password@proxy.someplace.com:8080 + socks5://127.0.0.1:9150 + -piw URL, --proxy-internal-whois URL + Socks-proxy link for internal whois engine only (default is None) + for example: + user:password@socksproxy.someplace.com:8080 + 127.0.0.1:9150 -e EMAIL, --email-to EMAIL Send a warning message to email address (default is None) -subject STRING, --email-subject STRING @@ -145,7 +153,7 @@ Options: Use external whois utility for additional analysis (default is False) -nb, --no-banner Do not print banner (default is False) -© AK545 (Andrey Klimov) 2019..2023, e-mail: ak545 at mail dot ru +© AK545 (Andrey Klimov) 2019..2024, e-mail: ak545 at mail dot ru ``` ### Описание опций @@ -299,6 +307,12 @@ youtube.com Ссылка на прокси (только для Telegram), например: socks5://127.0.0.1:9150 (по умолчанию None). +**-piw URL, --proxy-internal-whois URL** + +Ссылка на Socks-прокси только для внутреннего whois-движка, например: user:password@socksproxy.someplace.com:8080 или 127.0.0.1:9150 (по умолчанию None). + +Не используйте опцию -oe/--use-only-external-whois с опцией -piw/--proxy-internal-whois. + **-e EMAIL, --email-to EMAIL** Отправить предупреждение на адрес электронной почты (по умолчанию Нет). Здесь необходимо указать email адрес получателя. diff --git a/README.md b/README.md index 573dae4..5076992 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,15 @@ Options: -trim, --trim-long-whois-text Trim long whois text of changes for a domain for Telegram (default is False) -t, --use-telegram Send a warning message through the Telegram (default is False) - -p URL, --proxy URL Proxy link (for Telegram only), for example: socks5://127.0.0.1:9150 (default is None) + -p URL, --proxy URL Proxy link for Telegram only (default is None) + for example: + user:password@proxy.someplace.com:8080 + socks5://127.0.0.1:9150 + -piw URL, --proxy-internal-whois URL + Socks-proxy link for internal whois engine only (default is None) + for example: + user:password@socksproxy.someplace.com:8080 + 127.0.0.1:9150 -e EMAIL, --email-to EMAIL Send a warning message to email address (default is None) -subject STRING, --email-subject STRING @@ -141,7 +149,7 @@ Options: Use external whois utility for additional analysis (default is False) -nb, --no-banner Do not print banner (default is False) -© AK545 (Andrey Klimov) 2019..2023, e-mail: ak545 at mail dot ru +© AK545 (Andrey Klimov) 2019..2024, e-mail: ak545 at mail dot ru ``` ### Description of options @@ -297,6 +305,12 @@ Send a warning message through the Telegram (default is False) Proxy link (for Telegram only), for example: socks5://127.0.0.1:9150 (default is None). +**-piw URL, --proxy-internal-whois URL** + +Socks-proxy link for internal whois engine only, for example: user:password@socksproxy.someplace.com:8080 or 127.0.0.1:9150 (default is None). + +Don't use option -oe/--use-only-external-whois with option -piw/--proxy-internal-whois. + **-e EMAIL, --email-to EMAIL** Send a warning message to email address (default is None) diff --git a/ddec.py b/ddec.py index a419369..172679c 100644 --- a/ddec.py +++ b/ddec.py @@ -14,9 +14,9 @@ # Leif (https://github.com/akhepcat) # woodholly (https://github.com/woodholly) # -# Current Version: 0.2.23 +# Current Version: 0.2.25 # Creation Date: 2019-07-05 -# Date of last changes: 2024-02-12 +# Date of last changes: 2024-03-27 # # License: # This program is free software; you can redistribute it and/or modify @@ -34,6 +34,7 @@ import os import sys import platform +import socket import argparse import time import json @@ -100,7 +101,7 @@ sys.exit(-1) # Global constants -__version__: str = '0.2.23' +__version__: str = '0.2.25' FR: str = Fore.RESET @@ -167,13 +168,13 @@ # 'https': 'socks5://127.0.0.1:9150', # } -# # Get help from https://core.telegram.org/bots -# # token that can be generated talking with @BotFather on telegram +# Get help from https://core.telegram.org/bots +# token that can be generated talking with @BotFather on telegram TELEGRAM_TOKEN: str = '' -# -# # channel id for telegram + +# channel id for telegram TELEGRAM_CHAT_ID: str = '' -# + # # url for post request to api.telegram.org TELEGRAM_URL: str = f'https://api.telegram.org/bot{TELEGRAM_TOKEN}/' @@ -185,7 +186,7 @@ REQUEST_HEADERS: Dict = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' 'AppleWebKit/537.36 (KHTML, like Gecko) ' - 'Chrome/122.0.0.0 Safari/537.36' + 'Chrome/124.0.0.0 Safari/537.36' } # Options for an external utility whois @@ -277,8 +278,8 @@ G_DOMAINS_LIST: List = [] # Currency symbol -# G_CURRENCY_SYMBOL: str = '₽' -G_CURRENCY_SYMBOL: str = '¥' +G_CURRENCY_SYMBOL: str = '₽' +# G_CURRENCY_SYMBOL: str = '¥' # G_CURRENCY_SYMBOL: str = '£' # G_CURRENCY_SYMBOL: str = '€' # G_CURRENCY_SYMBOL: str = '$' @@ -1109,15 +1110,15 @@ def make_report_for_email() -> None: border-color: rgb(31, 31, 31) !important; background-color: rgba(24,103,194,0.81); ''' - body_html: str = """ + body_html: str = f""" @@ -1131,6 +1132,23 @@ def make_report_for_email() -> None: -webkit-text-size-adjust:none; -ms-text-size-adjust:none;"> +
+ {subject}, Exp: {G_DOMAINS_EXPIRE}, Soon:{G_DOMAINS_SOON}{" ͏" * 150} +
+
None: f'\tMessage : {CLI.split_long_message}\n' f'\tUse Telegram : {CLI.use_telegram}\n' f'\tProxy for Telegram : {CLI.proxy}\n' + f'\tSocks for internal whois : {CLI.proxy_internal_whois}\n' f'\tEmail to : {CLI.email_to}\n' f'\tEmail subject : {CLI.email_subject}\n' f'\tEmail SSL : {CLI.email_ssl}\n' @@ -2736,6 +2798,52 @@ def check_cli_logic() -> None: TELEGRAM_PROXIES['http'] = CLI.proxy TELEGRAM_PROXIES['https'] = CLI.proxy + if CLI.proxy_internal_whois and CLI.use_only_external_whois: + print( + f"{FRC}The Socks-proxy setting is for internal whois engine only. " + f"Don't use option {FLR}-oe{FRC}/{FLR}--use-only-external-whois{FRC} " + f"with option {FLR}-piw{FRC}/{FLR}--proxy-internal-whois" + ) + sys.exit(-1) + + if CLI.proxy_internal_whois and not CLI.use_only_external_whois: + os.environ['SOCKS']: str = CLI.proxy_internal_whois.strip() + socks_user, socks_password = None, None + if '@' in os.environ['SOCKS']: + creds, proxy = os.environ['SOCKS'].split('@') + socks_user, socks_password = creds.split(':') + else: + proxy = os.environ['SOCKS'] + socksproxy, port = proxy.split(':') + socks_proto = socket.AF_INET + + try: + if socket.AF_INET6 in [ + sock[0] for sock in socket.getaddrinfo(socksproxy, port) + ]: + socks_proto = socket.AF_INET6 + except socket.error as e: + print( + f'{FLR}{str(e)}' + ) + + s = socks.socksocket(socks_proto) + s.set_proxy( + socks.SOCKS5, socksproxy, int(port), True, socks_user, socks_password + ) + s.settimeout(10) + try: + s.connect(('google.com', 443)) + s.close() + except socket.error as e: + print( + f'{FLR}{str(e)}\n' + f'{FRC}Check the availability of SOCKS5 proxy ' + f'{FLR}{CLI.proxy_internal_whois.strip()}{FRC}\n' + ) + s.close() + sys.exit(-1) + if CLI.print_to_console: print_heading()