Python socket.BTPROTO_L2CAP Examples

The following are 17 code examples of socket.BTPROTO_L2CAP(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module socket , or try the search function .
Example #1
Source File: btk_server.py    From keyboard_mouse_emulate_on_raspberry with MIT License 8 votes vote down vote up
def listen(self):
		print("Waiting for connections")
		self.scontrol = socket.socket(
		    socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)  # BluetoothSocket(L2CAP)
		self.sinterrupt = socket.socket(
		    socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)  # BluetoothSocket(L2CAP)
		self.scontrol.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
		self.sinterrupt.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
		# bind these sockets to a port - port zero to select next available
		self.scontrol.bind((socket.BDADDR_ANY, self.P_CTRL))
		self.sinterrupt.bind((socket.BDADDR_ANY, self.P_INTR))

		# Start listening on the server sockets
		self.scontrol.listen(5)  # Limit of 1 connection
		self.sinterrupt.listen(5)

		self.ccontrol, cinfo = self.scontrol.accept()
		print ("Got a connection on the control channel from " + cinfo[0])

		self.cinterrupt, cinfo = self.sinterrupt.accept()
		print ("Got a connection on the interrupt channel from " + cinfo[0])

	# send a string to the bluetooth host machine 
Example #2
Source File: bluetooth.py    From dash-hack with MIT License 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #3
Source File: bluetooth.py    From arissploit with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #4
Source File: bluetooth.py    From kamene with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #5
Source File: bluetooth.py    From POC-EXP with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #6
Source File: BluetoothSocket.py    From pybleno with MIT License 5 votes vote down vote up
def _connect(self, sa):
        r = self.libc.connect(self.fileno(), self.libc.string(sa), len(sa))
        if r != 0:
            raise IOError(get_errno(), os.strerror(get_errno()))

    # connect to BTPROTO_L2CAP socket 
Example #7
Source File: BluetoothSocket.py    From pybleno with MIT License 5 votes vote down vote up
def _bind(self, sa):
        r = self.libc.bind(self.fileno(), self.libc.string(sa), len(sa))
        if r != 0:
            raise IOError(get_errno(), os.strerror(get_errno()))

    # bind to BTPROTO_L2CAP socket 
Example #8
Source File: BluetoothHCI.py    From pybleno with MIT License 5 votes vote down vote up
def kernel_disconnect_workarounds(self, data):
        #print 'PRE KERNEL WORKAROUND %d' % len(data)
        
        def noop(value):
            return value
            
        if (sys.version_info > (3, 0)):
            ord = noop
        else:
            import __builtin__
            ord = __builtin__.ord
        
        if len(data) == 22 and [ord(elem) for elem in data[0:5]] == [0x04, 0x3e, 0x13, 0x01, 0x00]:
            handle = ord(data[5])
            # get address
            set = data[9:15]
            # get device info
            dev_info = self.get_device_info()
            raw_set = [ord(c) for c in set]
            raw_set.reverse()
            #addz = ''.join([hex(c) for c in set])
            #set.reverse()
            addz = "%02x:%02x:%02x:%02x:%02x:%02x" % struct.unpack("BBBBBB", array.array('B', raw_set))
            socket2 = BluetoothSocket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)
            
            socket2.bind_l2(0, dev_info['addr'], cid=ATT_CID, addr_type=0)#addr_type=dev_info['type'])
            
            self._l2sockets[handle] = socket2
            try:
                result = socket2.connect_l2(0, addz, cid=ATT_CID, addr_type=ord(data[8]) + 1)
            except:
                pass
        elif len(data) == 7 and [ord(elem) for elem in data[0:4]] == [0x04, 0x05, 0x04, 0x00]:
            handle = ord(data[4])
            
            socket2 = self._l2sockets[handle] if handle in self._l2sockets else None
            if socket2:
                # print 'GOT A SOCKET!'
                socket2.close()
                del self._l2sockets[handle] 
Example #9
Source File: btsock.py    From blueborne with GNU General Public License v3.0 5 votes vote down vote up
def l2cap_connect(dst, src=None, mtu=None):
    sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_SEQPACKET, socket.BTPROTO_L2CAP)
    if src is not None:
        sock.bind(src)
    if mtu is not None:
        set_imtu(sock, mtu)
    sock.connect(dst)
    return sock 
Example #10
Source File: bluetooth.py    From isip with MIT License 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #11
Source File: bluetooth.py    From CyberScan with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #12
Source File: bluetooth.py    From dash-hack with MIT License 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #13
Source File: bluetooth.py    From dash-hack with MIT License 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #14
Source File: bluetooth.py    From scapy with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, bt_address):
        if WINDOWS:
            warning("Not available on Windows")
            return
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((bt_address, 0))
        self.ins = self.outs = s 
Example #15
Source File: bluetooth.py    From mptcp-abuse with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #16
Source File: bluetooth.py    From CVE-2016-6366 with MIT License 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s 
Example #17
Source File: bluetooth.py    From smod-1 with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, peer):
        s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW,
                          socket.BTPROTO_L2CAP)
        s.connect((peer,0))
        
        self.ins = self.outs = s