Update menu_functions.py
This commit is contained in:
parent
34fc956991
commit
d5ea1fc6f8
|
@ -7,24 +7,30 @@ import time
|
||||||
|
|
||||||
def get_target_address():
|
def get_target_address():
|
||||||
target_address = input("\nWhat is the target address? Leave blank and we will scan for you: ")
|
target_address = input("\nWhat is the target address? Leave blank and we will scan for you: ")
|
||||||
|
|
||||||
if target_address == "":
|
if target_address == "":
|
||||||
devices = scan_for_devices()
|
devices = scan_for_devices()
|
||||||
if devices:
|
if devices:
|
||||||
if len(devices) > 1: # More than one device means a scan was performed
|
# Check if the returned list is from known devices or scanned devices
|
||||||
|
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
|
||||||
|
target_address = devices[0][0]
|
||||||
|
else:
|
||||||
|
# Show list of scanned devices for user selection
|
||||||
|
for idx, (addr, name) in enumerate(devices):
|
||||||
|
print(f"{idx + 1}: Device Name: {name}, Address: {addr}")
|
||||||
selection = int(input("\nSelect a device by number: ")) - 1
|
selection = int(input("\nSelect a device by number: ")) - 1
|
||||||
if 0 <= selection < len(devices):
|
if 0 <= selection < len(devices):
|
||||||
target_address = devices[selection][0]
|
target_address = devices[selection][0]
|
||||||
else:
|
else:
|
||||||
print("\nInvalid selection. Exiting.")
|
print("\nInvalid selection. Exiting.")
|
||||||
return
|
return
|
||||||
else:
|
|
||||||
# Only one device, means a known device was selected
|
|
||||||
target_address = devices[0][0]
|
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
elif not is_valid_mac_address(target_address):
|
elif not is_valid_mac_address(target_address):
|
||||||
print("\nInvalid MAC address format. Please enter a valid MAC address.")
|
print("\nInvalid MAC address format. Please enter a valid MAC address.")
|
||||||
return
|
return
|
||||||
|
|
||||||
return target_address
|
return target_address
|
||||||
|
|
||||||
def restart_bluetooth_daemon():
|
def restart_bluetooth_daemon():
|
||||||
|
@ -33,7 +39,7 @@ def restart_bluetooth_daemon():
|
||||||
|
|
||||||
def run(command):
|
def run(command):
|
||||||
assert(isinstance(command, list))
|
assert(isinstance(command, list))
|
||||||
log.debug("executing '%s'" % " ".join(command))
|
log.info("executing '%s'" % " ".join(command))
|
||||||
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -131,7 +137,6 @@ def main_menu():
|
||||||
print("Remember, you can still attack devices without visibility...\nIf you have their MAC address")
|
print("Remember, you can still attack devices without visibility...\nIf you have their MAC address")
|
||||||
print(separator)
|
print(separator)
|
||||||
|
|
||||||
|
|
||||||
def is_valid_mac_address(mac_address):
|
def is_valid_mac_address(mac_address):
|
||||||
# Regular expression to match a MAC address in the form XX:XX:XX:XX:XX:XX
|
# 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})$')
|
mac_address_pattern = re.compile(r'^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$')
|
||||||
|
|
Loading…
Reference in New Issue