Exemplo n.º 1
0
    def __init__(self, vendor_id, product_id, additional_filters=None):
        """
        Creates a new USBProxy instance that captures all passed packets to ViewSB.

        Args:
            vendor_id -- The vendor ID of the device to be proxied.
            product_id -- The product ID of the device to be proxied.
            additional_filters -- A list of any additional filters to be installed in the proxy stack.
        """

        # Create the backend USBProxy instance that will perform our captures...
        facedancer_app = FacedancerUSBApp()
        self.proxy = USBProxyDevice(facedancer_app, idVendor=vendor_id, idProduct=product_id)

        # ... add the necessary filters to perform our magic...
        self.proxy.add_filter(ViewSBProxyObserver(self))
        self.proxy.add_filter(USBProxySetupFilters(self.proxy))

        # ... and add any other filters passed in.
        if additional_filters:
            for additional_filter in additional_filters:
                self.proxy.add_filter(additional_filter)

        # Set up our connection to the device-to-be-proxied.
        self.proxy.connect()
Exemplo n.º 2
0
class USBProxyBackend(ViewSBBackend):
    """ Capture backend that captures packets as they're proxied from device to device. """


    def __init__(self, vendor_id, product_id, additional_filters=None):
        """
        Creates a new USBProxy instance that captures all passed packets to ViewSB.

        Args:
            vendor_id -- The vendor ID of the device to be proxied.
            product_id -- The product ID of the device to be proxied.
            additional_filters -- A list of any additional filters to be installed in the proxy stack.
        """

        # Create the backend USBProxy instance that will perform our captures...
        facedancer_app = FacedancerUSBApp()
        self.proxy = USBProxyDevice(facedancer_app, idVendor=vendor_id, idProduct=product_id)

        # ... add the necessary filters to perform our magic...
        self.proxy.add_filter(ViewSBProxyObserver(self))
        self.proxy.add_filter(USBProxySetupFilters(self.proxy))

        # ... and add any other filters passed in.
        if additional_filters:
            for additional_filter in additional_filters:
                self.proxy.add_filter(additional_filter)

        # Set up our connection to the device-to-be-proxied.
        self.proxy.connect()


    def get_microseconds(self):

        # Get the current time...
        current_time = datetime.now()

        # ... and figure out the microseconds since the start.
        return (current_time - self.start_time).microseconds


    def run(self):

        # Record the time at which the capture is starting.
        self.start_time = datetime.now()

        # And call the base run, function.
        super().run()


    def run_capture(self):
        """ Perform a single iteration of our capture -- essentially services the FaceDancer IRQs. """

        # If the start time wasn't set (e.g. the user is strumming our strings manually), set it.
        if self.start_time is None:
            self.start_time = datetime.now()

        # FIXME: call a run_once on the FaceDancer scheduler; don't touch its internals
        for task in self.proxy.scheduler.tasks:
            task()


    def handle_termination(self):
        """ Handles termination of the capture. """

        # Pass the termination on to our backend.
        self.backend.handle_termination()
Exemplo n.º 3
0
def main():
    """
    Core code for this script. This creates our USBProxy instance and
    runs it, proxying data back and forth.
    """

    # Create a new USBProxy object, proying the device with our target VID/PID.
    u = FacedancerUSBApp(verbose=1)
    d = USBProxyDevice(u,
                       idVendor=TARGET_DEVICE_VID,
                       idProduct=TARGET_DEVICE_PID,
                       verbose=2)

    # Apply the standard filters that make USBProork.
    d.add_filter(USBProxySetupFilters(d, verbose=2))

    # Add in the MITM filter we defined above -- this gives us control
    # over all USB packets.
    d.add_filter(TrainingExampleFilter())

    # Add in a filter that prints all packets as they fly by.
    # This is nice to see what's happening.
    d.add_filter(USBProxyPrettyPrintFilter(verbose=5))

    # Connect to the target device...
    d.connect()

    # And proxy until the user presses CTRL+c.
    try:
        d.run()
    except KeyboardInterrupt:
        d.disconnect()
Exemplo n.º 4
0
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()
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 our filter before the standard filters so we impact configuration
    # of the target device.
    d.add_filter(SwitchControllerWorkWithFacedancer21Filter())

    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()
Exemplo n.º 6
0
class USBProxyBackend(ViewSBBackend):
    """ Capture backend that captures packets as they're proxied from device to device. """

    UI_NAME = "usbproxy"
    UI_DESCRIPTION = "display packets proxied by FaceDancer's usbproxy"

    @staticmethod
    def reason_to_be_disabled():

        # The main reason we'd not be available would be that pyopenvizsla
        # isn't importable (and thus likely not installed).
        if not 'ViewSBProxyObserver' in globals():
            return "facedancer module not available"

        return None

    def __init__(self, vendor_id, product_id, additional_filters=None):
        """
        Creates a new USBProxy instance that captures all passed packets to ViewSB.

        Args:
            vendor_id -- The vendor ID of the device to be proxied.
            product_id -- The product ID of the device to be proxied.
            additional_filters -- A list of any additional filters to be installed in the proxy stack.
        """

        super().__init__()
        # Create the backend USBProxy instance that will perform our captures...
        facedancer_app = FacedancerUSBApp()
        self.proxy = USBProxyDevice(facedancer_app,
                                    idVendor=vendor_id,
                                    idProduct=product_id)

        # ... add the necessary filters to perform our magic...
        self.proxy.add_filter(ViewSBProxyObserver(self))
        self.proxy.add_filter(USBProxySetupFilters(self.proxy))

        # ... and add any other filters passed in.
        if additional_filters:
            for additional_filter in additional_filters:
                self.proxy.add_filter(additional_filter)

        # Set up our connection to the device-to-be-proxied.
        self.proxy.connect()

    @classmethod
    def add_options(cls, parser):
        def hex_int(i):
            return int(i, 16)

        parser.add_argument('-v',
                            '--vid',
                            type=hex_int,
                            required=True,
                            dest='vendor_id',
                            help="USB Vendor ID in hex")
        parser.add_argument('-p',
                            '--pid',
                            type=hex_int,
                            required=True,
                            dest='product_id',
                            help="USB Product ID in hex")

    def get_microseconds(self):

        # Get the current time...
        current_time = datetime.now()

        # ... and figure out the microseconds since the start.
        return (current_time - self.start_time).microseconds

    def run(self):

        # Record the time at which the capture is starting.
        self.start_time = datetime.now()

        # And call the base run, function.
        super().run()

    def run_capture(self):
        """ Perform a single iteration of our capture -- essentially services the FaceDancer IRQs. """

        # If the start time wasn't set (e.g. the user is strumming our strings manually), set it.
        if self.start_time is None:
            self.start_time = datetime.now()

        # FIXME: call a run_once on the FaceDancer scheduler; don't touch its internals
        for task in self.proxy.scheduler.tasks:
            task()

    def handle_termination(self):
        """ Handles termination of the capture. """

        # Pass the termination on to our backend.
        self.backend.handle_termination()
Exemplo n.º 7
0
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()