Exemplo n.º 1
0
    AS_DESCRIPTOR_UNDEFINED = 0x00
    AS_GENERAL = 0x01
    FORMAT_TYPE = 0x02
    FORMAT_SPECIFIC = 0x03


# TODO: audio_ep2_buffer_available

# TODO: remove?
audio_header_descriptor = Descriptor(
    name='audio_header_descriptor',
    descriptor_type=_DescriptorTypes.CS_INTERFACE,
    fields=[
        UInt8(name='bDesciptorSubType', value=_AC_DescriptorSubTypes.HEADER),
        LE16(name='bcdADC', value=0x0100),
        LE16(name='wTotalLength', value=0x1e),
        UInt8(name='bInCollection', value=0x1),
        Repeat(UInt8(name='baInterfaceNrX', value=1), 0, 247)
    ])

# TODO: remove?
audio_input_terminal_descriptor = Descriptor(
    descriptor_type=_DescriptorTypes.CS_INTERFACE,
    name='audio_input_terminal_descriptor',
    fields=[
        UInt8(name='bDesciptorSubType',
              value=_AC_DescriptorSubTypes.INPUT_TERMINAL),
        UInt8(name='bTerminalID', value=0x00),
        LE16(name='wTerminalType', value=0x0206),  # termt10.pdf table 2-2
        UInt8(name='bAssocTerminal', value=0x00),
Exemplo n.º 2
0
                          ]))
        index += num_args
    return OneOf(name=name,
                 fields=[
                     Container(name='generation', fields=fields),
                     MutableField(name='mutation', value=report_str),
                     RandomHidReport(name='random_sequences'),
                 ])


# ############### Templates ############### #

hid_descriptor = Descriptor(name='hid_descriptor',
                            descriptor_type=DescriptorType.hid,
                            fields=[
                                DynamicInt('bcdHID', LE16(value=0x0110)),
                                DynamicInt('bCountryCode', UInt8(value=0x00)),
                                DynamicInt('bNumDescriptors',
                                           UInt8(value=0x01)),
                                DynamicInt('bDescriptorType2',
                                           UInt8(value=DescriptorType.hid)),
                                DynamicInt('wDescriptorLength',
                                           LE16(value=0x27)),
                            ])

# this descriptor is based on umap
# https://github.com/nccgroup/umap
# commit 3ad812135f8c34dcde0e055d1fefe30500196c0f
hid_report_descriptor = Template(
    name='hid_report_descriptor',
    fields=GenerateHidReport(
Exemplo n.º 3
0
            DescriptorType.hub,
            self.num_ports,
            self.hub_chars,
            self.pwr_on_2_pwr_good,
            self.hub_contr_current,
        )
        num_bytes = self.num_ports // 7
        if self.num_ports % 7 != 0:
            num_bytes += 1
        d += b'\x00' * num_bytes
        d += b'\xff' * num_bytes
        d = struct.pack('B', len(d) + 1) + d
        return d
'''

hub_descriptor = Descriptor(name='hub_descriptor',
                            descriptor_type=DescriptorType.hub,
                            fields=[
                                Size(name='bNbrPorts',
                                     sized_field='DeviceRemovable',
                                     length=8,
                                     calc_func=lambda x: len(x) * 7),
                                LE16(name='wHubCharacteristics', value=0x0000),
                                UInt8(name='bPwrOn2PwrGood', value=0x00),
                                UInt8(name='bHubContrCurrent', value=0x02),
                                RandomBytes(name='DeviceRemovable',
                                            value=b'\x00',
                                            min_length=0,
                                            max_length=250),
                            ])
Exemplo n.º 4
0
            MutableField(
                name='mutation',
                value=report_str
            ),
            RandomHidReport(
                name='random_sequences'
            ),
        ])

# ############### Templates ############### #

hid_descriptor = Descriptor(
    name='hid_descriptor',
    descriptor_type=DescriptorType.hid,
    fields=[
        DynamicInt('bcdHID', LE16(value=0x0110)),
        DynamicInt('bCountryCode', UInt8(value=0x00)),
        DynamicInt('bNumDescriptors', UInt8(value=0x01)),
        DynamicInt('bDescriptorType2', UInt8(value=DescriptorType.hid)),
        DynamicInt('wDescriptorLength', LE16(value=0x27)),
    ])


# this descriptor is based on umap
# https://github.com/nccgroup/umap
# commit 3ad812135f8c34dcde0e055d1fefe30500196c0f
hid_report_descriptor = Template(
    name='hid_report_descriptor',
    fields=GenerateHidReport(
        binascii.a2b_hex('05010906A101050719E029E7150025017501950881029501750881011900296515002565750895018100C0')
    )
Exemplo n.º 5
0
Arquivo: cdc.py Projeto: xairy/nu-map
                         fuzzable=False),
                   UInt8(name='bInterfaceSubClass',
                         value=CommunicationClassSubclassCodes.Reserved,
                         fuzzable=False),
                   UInt8(name='bInterfaceProtocol', value=0x00),
                   UInt8(name='iInterface', value=0x01),
               ]),
 List(
     name='Class-Specific interfaces',
     fields=[
         SubDescriptor(name='cdc_header_functional_descriptor',
                       descriptor_type=DescriptorType.cs_interface,
                       fields=[
                           UInt8(name='bDesciptorSubType',
                                 value=FunctionalDescriptor.Header),
                           LE16(name='bcdCDC', value=0x0101)
                       ]),
         SubDescriptor(name='cdc_call_management_functional_descriptor',
                       descriptor_type=DescriptorType.cs_interface,
                       fields=[
                           UInt8(name='bDesciptorSubType',
                                 value=FunctionalDescriptor.CM),
                           BitField(name='bmCapabilities',
                                    value=0,
                                    length=8),
                           UInt8(name='bDataInterface', value=2)
                       ]),
         SubDescriptor(
             name=
             'cdc_abstract_control_management_functional_descriptor',
             descriptor_type=DescriptorType.cs_interface,
Exemplo n.º 6
0
Arquivo: cdc.py Projeto: 0xd3d0/umap2
    NETWORK_CHANNEL_TERMINAL = 0xa
    PROTOCOL_UNIT = 0xb
    EXTENSION_UNIT = 0xc
    MULTI_CHANNEL_MANAGEMENT = 0xd
    CAPI_CONTROL_MANAGEMENT = 0xe
    ETHERNET_NETWORKING = 0xf
    ATM_NETWORKING = 0x10
    # 0x11-0xff reserved


cdc_header_functional_descriptor = Descriptor(
    name='cdc_header_functional_descriptor',
    descriptor_type=_DescriptorTypes.CS_INTERFACE,
    fields=[
        UInt8(name='bDesciptorSubType', value=_CDC_DescriptorSubTypes.HEADER_FUNCTIONAL),
        LE16(name='bcdCDC', value=0xffff)
    ])


cdc_call_management_functional_descriptor = Descriptor(
    name='cdc_call_management_functional_descriptor',
    descriptor_type=_DescriptorTypes.CS_INTERFACE,
    fields=[
        UInt8(name='bDesciptorSubType', value=_CDC_DescriptorSubTypes.CALL_MANAGMENT),
        BitField(name='bmCapabilities', value=0, length=8),
        UInt8(name='bDataInterface', value=0)
    ])


# TODO: Missing descriptors for subtypes 3,4,5
Exemplo n.º 7
0
# containers
from kitty.model import Template, Container, List
# dynamic fields
from kitty.model import ElementCount, SizeInBytes
# encoders
from kitty.model import StrEncodeEncoder, ENC_INT_LE
from generic import Descriptor, SubDescriptor

# Device descriptor
# Section 9.6.1, page 261
device_descriptor = Descriptor(
    name='device_descriptor',
    descriptor_type=DescriptorType.device,
    fields=[
        LE16(
            name='bcdUSB', value=0x0100
        ),  # USB 2.0 is reported as 0x0200, USB 1.1 as 0x0110 and USB 1.0 as 0x0100
        UInt8(name='bDeviceClass', value=0),
        UInt8(name='bDeviceSubClass', value=0),
        UInt8(name='bDeviceProtocol', value=0),
        UInt8(name='bMaxPacketSize', value=64),  # valid sizes: 8,16,32,64
        LE16(name='idVendor', value=0),
        LE16(name='idProduct', value=0),
        LE16(name='bcdDevice', value=0),
        UInt8(name='iManufacturer', value=0),
        UInt8(name='iProduct', value=0),
        UInt8(name='iSerialNumber', value=0),
        UInt8(name='bNumConfigurations', value=0)
    ])

# Device qualifier descriptor