secdev / secdev/scapy

Invalid argument when sending Bluetooth packets through srbt()

Open
#3,516 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
12.6k
Forks
2.2k
Avg merge
1d 4h
Merged PRs (30d)
56

Description

Hi, I'm trying to send a Bluetooth packet to a known mac address, I tried the function srbt(), as the code below:

pkts=HCI_Hdr(type=2)/HCI_ACL_Hdr(handle=0x040, PB=0, BC=0)/L2CAP_Hdr(cid=0x0004)/
         ATT_Hdr(opcode=0x52)/ATT_Write_Command(gatt_handle=0x000d,data=bytes(data.buf))
srbt('e8:32:2a:d2:a8:79', pkts, inter=0.1)

But it always has this bug:

Traceback (most recent call last):
  File "get.py", line 48, in <module>
    srbt('e8:32:2a:d2:a8:79', pkts, inter=0.1)
  File "/usr/local/lib/python3.7/dist-packages/scapy/layers/bluetooth.py", line 1580, in srbt
    s = conf.BTsocket(bt_address=bt_address)
  File "/usr/local/lib/python3.7/dist-packages/scapy/layers/bluetooth.py", line 1451, in __init__
    s.connect((bt_address, port))
OSError: [Errno 22] Invalid argument

How can I solve this problem? Or is there another way to send Bluetooth packets to a known mac address?
Thank you very much!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in scapy/layers/bluetooth.py at srbt() around line 1580 and the BTsocket connection around line 1451. Reproduce the reported call and inspect the arguments passed to s.connect(); determine the cause of the Invalid argument error and verify a supported way to send packets to the given Bluetooth address.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.