Merge pull request #3 from FaganAfandiyev/fixes

Fixes
This commit is contained in:
Opabinia 2024-02-07 10:45:33 +13:00 committed by GitHub
commit d94d86c611
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 18 deletions

View File

@ -1,15 +1,9 @@
import binascii import binascii, bluetooth, sys, time, datetime, logging
import bluetooth
import sys
import time
from multiprocessing import Process from multiprocessing import Process
from pydbus import SystemBus from pydbus import SystemBus
from enum import Enum from enum import Enum
import datetime
import logging
from utils.menu_functions import (main_menu, read_duckyscript, from utils.menu_functions import (main_menu, read_duckyscript, run, restart_bluetooth_daemon, get_target_address)
run, restart_bluetooth_daemon, get_target_address)
from utils.register_device import register_hid_profile, agent_loop from utils.register_device import register_hid_profile, agent_loop
child_processes = [] child_processes = []

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +1,5 @@
import os import os, bluetooth,re, subprocess, time, curses
import logging as log import logging as log
import bluetooth
import re
import subprocess
import time
import platform
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: ")
@ -89,6 +83,23 @@ 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()
@ -109,13 +120,11 @@ def scan_for_devices():
print("\nAttempting to scan now...") print("\nAttempting to scan now...")
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("\nNo 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):
print(f"{idx + 1}: Device Name: {name}, Address: {addr}")
device_list.append((addr, name)) device_list.append((addr, name))
# Save the scanned devices only if they are not already in known devices # Save the scanned devices only if they are not already in known devices
@ -123,6 +132,8 @@ def scan_for_devices():
if new_devices: if new_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):
print(f"{idx + 1}: Device Name: {name}, Address: {addr}")
return device_list return device_list
def print_menu(): def print_menu():