forked from greatscottgadgets/facedancer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
facedancer-usbproxy.py
executable file
·50 lines (41 loc) · 1.65 KB
/
facedancer-usbproxy.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
#!/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
import argparse
def vid_pid(x):
return int(x, 16)
def main():
# TODO: Accept arguments that specify a list of filters to apply,
# from the local directory or the filters directory.
parser = argparse.ArgumentParser(description="FaceDancer USB Proxy")
parser.add_argument('-v', dest='vendorid', metavar='<VendorID>',
type=vid_pid, help="Vendor ID of device",
required=True)
parser.add_argument('-p', dest='productid', metavar='<ProductID>',
type=vid_pid, help="Product ID of device",
required=True)
args = parser.parse_args()
quirks = []
# Create a new USBProxy device.
u = FacedancerUSBApp(verbose=1)
d = USBProxyDevice(u, idVendor=args.vendorid, idProduct=args.productid, verbose=2, quirks=quirks)
# Add our standard filters.
# TODO: Make the PrettyPrintFilter switchable?
d.add_filter(USBProxyPrettyPrintFilter(verbose=5))
d.add_filter(USBProxySetupFilters(d, verbose=2))
# TODO: Figure these out from the command line!
d.connect()
try:
d.run()
# SIGINT raises KeyboardInterrupt
except KeyboardInterrupt:
d.disconnect()
if __name__ == "__main__":
main()