如何通过Scapy发送蓝牙Rfcommsocket



我用此代码设置了一个bluetoothrfcommsocket:

    from scapy.layers.bluetooth import *
    from scapy.all import *
    bt = BluetoothRFCommSocket('68:A0:3E:CC:24:06',2)

错误是:

    Traceback (most recent call last):
      File "test.py", line 3, in <module>
        bt = BluetoothRFCommSocket('68:A0:3E:CC:24:06',2)
      File "/usr/local/lib/python2.7/dist-packages/scapy-2.4.3rc1.dev120-py2.7.egg/scapy/layers/bluetooth.py", line 1229, in __init__
        s.connect((bt_address, port))
      File "/usr/lib/python2.7/socket.py", line 228, in meth
        return getattr(self._sock,name)(*args)
    socket.error: [Errno 22] Invalid argument

设置bluetoothrfcommsocket的正确方法是什么?

我也会遇到此错误。

来自Scapy源代码:

class BluetoothRFCommSocket(BluetoothL2CAPSocket):
"""read/write packets on a connected RFCOMM socket"""
def __init__(self, bt_address, port=0):
    s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                      socket.BTPROTO_RFCOMM)
    s.connect((bt_address, port))
    self.ins = self.outs = s

scapy使用sock_raw来创建套接字,但似乎RFCOMM不支持此套接字。(我也尝试使用C_TYPES和LIBC,但仍会发生错误(

(

用sock_stream替换sock_raw将消除错误。这是毕色使用的方式。

(L2CAP支持SOCK_RAW(

相关内容

  • 没有找到相关文章