A Python-based Bluetooth Low Energy (BLE) research, scripting, and interaction tool designed for security researchers, reverse engineers, and developers working with BLE devices.
bletoolDemo.mp4
bletool provides an interactive CLI, a scripting engine, and protocol analysis tools for:
- BLE device discovery
- GATT enumeration
- Characteristic read/write operations
- Notification monitoring and analysis
- Protocol replay testing
- BLE ATT traffic analysis
- Automatic script generation from Wireshark JSON exports
- Automated BLE workflows
- Keep-alive functionality
- BLE device information dumping
- Interactive BLE CLI
- BLE ATT operation analyzer
- Automatic script generation from Wireshark JSON exports
- Packet capture replay engine
- Timing-aware BLE script generation
- BLE scripting engine
- Script output logging
- Verbose script execution
- BLE device scanning
- Connect/disconnect support
- GATT service and characteristic enumeration
- Read characteristics by:
- Handle
- Hex handle
- Estimated characteristic value handle
- UUID
- Selected characteristic
- Write characteristics with and without response
- Characteristic selection shortcuts
- Handle ↔ UUID abstraction
- Notification monitoring and management
- Notification display customization
- Notification timestamp support
- Notification diff highlighting for protocol analysis
- Replay previously sent write operations
- Keep-alive task support
- GATT and advertisement data dumping to JSON
- Session status and device information reporting
- Tab completion
- Colored interactive prompt
- Automated integration testing with pytest
This tool is intended for authorized BLE security research, testing, and educational purposes only.
Only use this tool against devices you own or have explicit permission to test.
git clone https://github.com/serial-hacker-yt/bletool.git
cd bletoolpip install -r requirements.txtpython3 bletool.py -Spython3 bletool.py -IOr preload a target device:
python3 bletool.py -I -b AA:BB:CC:DD:EE:FFpython3 bletool.py -a capture.jsonpython3 bletool.py -sg capture.jsonThis automatically generates:
capture.bts
python3 bletool.py -sc capture.btsEnable verbose output:
python3 bletool.py -sc capture.bts -vSave replay output to a log file:
python3 bletool.py -sc capture.bts -o replay.logThe examples/ directory contains several example workflows:
| Script | Description |
|---|---|
| enumerate.bts | Device enumeration and dumping |
| notification_capture.bts | Capture BLE notifications |
bletool scripts can be written manually or automatically generated from Wireshark JSON captures.
Execute a script:
python3 bletool.py -sc myscript.btsEnable verbose execution:
python3 bletool.py -sc myscript.bts -vSave output to a file:
python3 bletool.py -sc myscript.bts -o output.logExample script:
connect 48:27:E2:08:B4:CE
notify 49 start
sleep 10
notify 49 stop
disconnect
Example verbose output:
[1] connect 48:27:E2:08:B4:CE
Attempting to connect...
[+] Connected!
[2] notify 49 start
Notifications started for 70d51002-2c7f-4e75-ae8a-d758951ce4e0
70d51002-2c7f-4e75-ae8a-d758951ce4e0 (Handle: 49):
1eff020907304c420c031ae800...
[4] notify 49 stop
Notifications stopped
Analyze an nRF Sniffer capture converted to .json:
python3 bletool.py -a capture.jsonGenerate a script based on a .json capture:
Generated replay scripts preserve the timing between captured ATT operations, allowing realistic protocol replay during authorized testing.
python3 bletool.py -sg capture.jsonExecute a script with bletool:
python3 bletool.py -sc capture.btsbletool can analyze captured BLE traffic and automatically generate replayable scripts from Wireshark JSON exports.
Current Support
Replay script generation currently supports Wireshark JSON exports generated from Nordic nRF Sniffer captures.
Capture BLE traffic using a Nordic nRF Sniffer and Wireshark.
In Wireshark:
File
→ Export Packet Dissections
→ As JSON...
Save the capture as a JSON file.
Example:
capture.json
Analyze the captured BLE ATT operations:
python3 bletool.py -a capture.jsonExample output:
Analyzing: capture.json
WRITE HANDLES
----------------------------------------
Handle: 0x0004 0x12 Write Request 1 packets
Handle: 0x002d 0x12 Write Request 2 packets
Handle: 0x0033 0x12 Write Request 1 packets
Handle: 0x0037 0x12 Write Request 1 packets
Handle: 0x003d 0x12 Write Request 2 packets
Handle: 0x0030 0x12 Write Request 27 packets
READ HANDLES
----------------------------------------
Handle: 0x0045 0x0a Read Request 1 packets
Handle: 0x0047 0x0a Read Request 1 packets
NOTIFICATION HANDLES
----------------------------------------
Handle: 0x0032 0x1b Notification 34 packets
OTHER HANDLES
----------------------------------------
Handle: 0x0004 0x01 Unknown 1 packets
Handle: 0x0004 0x13 Unknown 1 packets
Handle: 0x0005 0x01 Unknown 1 packets
Handle: 0x0048 0x01 Unknown 1 packets
Handle: 0x002d 0x13 Unknown 1 packets
Handle: 0x0033 0x13 Unknown 1 packets
Handle: 0x0037 0x13 Unknown 1 packets
Handle: 0x003d 0x13 Unknown 1 packets
Handle: 0x0045 0x0b Unknown 1 packets
Handle: 0x0047 0x0b Unknown 1 packets
Handle: 0x0030 0x13 Unknown 20 packets
Generate a replayable bletool script from the capture:
python3 bletool.py -sg capture.jsonbletool automatically creates:
capture.bts
The generated script preserves:
- Target device address
- Characteristic read operations
- Characteristic write operations
- Notification subscriptions
- Timing between BLE operations
Execute the generated script:
python3 bletool.py -sc capture.btsEnable verbose output:
python3 bletool.py -sc capture.bts -vOptionally save the replay output to a file:
python3 bletool.py -sc capture.bts -o replay.logCurrent support includes:
- Wireshark JSON exports generated from Nordic nRF Sniffer captures
Planned support:
- Android BTSnoop captures
- Additional Wireshark export formats
Launch the interactive BLE CLI:
python3 bletool.py -IOptionally preload a target MAC address:
python3 bletool.py -I -b AA:BB:CC:DD:EE:FFThe enum command provides a formatted overview of the connected device's GATT database, making it easier to understand the device structure during reverse engineering and protocol analysis.
The table includes:
- Service handle ranges
- Service names and UUIDs
- Characteristic declaration and value handles
- Characteristic properties
- Readable characteristic values (when supported)
Run:
enumExample output:
Handles Service / Characteristic Properties Value
--------------------------------------------------------------------------------------------------------------
0001 -> 0027 Generic Attribute Profile (1801)
0002 -> 0003 Service Changed INDICATE
0028 -> 002D Vendor Specific (FFFF)
0029 -> 002A FF01 WRITE
002B -> 002C FF02 READ, NOTIFY
002E -> 0033 70D51000-2C7F-4E75-AE8A-D758951CE4E0
002F -> 0030 70D51001-2C7F-4E75-AE8A-D758951CE4E0 READ, WRITE 11223344
0031 -> 0032 70D51002-2C7F-4E75-AE8A-D758951CE4E0 READ, NOTIFY 11223344
0034 -> 0040 Vendor Specific (8018)
0035 -> 0036 8020 WRITE, INDICATE
0038 -> 0039 8021 READ, INDICATE
003B -> 003C 8022 WRITE, INDICATE
003E -> 003F 8023 WRITE, INDICATE
0041 -> FFFF Device Information (180A)
0042 -> 0043 Model Number String READ AC Infinity
0044 -> 0045 Hardware Revision String READ 1.1
0046 -> 0047 Software Revision String READ 3.2.25
This command provides a concise overview of the device's GATT layout, allowing researchers to quickly identify services, characteristics, supported operations, and readable values without manually querying individual attributes.
List all discovered characteristics:
characteristicsShow handle-to-UUID mappings:
handlesExample:
Handle: 43 (0x002B) | Estimated Char value handle: 44 (0x002C) -> UUID: 0000ff02-0000-1000-8000-00805f9b34fb | Properties: ['read', 'notify']
Hex Handle Support
bletool supports decimal handles, hexadecimal handles, and estimated characteristic value handles.
Examples:
read-char 47
read-char 0x2F
read-char 48
read-char 0x30All handle formats are automatically normalized to the correct BLE characteristic UUID.
Once a characteristic is selected, commands such as read-char, char-write-cmd, and char-write-req can be executed without specifying the handle again.
Select a characteristic by handle:
select 43Or by UUID:
select 0000ff02-0000-1000-8000-00805f9b34fbDeselect the current characteristic:
deselectExample workflow:
select 47
read-char
select 47
char-write-cmd 0100Read by handle:
read-char 43Read by UUID:
read-char 0000ff02-0000-1000-8000-00805f9b34fbRead the currently selected characteristic:
select 43
read-charchar-write-req <handle> <hex-data>Example:
char-write-req 43 0100char-write-cmd <handle> <hex-data>Example:
char-write-cmd 43 0100select 43
char-write-cmd 0100Replay the last write operation:
replayUseful for:
- Protocol testing
- Replay validation
- Reverse engineering workflows
- Device state analysis
Start notifications:
notify <handle> startExample:
notify 43 startStop notifications:
notify <handle> stopExample:
notify 43 stopStop all active notifications:
notify stopView notification status:
notify statusExample status output:
Handle 43: Running
Handle 49: Stopped
Example notification output:
[NOTIFY] 43: 01020304
Control how incoming notification data is displayed.
Show current settings:
notify-display statusEnable timestamps:
notify-display timestamps onDisable timestamps:
notify-display timestamps offEnable packet counters:
notify-display counters onDisable packet counters:
notify-display counters offEnable alternating row colors:
notify-display colors onDisable alternating row colors:
notify-display colors offEnable byte-level diff highlighting:
notify-display diffs onDisable diff highlighting:
notify-display diffs offExample status output:
{
'timestamps': False,
'counters': False,
'diffs': False,
'colors': False
}
Example notification output with timestamps and counters enabled:
[19:55:37.191] [22] 70d51002-2c7f-4e75-ae8a-d758951ce4e0 (Handle: 49): 1eff0209073000420c0c182000be00000001f0000000ffff0002f00000003db80602f0000080ffff0008f0000080ffff0008f0000000
When diff highlighting is enabled, changed bytes between consecutive notifications are visually highlighted, making it easier to identify protocol fields that change in response to device activity.
Some BLE devices disconnect when idle. The keep-alive feature periodically writes data to a characteristic to maintain the connection.
Start keep-alive:
keep-alive <handle> <hex-data> startExample:
keep-alive 43 0100 startStop keep-alive:
keep-alive stopCheck keep-alive status:
keep-alive statusDump advertisement and GATT information to JSON:
dump mydeviceCreates:
mydevice.json
The dump includes:
- Advertisement data
- RSSI
- Manufacturer data
- Services
- Characteristics
- Descriptors
Display current session information:
infoExample output:
MAC: AA:BB:CC:DD:EE:FF
Connected: True
Selected Char: 43
Last Write:
{
'uuid': '0000ff01-0000-1000-8000-00805f9b34fb',
'data': b'\x01\x00'
}
Display command help:
helpExit the interactive session:
exitor
quitUpcoming features include:
- Android btsnoop replay generation
- Notification-aware scripting
- Additional ATT opcode support
- Improved protocol decoding
- Enhanced replay controls
bletool is intended for:
- BLE security research
- BLE reverse engineering
- Protocol analysis
- Device interoperability testing
- BLE automation and scripting
- Device fuzzing and experimentation
- Educational use
- Authorized security assessments
Always obtain permission before testing devices you do not own.
This project is licensed under the MIT License.