Saturday 30 August 2014

Emulating USB Devices In Python With No Additional Hardware!

In my previous post I showed how I can emulate USB devices in python:
http://breaking-the-system.blogspot.co.il/2014/08/no-need-for-ccdebugger-you-got.html

This method wasn't generic and was written specifically to the CC Debugger usb device.
I wanted to write something that can easily emulate any usb devices in python.


In the CC Debugger project I used the USB/IP project, and I decided to use it again. I started by understanding the USB/IP protocol. After that, converting the protocol into python data structures. At this point I can handle USB/IP requests. I implemented function to handle usb protocol requests like GET_DESCRIPTOR, you can read more about it here.

The final result is in GitHub:
https://github.com/smulikHakipod/USB-Emulation

**THIS CODE IS VERY EXPERMINTAL AND WILL PROBABLY CRASH THE MACHINE
 YOU ARE RUNNING ON"

Its very recommended to install the USB/IP driver on a VM at first for testing purposes. As I said in GitHub, HID devices doesn't work that well with USB/IP driver and on de-attach the driver crashes the computer with blue screen.

Steps:
1) Download and install the USB/IP driver version 0.2 from http://sourceforge.net/projects/usbip/files/usbip_windows/
2) Download project files: https://github.com/smulikHakipod/USB-Emulation
3) Run hid.py
4) Attach USB/IP to the python script: usbip.exe -a 10.0.0.1 "1-1"

I didn't find any other way to emulate usb devices in python with no additional hardware, so I hope any of you readers will find it usefull. If you have any questions you can ask in the comments. Thanks for reading!

6 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. *Spot on with this write-up, I truly think this website needs much more consideration. I’ll probably be again to read much more, thanks for that info. best instagram followers at famoid

    ReplyDelete
  4. It should be noted that whilst ordering papers for sale at paper writing service, you can get unkind attitude. In case you feel that the bureau is trying to cheat you, don't buy term paper from it. geek squad

    ReplyDelete
  5. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. geek squad

    ReplyDelete
  6. Great post however , I was wanting to know if you could write a litte more on this subject? I’d be very thankful if you could elaborate a little bit further. Bless you! https://python.engineering/python-os-path-isdir-method/

    ReplyDelete