Exemplo n.º 1
0
 def setUp(self):
     super(MtpDeviceTests, self).setUp()
     self.object = MtpObject.from_fs_recursive('.')
     self.storage_info = MtpStorageInfo(
         st_type=0,
         fs_type=0,
         access=0,
         max_cap=150000,
         free_bytes=0,
         free_objs=0,
         desc='MyStorage',
         vol_id='Python MTP Device Stack',
     )
     self.storage = MtpStorage(self.storage_info)
     self.storage.add_object(self.object)
     self.dev_info = MtpDeviceInfo(
         std_version=0x0102,
         mtp_vendor_ext_id=0x03040506,
         mtp_version=0x0708,
         mtp_extensions='Some Extension',
         functional_mode=0x0000,
         capture_formats=[],
         playback_formats=[],
         manufacturer='BinyaminSharet',
         model='Role',
         device_version='1.2.3',
         serial_number='0123456789abcdef',
     )
     self.dev = MtpDevice(self.dev_info)
     self.dev.add_storage(self.storage)
     self.tid = 1
Exemplo n.º 2
0
 def get_default_storage(self):
     storage_info = MtpStorageInfo(
         st_type=0,
         fs_type=0,
         access=0,
         max_cap=150000000,
         free_bytes=0,
         free_objs=0,
         desc='150MB Storage',
         vol_id='Test Storage',
     )
     storage = MtpStorage(storage_info)
     return storage
Exemplo n.º 3
0
    def __init__(self, app, phy):
        if not mtpdeviceloaded:
            raise Exception('You cannot use USBMtp until you install pymtpdevice')
        # TODO: un-hardcode string index (last arg before 'verbose')
        super(USBMtpInterface, self).__init__(
            app=app,
            phy=phy,
            interface_number=0,
            interface_alternate=0,
            interface_class=USBClass.VendorSpecific,
            interface_subclass=0xff,
            interface_protocol=0,
            interface_string_index=0,
            endpoints=[
                USBEndpoint(
                    app=app,
                    phy=phy,
                    number=1,
                    direction=USBEndpoint.direction_out,
                    transfer_type=USBEndpoint.transfer_type_bulk,
                    sync_type=USBEndpoint.sync_type_none,
                    usage_type=USBEndpoint.usage_type_data,
                    max_packet_size=64,
                    interval=0,
                    handler=self.handle_ep1_data_available
                ),
                USBEndpoint(
                    app=app,
                    phy=phy,
                    number=2,
                    direction=USBEndpoint.direction_in,
                    transfer_type=USBEndpoint.transfer_type_bulk,
                    sync_type=USBEndpoint.sync_type_none,
                    usage_type=USBEndpoint.usage_type_data,
                    max_packet_size=64,
                    interval=0,
                    handler=None
                ),
                USBEndpoint(
                    app=app,
                    phy=phy,
                    number=3,
                    direction=USBEndpoint.direction_in,
                    transfer_type=USBEndpoint.transfer_type_interrupt,
                    sync_type=USBEndpoint.sync_type_none,
                    usage_type=USBEndpoint.usage_type_data,
                    max_packet_size=64,
                    interval=32,
                    handler=None
                ),
            ],
        )
        self.object = MtpObject.from_fs_recursive('mtp_fs')
        # self.object = MtpObject.from_fs_recursive('mtp_fs/eits.mp3')
        self.storage_info = MtpStorageInfo(
            st_type=1,
            fs_type=2,
            access=0,
            max_cap=150000,
            free_bytes=0,
            free_objs=0,
            desc='MyStorage',
            vol_id='Python MTP Device Stack',
        )
        self.storage = MtpStorage(self.storage_info)
        self.storage.add_object(self.object)
        self.dev_info = MtpDeviceInfo(
            std_version=0x0064,
            mtp_vendor_ext_id=0x00000006,
            mtp_version=0x0064,
            mtp_extensions='microsoft.com: 1.0;',
            functional_mode=0x0000,
            capture_formats=[],
            playback_formats=[],
            manufacturer='UMAP2',
            model='Role',
            device_version='1.2',
            serial_number='3031323334353637',
        )
        properties = [
            MtpDeviceProperty(MtpDevicePropertyCode.MTP_DeviceFriendlyName, 0, MStr('UmapMtpDevice'), MStr('')),
            MtpDeviceProperty(MtpDevicePropertyCode.BatteryLevel, 0, UInt8(100), UInt8(0))
        ]
        self.dev = MtpDevice(self.dev_info, properties, self.logger)
        self.dev.add_storage(self.storage)
        self.dev.set_fuzzer(app.fuzzer)
        self.api = MtpApi(self.dev)

        # OS String descriptor
        # self.add_string_with_id(50, 'MTP'.encode('utf-16') + b'\x00\x00')
        self.add_string_with_id(0xee, 'MSFT100'.encode('utf-16') + b'\x00\x00')