felis / USB_Host_Shield_2.0

Revision 2.0 of USB Host Library for Arduino.
https://chome.nerpa.tech
1.76k stars 781 forks source link

How to send custom non-HID USB using this library? #619

Open bsperryn opened 3 years ago

bsperryn commented 3 years ago

I'm looking at using my Arduino as a proxy between a PS4 and a PS4 controller.

To do this I need to forward the authentication process between the 2 devices as described here: https://forum.gimx.fr/viewtopic.php?t=2384&start=10

Challenge:

struct ps4_challenge {
    unsigned char nonce[0x100];
};

Response:

struct ds4_response {
    unsigned char signature[0x100];
    unsigned char serial_num[0x10];
    unsigned char n[0x100];
    unsigned char e[0x100];
    unsigned char casig[0x100];
};

signature is a PSS signature of the nonce, signed by the private key of DS4 serial_num is the controller/cert serial number. n is the Public Key's prime number e is the Public Key's exponent casig is a PSS signature (signed by Sony's CA private key) of the serial_num, n and e. This is what prevents you from generating your own keys and this is why you need a valid DS4 dump.

I will use another library and USB port to help receive the challenge from the PS4 and forward the responses from the controller back.

I was hoping you could help me with how best to forward this non HID challenge from the PS4 on to the controller and then how to receive the 3 non-HID response's from the controller?

gdsports commented 3 years ago

USB MITM between PS4 and DS4 has been done apparently. I have never tried it.

https://dsremap.readthedocs.io/en/latest/index.html

bsperryn commented 3 years ago

Thank you for this, it looks promising!

bsperryn commented 3 years ago

Do you know if there is something similar for Xbox?

gdsports commented 3 years ago

I do not know of a project similar to dsremap for Xbox.

The GIMX project supports Xbox and PS4 but it runs on a PC or Raspberry Pi. It uses a Pro Micro to talk to the console.

https://gimx.fr/wiki/index.php?title=Main_Page

Ryzee119 commented 3 years ago

https://github.com/Ryzee119/ogx360 I made this a few years ago. For original xbox (not xbox 360) but uses this lib for host control and LUFA for device emulation

bsperryn commented 3 years ago

Hmmm, unfortunately the DSremap library has been made to work with LUFA and LUFA is only for older AVR's...

I'd really like to get this working on a newer chip like the Samd21. (I'm using a IOT Nano at the moment) Any idea on how I might go about that?

I had originally looked at using this library (https://github.com/NicoHood/HID) to handle the built in USB on the board. Not sure if it would be possible to replace LUFA with this in the DSremap library somehow?

Ryzee119 commented 3 years ago

Ive used TinyUSB for xbox controller emulation. It supports samd21.

bsperryn commented 3 years ago

@Ryzee119 Which board did you use TinyUsb on? I'm having a problem getting it working with my nano IOT...

Ryzee119 commented 3 years ago

It happened to be a Teensy4 https://github.com/Ryzee119/ogx360_t4