Create menu_functions.py
This commit is contained in:
parent
d88fe7d058
commit
427545806e
|
@ -0,0 +1,155 @@
|
|||
import os
|
||||
import logging as log
|
||||
import bluetooth
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
def get_target_address():
|
||||
target_address = input("\nWhat is the target address? Leave blank and we will scan for you: ")
|
||||
if target_address == "":
|
||||
devices = scan_for_devices()
|
||||
if devices:
|
||||
if len(devices) > 1: # More than one device means a scan was performed
|
||||
selection = int(input("\nSelect a device by number: ")) - 1
|
||||
if 0 <= selection < len(devices):
|
||||
target_address = devices[selection][0]
|
||||
else:
|
||||
print("\nInvalid selection. Exiting.")
|
||||
return
|
||||
else:
|
||||
# Only one device, means a known device was selected
|
||||
target_address = devices[0][0]
|
||||
else:
|
||||
return
|
||||
elif not is_valid_mac_address(target_address):
|
||||
print("\nInvalid MAC address format. Please enter a valid MAC address.")
|
||||
return
|
||||
return target_address
|
||||
|
||||
def restart_bluetooth_daemon():
|
||||
run(["sudo", "service", "bluetooth", "restart"])
|
||||
time.sleep(0.5)
|
||||
|
||||
def run(command):
|
||||
assert(isinstance(command, list))
|
||||
log.debug("executing '%s'" % " ".join(command))
|
||||
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
return result
|
||||
|
||||
def print_blue_ascii_art():
|
||||
blue_color_code = "\033[34m" # ANSI escape code for blue text
|
||||
reset_color_code = "\033[0m" # ANSI escape code to reset text color
|
||||
|
||||
ascii_art = """
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣄⣤⣤⣄⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⡶⠟⠛⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠷⢶⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⠟⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⢷⣤⡀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣆⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣧⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣠⣤⣤⣤⣤⣤⣄⣀⡀⠀⠀⢹⣧⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣶⣶⣿⣷⣶⠶⠛⠛⠛⠛⠳⢶⣦⠀⠀⠀⠀⢠⣾⣿⣿⣿⣿⣿⣯⠉⠉⠉⠉⠉⠛⣷⠀⠀⢿⡄⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⢀⣠⣿⣀⡀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⠀⢀⣀⣀⣤⣴⠟⠀⠀⠸⣧⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⣙⣿⣿⣿⣿⣿⣿⠶⠶⠶⠿⠛⠛⠛⠛⠛⠛⢷⣦⡀⠉⠙⠛⠛⠛⠛⠛⠛⠛⠋⠉⠁⠀⠀⠀⠀⠀⣿⠀⠀⠀
|
||||
⠀⢀⣠⣴⠶⠾⠛⠛⠛⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡀⠀⠀
|
||||
⢠⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢗⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀
|
||||
⠈⢿⣦⣄⣀⣀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣤⣤⣤⣄⣀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀
|
||||
⠀⠀⠈⠉⠛⠛⠛⢻⣟⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠉⠉⠉⠻⠷⠀⢀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠛⠷⢶⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣴⠶⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⢹⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⡇⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡇⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣇⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣆⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⢶
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⡾⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣴⠟⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⢀⣤⣤⡀⢀⣤⣤⡀⠀⣤⠀⠀⢀⣤⣄⢀⣤⣤⡀⠀⠀⣤⠀⠀⣠⠀⢀⣄⠀⠀⣠⣤⡀⠀⠀⠀⡀⠀⣠⡀⣠⣤⣤⣠⡀⠀⣤⢀⣤⣤⡀⣤⣤⡀
|
||||
⢸⣯⣹⡗⣿⣿⡏⠀⣼⣿⣇⢰⡿⠉⠃⣿⣿⡍⠀⠀⠀⢿⣤⣦⣿⠀⣾⢿⡆⢾⣯⣝⡃⠀⠀⢰⣿⣆⣿⡧⣿⣽⡍⠘⣷⣸⡏⣾⣿⡯⢸⣯⣩⡿
|
||||
⢸⡟⠉⠀⢿⣶⣶⢰⡿⠟⢻⡾⢷⣴⡆⢿⣶⣶⠄⠀⠀⠸⡿⠻⡿⣼⡿⠟⢿⢤⣭⣿⠟⠀⠀⢸⡇⠻⣿⠃⣿⣼⣶⠀⢻⡟⠀⢿⣧⣶⠸⣿⠻⣧
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠁⠀⠀⠀⢀⡀⠀⠀⠀⠀⣀⠀⠀⠀⠀⣀⡀⠈⢀⣀⣀⠀⣁⣀⣀⢀⡀⠀⢀⣀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣿⠀⢠⣧⡀⣿⠀⠀⠀⣼⡿⢿⣄⣼⡟⢿⡿⠿⣿⠿⢻⣧⢠⡿⠿⣧⣀⣿⡄⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣸⣿⣿⣧⣾⡟⣷⣿⠀⠀⠘⣿⣀⣸⡟⢹⡿⠟⠁⠀⣿⡀⢸⣏⢿⣇⣠⣿⢻⣏⢿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
||||
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠁⠀⠙⠙⠁⠘⠋⠀⠀⠀⠈⠉⠉⠀⠘⠁⠀⠀⠀⠉⠁⠈⠁⠀⠉⠉⠁⠈⠋⠈⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀"""
|
||||
|
||||
|
||||
print(blue_color_code + ascii_art + reset_color_code)
|
||||
|
||||
def clear_screen():
|
||||
os.system('clear')
|
||||
|
||||
# Function to save discovered devices to a file
|
||||
def save_devices_to_file(devices, filename='known_devices.txt'):
|
||||
with open(filename, 'w') as file:
|
||||
for addr, name in devices:
|
||||
file.write(f"{addr},{name}\n")
|
||||
|
||||
# Function to scan for devices
|
||||
def scan_for_devices():
|
||||
main_menu()
|
||||
|
||||
# Load known devices
|
||||
known_devices = load_known_devices()
|
||||
if known_devices:
|
||||
print("\nKnown devices:")
|
||||
for idx, (addr, name) in enumerate(known_devices):
|
||||
print(f"{idx + 1}: Device Name: {name}, Address: {addr}")
|
||||
|
||||
use_known_device = input("\nDo you want to use one of these known devices? (yes/no): ")
|
||||
if use_known_device.lower() == 'yes':
|
||||
device_choice = int(input("Enter the number of the device: "))
|
||||
return [known_devices[device_choice - 1]]
|
||||
|
||||
# Normal Bluetooth scan
|
||||
print("\nAttempting to scan now...")
|
||||
nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True, flush_cache=True, lookup_class=True)
|
||||
device_list = []
|
||||
|
||||
if len(nearby_devices) == 0:
|
||||
print("\nNo nearby devices found.")
|
||||
else:
|
||||
print("\nFound {} nearby device(s):".format(len(nearby_devices)))
|
||||
for idx, (addr, name, _) in enumerate(nearby_devices):
|
||||
print(f"{idx + 1}: Device Name: {name}, Address: {addr}")
|
||||
device_list.append((addr, name))
|
||||
|
||||
# Save the scanned devices only if they are not already in known devices
|
||||
new_devices = [device for device in device_list if device not in known_devices]
|
||||
if new_devices:
|
||||
known_devices += new_devices
|
||||
save_devices_to_file(known_devices)
|
||||
return device_list
|
||||
|
||||
def main_menu():
|
||||
clear_screen()
|
||||
print_blue_ascii_art()
|
||||
title = "BlueDucky - Bluetooth Device Attacker"
|
||||
separator = 70 * "="
|
||||
print(separator)
|
||||
print(f"{separator}\n{title.center(len(separator))}\n{separator}")
|
||||
print("Remember, you can still attack devices without visibility...\nIf you have their MAC address")
|
||||
print(separator)
|
||||
|
||||
|
||||
def is_valid_mac_address(mac_address):
|
||||
# Regular expression to match a MAC address in the form XX:XX:XX:XX:XX:XX
|
||||
mac_address_pattern = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$')
|
||||
return mac_address_pattern.match(mac_address) is not None
|
||||
|
||||
# Function to read DuckyScript from file
|
||||
def read_duckyscript(filename='payload.txt'):
|
||||
if os.path.exists(filename):
|
||||
with open(filename, 'r') as file:
|
||||
return [line.strip() for line in file.readlines()]
|
||||
else:
|
||||
log.warning(f"File {filename} not found. Skipping DuckyScript.")
|
||||
return None
|
||||
|
||||
# Function to load known devices from a file
|
||||
def load_known_devices(filename='known_devices.txt'):
|
||||
if os.path.exists(filename):
|
||||
with open(filename, 'r') as file:
|
||||
return [tuple(line.strip().split(',')) for line in file]
|
||||
else:
|
||||
return []
|
Loading…
Reference in New Issue