π£ Localhost DDoS Simulator in Python – Ethical Hacking Demo GUI
Demo :
Click Video πππ
π Features :
-
Embedded YouTube Short
-
Code Snippets:
app.py
andmain.py
-
Screenshots of GUI + progress bar
-
Safety Notice: Educational use only
-
Tags/Labels for indexing (use the tag list above)
-
Button to Download Project Files (optional: link to GitHub)
Code :
app.py
# save as app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "Hello from localhost!"
if __name__ == '__main__':
app.run(port=5000)
main.py :
import tkinter as tk
from tkinter import ttk, messagebox
import threading
import requests
import time
import random
# ------------------- GUI Setup -------------------
root = tk.Tk()
root.title("π£ Localhost DDoS Simulator - Educational Use Only")
root.geometry("500x500")
root.configure(bg="#1e1e1e")
# ------------------- Style -------------------
style = ttk.Style()
style.theme_use('clam')
style.configure("TButton", foreground="white", background="#ff4d4d", font=("Helvetica", 12, "bold"))
style.configure("TLabel", foreground="white", background="#1e1e1e", font=("Helvetica", 12))
style.configure("TEntry", fieldbackground="#333", foreground="white", font=("Helvetica", 12))
style.configure("Horizontal.TProgressbar", troughcolor='#333', background='#4caf50')
# ------------------- Widgets -------------------
tk.Label(root, text="π» Target (Localhost URL Only)", bg="#1e1e1e", fg="white",
font=("Helvetica", 14, "bold")).pack(pady=(20, 5))
target_entry = ttk.Entry(root, width=40)
target_entry.insert(0, "http://127.0.0.1:5000")
target_entry.pack(pady=10)
tk.Label(root, text="π Requests to Send", bg="#1e1e1e", fg="white", font=("Helvetica", 14, "bold")).pack()
requests_entry = ttk.Entry(root, width=20)
requests_entry.insert(0, "100")
requests_entry.pack(pady=10)
progress = ttk.Progressbar(root, length=300, mode='determinate', style="Horizontal.TProgressbar")
progress.pack(pady=20)
status_box = tk.Text(root, height=10, width=55, bg="#121212", fg="lime", font=("Courier", 10))
status_box.pack(pady=10)
status_box.insert(tk.END, ">> Ready to simulate traffic...\n")
status_box.config(state='disabled')
# ------------------- Function -------------------
def simulate_attack():
target = target_entry.get().strip()
try:
num_requests = int(requests_entry.get())
if num_requests <= 0:
raise ValueError
except ValueError:
messagebox.showerror("Invalid Input", "Please enter a positive number of requests.")
return
if not target.startswith("http://127.0.0.1"):
messagebox.showerror("Invalid Target", "Only localhost is allowed for safety.")
return
progress["maximum"] = num_requests
progress["value"] = 0
status_box.config(state='normal')
status_box.insert(tk.END, f">> Starting {num_requests} requests to {target}...\n")
status_box.config(state='disabled')
root.update()
def attack():
success = 0
for i in range(num_requests):
try:
r = requests.get(target, timeout=1)
success += 1
log = f"[{i+1}/{num_requests}] ✅ Status: {r.status_code}\n"
except requests.exceptions.ConnectionError:
log = f"[{i+1}/{num_requests}] ❌ Connection Error – is the server running?\n"
except Exception as e:
log = f"[{i+1}/{num_requests}] ❌ Error: {str(e)}\n"
progress["value"] = i + 1
status_box.config(state='normal')
status_box.insert(tk.END, log)
status_box.yview(tk.END)
status_box.config(state='disabled')
time.sleep(random.uniform(0.05, 0.2))
messagebox.showinfo("Completed", f"Finished sending {success}/{num_requests} successful requests.")
threading.Thread(target=attack).start()
# ------------------- Button -------------------
attack_btn = ttk.Button(root, text="π£ Start Simulation", command=simulate_attack)
attack_btn.pack(pady=20)
tk.Label(root, text="⚠️ Educational use only – Do not attack real servers.",
bg="#1e1e1e", fg="#ff4d4d", font=("Helvetica", 10, "italic")).pack(pady=5)
root.mainloop()
Comments
Post a Comment