updated function for ssp error
This commit is contained in:
parent
2d37faf6cf
commit
4b2bd0a4ba
28
BlueDucky.py
28
BlueDucky.py
|
@ -3,8 +3,11 @@ from multiprocessing import Process
|
||||||
from pydbus import SystemBus
|
from pydbus import SystemBus
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
from utils.menu_functions import (main_menu, read_duckyscript, run, restart_bluetooth_daemon, get_target_address)
|
from utils.menu_functions import (main_menu, read_duckyscript, 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
|
||||||
|
|
||||||
|
@ -23,6 +26,31 @@ class AnsiColorCode:
|
||||||
NOTICE_LEVEL = 25
|
NOTICE_LEVEL = 25
|
||||||
|
|
||||||
# Custom formatter class with added color for NOTICE
|
# Custom formatter class with added color for NOTICE
|
||||||
|
|
||||||
|
# Bluetooth Adapter Checking For Error
|
||||||
|
class BluetoothAdapter:
|
||||||
|
def __init__(self, iface):
|
||||||
|
self.iface = iface
|
||||||
|
|
||||||
|
def enable_ssp(self):
|
||||||
|
try:
|
||||||
|
ssp_command = ["sudo", "hciconfig", self.iface, "sspmode", "1"]
|
||||||
|
ssp_result = subprocess.run(ssp_command, capture_output=True, text=True)
|
||||||
|
if ssp_result.returncode != 0:
|
||||||
|
log.error(f"Failed to enable SSP: {ssp_result.stderr}")
|
||||||
|
raise ConnectionFailureException("Failed to enable SSP")
|
||||||
|
else:
|
||||||
|
log.info(f"SSP enabled successfully: {ssp_result.stdout}")
|
||||||
|
except Exception as e:
|
||||||
|
log.error(f"Error enabling SSP: {e}")
|
||||||
|
raise
|
||||||
|
|
||||||
|
class ConnectionFailureException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Example usage
|
||||||
|
adapter = BluetoothAdapter("hci0")
|
||||||
|
adapter.enable_ssp()
|
||||||
class ColorLogFormatter(logging.Formatter):
|
class ColorLogFormatter(logging.Formatter):
|
||||||
COLOR_MAP = {
|
COLOR_MAP = {
|
||||||
logging.DEBUG: AnsiColorCode.BLUE,
|
logging.DEBUG: AnsiColorCode.BLUE,
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
70:DD:A8:A2:71:73,OPPO A1k
|
||||||
|
07:8C:8E:F5:62:61,VGO TEL
|
Loading…
Reference in New Issue