usb-tools / nu-map

nü-map: a somewhat-more-modern (expeirmental) derivative of umap2 for modern FaceDancer
GNU Affero General Public License v3.0
23 stars 11 forks source link

numap-emulate -C mass_storage fails to emulate #12

Open keesj opened 3 years ago

keesj commented 3 years ago

numap-emulate -C mass_storage

numap-emulate -C mass_storage fails with s = self.strings[num - 1].encode('utf-16') AttributeError: 'bytes' object has no attribute 'encode'

The main reason is that the serial number in the descriptor is actually a byte array

DEBUG:numap:[MassStorageDevice] get_string_descriptor: 0x3 (0x4)
[ERROR ] Traceback (most recent call last):

"Fixed" this issue by converting the byte array to a string e.g.

diff --git a/numap/dev/mass_storage.py b/numap/dev/mass_storage.py
index 1db061c..577ed0f 100644
--- a/numap/dev/mass_storage.py
+++ b/numap/dev/mass_storage.py
@@ -528,7 +528,7 @@ class USBMassStorageDevice(USBDevice):
             device_rev=rev,
             manufacturer_string='PNY',
             product_string='USB 2.0 FD',
-            serial_number_string=b'4731020ef1914da9',
+            serial_number_string='4731020ef1914da9',
             configurations=[
                 USBConfiguration(
                     app=app,
ERROR:numap:Traceback (most recent call last):
  File "/home/pentest/projects/nu-map/numap/apps/emulate.py", line 42, in run
    self.dev.run()
  File "/home/pentest/projects/Facedancer/facedancer/USBDevice.py", line 165, in run
    self.scheduler.run()
  File "/home/pentest/projects/Facedancer/facedancer/core.py", line 509, in run
    task()
  File "/home/pentest/projects/Facedancer/facedancer/USBDevice.py", line 83, in <lambda>
    self.scheduler.add_task(lambda : self.maxusb_app.service_irqs())
  File "/home/pentest/projects/Facedancer/facedancer/backends/greatdancer.py", line 765, in service_irqs
    self._handle_setup_events()
  File "/home/pentest/projects/Facedancer/facedancer/backends/greatdancer.py", line 368, in _handle_setup_events
    self._handle_setup_event_on_endpoint(i)
  File "/home/pentest/projects/Facedancer/facedancer/backends/greatdancer.py", line 402, in _handle_setup_event_on_endpoint
    self.connected_device.handle_request(request)
  File "/home/pentest/projects/Facedancer/facedancer/USBDevice.py", line 251, in handle_request
    handler(req)
  File "/home/pentest/projects/Facedancer/facedancer/USBDevice.py", line 326, in handle_get_descriptor_request
    response = response(dindex)
  File "/home/pentest/projects/nu-map/numap/core/usb_device.py", line 290, in handle_get_string_descriptor_request
    return self.get_string_descriptor(num)
  File "/home/pentest/projects/nu-map/numap/fuzz/helpers.py", line 81, in wrapper
    raise e
  File "/home/pentest/projects/nu-map/numap/fuzz/helpers.py", line 77, in wrapper
    response = func(self, *args, **kwargs)
  File "/home/pentest/projects/nu-map/numap/core/usb_device.py", line 269, in get_string_descriptor
    s = self.strings[num - 1].encode('utf-16')
AttributeError: 'bytes' object has no attribute 'encode'
straithe commented 2 years ago

Are you still experiencing this issue, @keesj ?

keesj commented 2 years ago

I just updated the software (nu-map and Facedancer) and yes the issue is still there log.txt

straithe commented 2 years ago

Thank you for the update! I don't have the skills to assist you yet, and my team is spread pretty thin at the moment, but I'll make sure we get to this as soon as we can.