forked from greatscottgadgets/facedancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusbproxy-switch-invertx.py
executable file
·55 lines (40 loc) · 1.47 KB
/
usbproxy-switch-invertx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
#
# facedancer-usbproxy.py
from facedancer import FacedancerUSBApp
from facedancer.USBConfiguration import USBConfiguration
from facedancer.USBInterface import USBInterface
from facedancer.USBEndpoint import USBEndpoint
from facedancer.USBProxy import USBProxyDevice, USBProxyFilter
from facedancer.filters.standard import USBProxySetupFilters
from facedancer.filters.logging import USBProxyPrettyPrintFilter
class SwitchControllerInvertXFilter(USBProxyFilter):
"""
Sample filter that inverts the X axis on a switch controller.
Demonstrates how dead simple this is. :)
"""
# Joystick up: b'\x00\x00\x0f\x80\xff\x80\x80\x00'
# Joystick down: b'\x00\x00\x0f\x80\x00\x80\x80\x00'
def filter_in(self, ep_num, data):
# Invert the X axis...
try:
data[3] = 0xff - data[3]
except:
pass
return ep_num, data
def main():
# Create a new proxy/MITM connection for the Switch Wired Pro Controller.
u = FacedancerUSBApp(verbose=1)
d = USBProxyDevice(u, idVendor=0x0f0d, idProduct=0x00c1, verbose=2)
# Apply the standard filters that make USBProork.
d.add_filter(USBProxySetupFilters(d, verbose=2))
d.add_filter(SwitchControllerInvertXFilter())
d.add_filter(USBProxyPrettyPrintFilter(verbose=5))
d.connect()
try:
d.run()
# SIGINT raises KeyboardInterrupt
except KeyboardInterrupt:
d.disconnect()
if __name__ == "__main__":
main()