Updated UI / Ver 2.1

UI Update, and bug fixes
This commit is contained in:
Charles Johnson 2024-05-15 18:15:55 -05:00 committed by GitHub
parent 2b9c4bd373
commit 97316eb742
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 95 additions and 67 deletions

View File

@ -1,7 +1,15 @@
import os, bluetooth,re, subprocess, time, curses import os, bluetooth, re, subprocess, time, curses
import logging as log import logging as log
##########################
# UI Redesign by Lamento #
##########################
def get_target_address(): def get_target_address():
target_address = input("\nWhat is the target address? Leave blank and we will scan for you: ") blue = "\033[94m"
reset = "\033[0m"
print(f"\n What is the target address{blue}? {reset}Leave blank and we will scan for you{blue}!{reset}")
target_address = input(f"\n {blue}> ")
if target_address == "": if target_address == "":
devices = scan_for_devices() devices = scan_for_devices()
@ -10,7 +18,7 @@ def get_target_address():
if len(devices) == 1 and isinstance(devices[0], tuple) and len(devices[0]) == 2: if len(devices) == 1 and isinstance(devices[0], tuple) and len(devices[0]) == 2:
# A single known device was chosen, no need to ask for selection # A single known device was chosen, no need to ask for selection
# I think it would be better to ask, as sometimes I do not want to chose this device and actually need solely to scan for actual devices. # I think it would be better to ask, as sometimes I do not want to chose this device and actually need solely to scan for actual devices.
confirm = input(f"Would you like to enter this device :\n{devices[0][1]} {devices[0][0]} ? (y/n)\n").strip().lower() confirm = input(f"\n Would you like to register this device{blue}:\n{reset}{devices[0][1]} {devices[0][0]}{blue}? {blue}({reset}y{blue}/{reset}n{blue}) {blue}").strip().lower()
if confirm == 'y' or confirm == 'yes': if confirm == 'y' or confirm == 'yes':
return devices[0][0] return devices[0][0]
elif confirm != 'y' or 'yes': elif confirm != 'y' or 'yes':
@ -18,8 +26,8 @@ def get_target_address():
else: else:
# Show list of scanned devices for user selection # Show list of scanned devices for user selection
for idx, (addr, name) in enumerate(devices): for idx, (addr, name) in enumerate(devices):
print(f"{idx + 1}: Device Name: {name}, Address: {addr}") print(f"{reset}[{blue}{idx + 1}{reset}] {blue}Device Name{reset}: {blue}{name}, {blue}Address{reset}: {blue}{addr}")
selection = int(input("\nSelect a device by number: ")) - 1 selection = int(input(f"\n{reset}Select a device by number{blue}: {blue}")) - 1
if 0 <= selection < len(devices): if 0 <= selection < len(devices):
target_address = devices[selection][0] target_address = devices[selection][0]
else: else:
@ -46,38 +54,30 @@ def run(command):
def print_fancy_ascii_art(): def print_fancy_ascii_art():
ascii_art = """ ascii_art = """
"""
"""
print("\033[1;36m" + ascii_art + "\033[0m") # Cyan color print("\033[94m" + ascii_art + "\033[0m") # Blue color
def clear_screen(): def clear_screen():
os.system('clear') os.system('clear')
@ -88,45 +88,44 @@ def save_devices_to_file(devices, filename='known_devices.txt'):
for addr, name in devices: for addr, name in devices:
file.write(f"{addr},{name}\n") file.write(f"{addr},{name}\n")
def get_yes_no():
stdscr = curses.initscr()
curses.cbreak()
stdscr.keypad(1)
while True:
key = stdscr.getch()
if key == ord('y'):
response = 'yes'
break
elif key == ord('n'):
response = 'no'
break
curses.endwin()
return response
# Function to scan for devices # Function to scan for devices
def scan_for_devices(): def scan_for_devices():
main_menu() main_menu()
blue = "\033[94m"
error = "\033[91m"
reset = "\033[0m"
# Load known devices # Load known devices
known_devices = load_known_devices() known_devices = load_known_devices()
if known_devices: if known_devices:
print("\nKnown devices:") blue = "\033[94m"
error = "\033[91m"
reset = "\033[0m"
print(f"\n{reset}Known devices{blue}:")
for idx, (addr, name) in enumerate(known_devices): for idx, (addr, name) in enumerate(known_devices):
print(f"{idx + 1}: Device Name: {name}, Address: {addr}") blue = "\033[94m"
error = "\033[91m"
reset = "\033[0m"
print(f"{blue}{idx + 1}{reset}: Device Name: {blue}{name}, Address: {blue}{addr}")
use_known_device = input("\nDo you want to use one of these known devices? (yes/no): ") blue = "\033[94m"
error = "\033[91m"
reset = "\033[0m"
use_known_device = input(f"\n{reset}Do you want to use one of these known devices{blue}? {blue}({reset}yes{blue}/{reset}no{blue}): ")
if use_known_device.lower() == 'yes': if use_known_device.lower() == 'yes':
device_choice = int(input("Enter the number of the device: ")) device_choice = int(input(f"{reset}Enter the index number of the device to attack{blue}: "))
return [known_devices[device_choice - 1]] return [known_devices[device_choice - 1]]
# Normal Bluetooth scan # Normal Bluetooth scan
print("\nAttempting to scan now...") blue = "\033[94m"
error = "\033[91m"
reset = "\033[0m"
print(f"\n{reset}Attempting to scan now{blue}...")
nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True, flush_cache=True, lookup_class=True) nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True, flush_cache=True, lookup_class=True)
device_list = [] device_list = []
if len(nearby_devices) == 0: if len(nearby_devices) == 0:
print("\nNo nearby devices found.") print(f"\n{reset}[{error}+{reset}] No nearby devices found.")
else: else:
print("\nFound {} nearby device(s):".format(len(nearby_devices))) print("\nFound {} nearby device(s):".format(len(nearby_devices)))
for idx, (addr, name, _) in enumerate(nearby_devices): for idx, (addr, name, _) in enumerate(nearby_devices):
@ -138,18 +137,31 @@ def scan_for_devices():
known_devices += new_devices known_devices += new_devices
save_devices_to_file(known_devices) save_devices_to_file(known_devices)
for idx, (addr, name) in enumerate(new_devices): for idx, (addr, name) in enumerate(new_devices):
print(f"{idx + 1}: Device Name: {name}, Address: {addr}") print(f"{reset}{idx + 1}{blue}: {blue}Device Name{reset}: {blue}{name}{reset}, {blue}Address{reset}: {blue}{addr}")
return device_list return device_list
def getterm():
size = os.get_terminal_size()
return size.columns
def print_menu(): def print_menu():
blue = '\033[94m'
reset = "\033[0m"
title = "BlueDucky - Bluetooth Device Attacker" title = "BlueDucky - Bluetooth Device Attacker"
separator = "=" * 70 vertext = "Ver 2.1"
print("\033[1;35m" + separator) # Purple color for separator motd1 = f"Remember, you can still attack devices without visibility.."
print("\033[1;33m" + title.center(len(separator))) # Yellow color for title motd2 = f"If you have their MAC address.."
print("\033[1;35m" + separator + "\033[0m") # Purple color for separator terminal_width = getterm()
print("\033[1;32m" + "Remember, you can still attack devices without visibility..." + "\033[0m") separator = "=" * terminal_width
print("\033[1;32m" + "If you have their MAC address" + "\033[0m")
print("\033[1;35m" + separator + "\033[0m") # Purple color for separator print(blue + separator) # Blue color for separator
print(reset + title.center(len(separator))) # Centered Title in blue
print(blue + vertext.center(len(separator))) # Centered Version
print(blue + separator + reset) # Blue color for separator
print(motd1.center(len(separator)))# used the same method for centering
print(motd2.center(len(separator)))# used the same method for centering
print(blue + separator + reset) # Blue color for separator
def main_menu(): def main_menu():
clear_screen() clear_screen()
@ -178,3 +190,19 @@ def load_known_devices(filename='known_devices.txt'):
return [tuple(line.strip().split(',')) for line in file] return [tuple(line.strip().split(',')) for line in file]
else: else:
return [] return []
title = "BlueDucky - Bluetooth Device Attacker"
vertext = "Ver 2.1"
terminal_width = getterm()
separator = "=" * terminal_width
blue = "\033[0m"
reset = "\033[0m"
print(blue + separator) # Blue color for separator
print(reset + title.center(len(separator))) # White color for title
print(blue + vertext.center(len(separator))) # White blue for version number
print(blue + separator + reset) # Blue color for separator
print(f"{reset}Remember, you can still attack devices without visibility{blue}.." + reset)
print(f"{blue}If you have their {reset}MAC address{blue}.." + reset)
print(blue + separator + reset) # Blue color for separator