facedancer icon indicating copy to clipboard operation
facedancer copied to clipboard

USBMassStorageInterface / USBEndpoint object has no attribute device_class

Open bhass1 opened this issue 5 years ago • 3 comments

While testing numap-scan from nu-map's (https://github.com/sprout42/nu-map/tree/umap2_python3_updates) against facedancer's current master branch (2281b57b579f), I encounter the following error:

[ERROR ] Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/numap-2.0.2-py3.6.egg/numap/apps/scan.py", line 50, in run device.run() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 166, in run self.scheduler.run() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/core.py", line 506, in run task() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 84, in self.scheduler.add_task(lambda : self.maxusb_app.service_irqs()) File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/backends/GreatDancerApp.py", line 756, in service_irqs self._handle_transfer_events() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/backends/GreatDancerApp.py", line 470, in _handle_transfer_events self._handle_transfer_complete_on_endpoint(i, self.HOST_TO_DEVICE) File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/backends/GreatDancerApp.py", line 556, in _handle_transfer_complete_on_endpoint self.connected_device.handle_request(self.pending_control_request) File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 236, in handle_request handler_entity = recipient.device_class AttributeError: 'USBEndpoint' object has no attribute 'device_class'

I still need to investigate a bit further to see why USBEndpoint causes this.

bhass1 avatar Feb 14 '20 21:02 bhass1

I get a similar issue when trying to use numap-emulate -C mass_storage :

[ERROR ] Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/numap-2.0.2-py3.6.egg/numap/apps/emulate.py", line 42, in run self.dev.run() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 166, in run self.scheduler.run() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/core.py", line 506, in run task() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 84, in self.scheduler.add_task(lambda : self.maxusb_app.service_irqs()) File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/backends/GreatDancerApp.py", line 755, in service_irqs self._handle_setup_events() File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/backends/GreatDancerApp.py", line 362, in _handle_setup_events self._handle_setup_event_on_endpoint(i) File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/backends/GreatDancerApp.py", line 396, in _handle_setup_event_on_endpoint self.connected_device.handle_request(request) File "/usr/local/lib/python3.6/dist-packages/Facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 236, in handle_request handler_entity = recipient.device_class AttributeError: 'USBMassStorageInterface' object has no attribute 'device_class'

bhass1 avatar Feb 14 '20 22:02 bhass1

By the way, this appears to be DUT (device-under-test) behavior related. Mass-storage emulator worked when the DUT was my Ubuntu 18.04 laptop, but not the other DUT I am focused on. I will try to post more logs tonight.

And I am using GreatFET One with the latest firmware and host-tools.

bhass1 avatar Feb 20 '20 14:02 bhass1

numap-scan log (not DUT dependent, both choke on the same packet from host): image After decoding and looking back at the error, things are starting to make sense. The host is sending a SETUP packet with a "class" type with the "endpoint" as the recipient. Then I guess a bRequest = 1 isn't being handled by the endpoint. In this case, the first class of devices being scanned for is Audio. Below is the emulated Audio configuration. emulated_audio

The question I have is whether this issue belongs in Facedancer or Numap. At a minimum I think Facedancer should handle all request types more gracefully... Maybe catch the exception, print a statement about unhandled request, and continue to raise the exception?

On the other hand, if the host is asking us to do something with the Audio class' endpoint, the numap-scan can probably assume the host supports audio peripherals and move on, right?

bhass1 avatar Feb 21 '20 02:02 bhass1