2016年8月5日金曜日

Emulating USB Devices In Python With No Additional Hardware!

In 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!

0 件のコメント:

コメントを投稿