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

Update nu-map to python3 #8

Closed sprout42 closed 4 years ago

sprout42 commented 4 years ago

Updated the code to be python3 compatible, making PR as requested in usb-tools/nu-map#1

sprout42 commented 4 years ago

I've been doing some testing and have had some errors. I believe that the byte strings in various such as in numap/dev/audio.py for initializing the USB device object aren't being interpreted correctly now that the code is python3. I'm working on the fixes for this.

ktemkin commented 4 years ago

Thanks a ton for your work on this! I haven't had a chance to look at these or test them; but I hope to get to looking at this in the next few days. :)

For now, I'm assigning @Qyriad to take a look.

sprout42 commented 4 years ago

thanks, I'm not sure how many of these changes are necessary, but they appear to be improving things in my testing. numap-vsscan kind of runs without error after sprout42/nu-map@69cf693, but it hangs at Setting configuration: 0x0. I can't figure out how numap-vsscan would actually timeout between device attempts.

Currently I'm still working on numap-scan to see if I can figure out why it fails here:

$ numap-scan -v
[ALWAYS] Scanning host for supported devices
[ALWAYS] Testing support: audio
[INFO  ] Loading USB device audio
[INFO  ] [AudioDevice] Calling get_descriptor (stage: "device_descriptor")
[INFO  ] [AudioDevice] Response: 12010200000000408c0d0c00010001020301
[INFO  ] [AudioDevice] Calling get_descriptor (stage: "device_descriptor")
[INFO  ] [AudioDevice] Response: 12010200000000408c0d0c00010001020301
[INFO  ] [Interface] Calling get_descriptor (stage: "audio_control_interface_descriptor")
[INFO  ] [Interface] Calling get_descriptor (stage: "interface_descriptor")
[INFO  ] [Interface] Response: 0904000000010100000a2401000164000201020c24020101010002030000000c240202010200010100000009240306010300090009240307010100080007240508010a000a2406090f01010202000924060a02014300000924060d02010300000d24040f02010d020300000000
[INFO  ] [Interface] Response: 0904000000010100000a2401000164000201020c24020101010002030000000c240202010200010100000009240306010300090009240307010100080007240508010a000a2406090f01010202000924060a02014300000924060d02010300000d24040f02010d020300000000
[INFO  ] [Interface] Calling get_descriptor (stage: "audio_streaming_interface_descriptor")
[INFO  ] [Interface] Calling get_descriptor (stage: "interface_descriptor")
[INFO  ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor")
[INFO  ] [ASEndpoint] Calling get_descriptor (stage: "usbcsendpoint_descriptor")
[INFO  ] [ASEndpoint] Response: 07250101010100
[INFO  ] [Endpoint] Response: 0705010940000107250101010100
[INFO  ] [Interface] Response: 090401000101020000072401010101000e2402010202100244ac0044ac000705010940000107250101010100
[INFO  ] [Interface] Response: 090401000101020000072401010101000e2402010202100244ac0044ac000705010940000107250101010100
[INFO  ] [Interface] Calling get_descriptor (stage: "audio_streaming_interface_descriptor")
[INFO  ] [Interface] Calling get_descriptor (stage: "interface_descriptor")
[INFO  ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor")
[INFO  ] [ASEndpoint] Calling get_descriptor (stage: "usbcsendpoint_descriptor")
[INFO  ] [ASEndpoint] Response: 07250101000000
[INFO  ] [Endpoint] Response: 0705820540000107250101000000
[INFO  ] [Interface] Response: 090402000101020000072401070101000e2402010102100244ac0044ac000705820540000107250101000000
[INFO  ] [Interface] Response: 090402000101020000072401070101000e2402010102100244ac0044ac000705820540000107250101000000
[INFO  ] [Interface] Calling get_descriptor (stage: "audio_control_interface_descriptor")
[INFO  ] [Interface] Calling get_descriptor (stage: "interface_descriptor")
[INFO  ] [Interface] Response: 0904000000010100000a2401000164000201020c24020101010002030000000c240202010200010100000009240306010300090009240307010100080007240508010a000a2406090f01010202000924060a02014300000924060d02010300000d24040f02010d020300000000
[INFO  ] [Interface] Response: 0904000000010100000a2401000164000201020c24020101010002030000000c240202010200010100000009240306010300090009240307010100080007240508010a000a2406090f01010202000924060a02014300000924060d02010300000d24040f02010d020300000000
[INFO  ] [Interface] Calling get_descriptor (stage: "audio_streaming_interface_descriptor")
[INFO  ] [Interface] Calling get_descriptor (stage: "interface_descriptor")
[INFO  ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor")
[INFO  ] [ASEndpoint] Calling get_descriptor (stage: "usbcsendpoint_descriptor")
[INFO  ] [ASEndpoint] Response: 07250101010100
[INFO  ] [Endpoint] Response: 0705010940000107250101010100
[INFO  ] [Interface] Response: 090401000101020000072401010101000e2402010202100244ac0044ac000705010940000107250101010100
[INFO  ] [Interface] Response: 090401000101020000072401010101000e2402010202100244ac0044ac000705010940000107250101010100
[INFO  ] [Interface] Calling get_descriptor (stage: "audio_streaming_interface_descriptor")
[INFO  ] [Interface] Calling get_descriptor (stage: "interface_descriptor")
[INFO  ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor")
[INFO  ] [ASEndpoint] Calling get_descriptor (stage: "usbcsendpoint_descriptor")
[INFO  ] [ASEndpoint] Response: 07250101000000
[INFO  ] [Endpoint] Response: 0705820540000107250101000000
[INFO  ] [Interface] Response: 090402000101020000072401070101000e2402010102100244ac0044ac000705820540000107250101000000
[INFO  ] [Interface] Response: 090402000101020000072401070101000e2402010102100244ac0044ac000705820540000107250101000000
[INFO  ] [AudioDevice] Calling get_string0_descriptor (stage: "string_descriptor_zero")
[INFO  ] [AudioDevice] Response: 04030904
[INFO  ] [AudioDevice] Calling get_string_descriptor (stage: "string_descriptor")
[DEBUG ] [AudioDevice] get_string_descriptor: 0x2 (0x4)
[INFO  ] [AudioDevice] Response: 280355004d00410050003200200041007500640069006f0020004100640061007000740065007200
[INFO  ] [AudioDevice] Calling get_string_descriptor (stage: "string_descriptor")
[DEBUG ] [AudioDevice] get_string_descriptor: 0x1 (0x4)
[INFO  ] [AudioDevice] Response: 220355004d00410050003200200053006f0075006e006400200049006e0063002e00
[INFO  ] [AudioDevice] Calling get_string_descriptor (stage: "string_descriptor")
[DEBUG ] [AudioDevice] get_string_descriptor: 0x3 (0x4)
[INFO  ] [AudioDevice] Response: 240355004d004100500032002d00310032003300340035002d0041005500440049004f00
[DEBUG ] [AudioDevice] Received SET_CONFIGURATION request
[DEBUG ] [AudioDevice] dir=0, type=0, rec=0, r=9, v=1, i=0, l=0
[DEBUG ] [AudioDevice] [<USBConfiguration index=1 num_interfaces=3 attributes=0x80 max_power=100mA>]
[INFO  ] [AudioDevice] Setting configuration: 0x0
[INFO  ] [AudioDevice] Calling get_string_descriptor (stage: "string_descriptor")
[DEBUG ] [AudioDevice] get_string_descriptor: 0x2 (0x4)
[INFO  ] [AudioDevice] Response: 280355004d00410050003200200041007500640069006f0020004100640061007000740065007200
[INFO  ] [AudioDevice] Calling get_string_descriptor (stage: "string_descriptor")
[DEBUG ] [AudioDevice] get_string_descriptor: 0x1 (0x4)
[INFO  ] [AudioDevice] Response: 220355004d00410050003200200053006f0075006e006400200049006e0063002e00
[DEBUG ] [Interface] Received SET_INTERFACE request
[ERROR ] Traceback (most recent call last):
  File "/home/user/.local/lib/python3.7/site-packages/numap-2.0.2-py3.7.egg/numap/apps/scan.py", line 50, in run
    device.run()
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/USBDevice.py", line 166, in run
    self.scheduler.run()
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/core.py", line 506, in run
    task()
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/USBDevice.py", line 84, in <lambda>
    self.scheduler.add_task(lambda : self.maxusb_app.service_irqs())
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/backends/GreatDancerApp.py", line 756, in service_irqs
    self._handle_transfer_events()
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/backends/GreatDancerApp.py", line 470, in _handle_transfer_events
    self._handle_transfer_complete_on_endpoint(i, self.HOST_TO_DEVICE)
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/backends/GreatDancerApp.py", line 556, in _handle_transfer_complete_on_endpoint
    self.connected_device.handle_request(self.pending_control_request)
  File "/home/user/.local/lib/python3.7/site-packages/Facedancer-testing-py3.7.egg/facedancer/USBDevice.py", line 236, in handle_request
    handler_entity = recipient.device_class
Qyriad commented 4 years ago

I fixed the AttributeError in usb-tools/facedancer#35. I'm still looking at the rest.

sprout42 commented 4 years ago

I probably went too far, but last week I was pretty sure there were some conflicts in how the logic that used to be part of nccgroup/umap2 was now split between this repo and usb-tools/Facedancer. I have two branches for nu-map and Facedancer I'm testing with:

These changes have gone further than just "python3" fixing so I didn't put them on this branch. But I can pull them in if you feel it is appropriate.

I've got everything working on those branches BUT I appear to get a hang somewhere in the low-level GreatDancer code (https://github.com/usb-tools/Facedancer/blob/master/facedancer/backends/GreatDancerApp.py) when using numap-scan (for testing I'm scanning a raspberry PI I have).

ktemkin commented 4 years ago

Thanks so much for your work on nu-map. :)

I manually squashed-and-merged the py3 fixes from this PR, so I'm going to close the PR itself. It might be a good idea to move future discussions to an issue?

I'd suggest hopping over into #1 for future discussion. :)