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

AttributeError: 'USBKeyboardInterface' object has no attribute 'device_class' #4

Closed hwgross closed 4 years ago

hwgross commented 4 years ago

Hi,

I am currently struggling with getting the nu-map to work but also have issues with facedancer itself.

The short version: When I clone nu-map and run:

python3 emulate.py -C keyboard

I get following error: File "/usr/local/lib/python3.6/dist-packages/facedancer-2019.3.2-py3.6.egg/facedancer/USBDevice.py", line 234, in handle_request handler_entity = recipient.device_class AttributeError: 'USBKeyboardInterface' object has no attribute 'device_class'

More details below: Steps done: 1) Setup a raw Ubuntu 18.04.3-desktop-amd64.iso in VirtualBox 2) sudo apt install python3-pip 3) pip3 install --upgrade --user greatfet 4) sudo wget https://raw.githubusercontent.com/greatscottgadgets/greatfet/master/host/misc/54-greatfet.rules -O /etc/udev/rules.d/54-greatfet.rules 5) sudo udevadm control --reload-rules 6) reboot 7) connect GreatFET One 8) gf info --> Found a GreatFET One! … Facedancer: 1) git clone https://github.com/usb-tools/Facedancer 2) cd Facedancer 3) ./facedancer-keyboard.py TypeError: unexpected return RPC read_setup; innner message: int() argument must be a string, a bytes-like object or a number, not 'tuple'; format: <8X 4) nedit /home/imp/.local/lib/python3.6/site-packages/pygreat/comms.py --> change “match.groups(1)” to “match[1]” 5) ./facedancer-keyboard.py works now but device not recognized by Windows device manager Next try nu-map 1) git clone https://github.com/usb-tools/nu-map 2) cd nu-map 3) sudo python3 setup.py install 4) python3 ./numap/apps/emulate.py -C keyboard [INFO ] Loading USB device keyboard [INFO ] [KeyboardDevice] Calling get_descriptor (stage: "device_descriptor") [INFO ] [KeyboardDevice] Response: b'12010200000000400b615346341201020301' [INFO ] [KeyboardDevice] Calling get_descriptor (stage: "device_descriptor") [INFO ] [KeyboardDevice] Response: b'12010200000000400b615346341201020301' [INFO ] [KeyboardInterface] Calling get_descriptor (stage: "interface_descriptor") [INFO ] [KeyboardInterface] Calling get_hid_descriptor (stage: "hid_descriptor") [INFO ] [KeyboardInterface] Calling get_report_descriptor (stage: "hid_report_descriptor") [INFO ] [KeyboardInterface] Response: b'05010906a101050719e029e7150025017501950881029501750881011900296515002565750895018100c0' [INFO ] [KeyboardInterface] Response: b'092110010001222b00' [INFO ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor") [INFO ] [Endpoint] Response: b'07058203400040' [INFO ] [KeyboardInterface] Response: b'090400000103000000092110010001222b0007058203400040' [INFO ] [KeyboardDevice] Calling get_string_descriptor (stage: "string_descriptor") [INFO ] [KeyboardDevice] Response: b'0c0330003000300030003100' [INFO ] [KeyboardDevice] Calling get_string0_descriptor (stage: "string_descriptor_zero") [INFO ] [KeyboardDevice] Response: b'04030904' [INFO ] [KeyboardDevice] Calling get_string_descriptor (stage: "string_descriptor") [INFO ] [KeyboardDevice] Response: b'3003440065006c006c002000550053004200200045006e0074007200790020004b006500790062006f00610072006400' [INFO ] [KeyboardDevice] Calling get_descriptor (stage: "device_descriptor") [INFO ] [KeyboardDevice] Response: b'12010200000000400b615346341201020301' [INFO ] [KeyboardDevice] Calling get_string0_descriptor (stage: "string_descriptor_zero") [INFO ] [KeyboardDevice] Response: b'04030904' [INFO ] [KeyboardDevice] Calling get_string_descriptor (stage: "string_descriptor") [INFO ] [KeyboardDevice] Response: b'0c0330003000300030003100' [INFO ] [KeyboardDevice] Calling get_string_descriptor (stage: "string_descriptor") [INFO ] [KeyboardDevice] Response: b'0a03440065006c006c00' [INFO ] [KeyboardDevice] Calling get_string_descriptor (stage: "string_descriptor") [INFO ] [KeyboardDevice] Response: b'3003440065006c006c002000550053004200200045006e0074007200790020004b006500790062006f00610072006400' [INFO ] [KeyboardDevice] Calling get_descriptor (stage: "device_descriptor") [INFO ] [KeyboardDevice] Response: b'12010200000000400b615346341201020301' [INFO ] [KeyboardInterface] Calling get_descriptor (stage: "interface_descriptor") [INFO ] [KeyboardInterface] Calling get_hid_descriptor (stage: "hid_descriptor") [INFO ] [KeyboardInterface] Calling get_report_descriptor (stage: "hid_report_descriptor") [INFO ] [KeyboardInterface] Response: b'05010906a101050719e029e7150025017501950881029501750881011900296515002565750895018100c0' [INFO ] [KeyboardInterface] Response: b'092110010001222b00' [INFO ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor") [INFO ] [Endpoint] Response: b'07058203400040' [INFO ] [KeyboardInterface] Response: b'090400000103000000092110010001222b0007058203400040' [INFO ] [KeyboardInterface] Calling get_descriptor (stage: "interface_descriptor") [INFO ] [KeyboardInterface] Calling get_hid_descriptor (stage: "hid_descriptor") [INFO ] [KeyboardInterface] Calling get_report_descriptor (stage: "hid_report_descriptor") [INFO ] [KeyboardInterface] Response: b'05010906a101050719e029e7150025017501950881029501750881011900296515002565750895018100c0' [INFO ] [KeyboardInterface] Response: b'092110010001222b00' [INFO ] [Endpoint] Calling get_descriptor (stage: "endpoint_descriptor") [INFO ] [Endpoint] Response: b'07058203400040' [INFO ] [KeyboardInterface] Response: b'090400000103000000092110010001222b0007058203400040' [INFO ] [KeyboardDevice] Setting configuration: 0x0 [ERROR ] Got exception while connecting/running device [ERROR ] Traceback (most recent call last): File "./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 164, in run self.scheduler.run() File "/usr/local/lib/python3.6/dist-packages/facedancer-2019.3.2-py3.6.egg/facedancer/core.py", line 495, 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 744, 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 356, 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 391, 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 234, in handle_request handler_entity = recipient.device_class AttributeError: 'USBKeyboardInterface' object has no attribute 'device_class'

BR, Hannes

decidedlygray commented 4 years ago

Did you ever figure out a workaround for this? I believe it has something to do with the differences between nu-map/umap2's USBDevice.py (https://github.com/usb-tools/nu-map/blob/master/numap/core/usb_device.py) and Facedancer's, but I haven't had time to dig into it yet. The fix is probably to replace nu-map's USBDevice with Facedancers?

decidedlygray commented 4 years ago

Hmm nevermind I have no idea why it's not working

hwgross commented 4 years ago

No I did not figure it out, but I am still interested since there are no other open-source USB fuzzers that are maintained

decidedlygray commented 4 years ago

Here was my crap “solution” because I wanted to get up and running quickly: buy a Facedancer21 board from int3.cc and use numap2. Everything still builds for the firmware and fuzzing works for all emulated devices I’ve tried so far

Obviously it’s not a good one because it doesn’t support this project. I’m also setting up a dev environment for this project and will be starting to debug this issue on my own, I’ll see if I can get a PR out :) but it won’t be for a few weeks at least

ktemkin commented 4 years ago

This particular issue should be fixed in upstream FaceDancer (thanks, @Qyriad). We're now working through other issues that block things from running properly.

I think gradually the emulate features will be moved over into facedancer core; as that's the core tool for emulation. I'd like to see these codebases have less divergence / redundancy; but that's a gradual process.