def run(self): phy = FacedancerUSBApp() phy.should_stop_phy = self.should_stop_phy self.build_scan_session() self.logger.always( 'Scanning host for supported vendor specific devices') self.prev_index = None while self.scan_session.current < (len(self.scan_session.db)): if self.stop_signal_received: break db_entry = self.scan_session.db[self.scan_session.current] db_entry.os = self.os vid = db_entry.vid pid = db_entry.pid if not self.options['--exhaustive']: driver = db_entry.drivers.get(self.os, None) if driver and driver in self.scan_session.supported_drivers: self.logger.always('skipping entry: %s' % db_entry) self.sync_and_increment_session() continue self.logger.always('Testing support for %s' % db_entry) self.current_usb_function_supported = False self.start_time = time.time() device = USBVendorSpecificDevice(phy, vid, pid) device.phy.should_stop_phy = self.should_stop_phy try: device.connect() device.run() except: self.logger.error(traceback.format_exc()) device.disconnect() if not self.is_host_alive(device.phy): break if device.phy.current_usb_function_supported: db_entry.info = self.get_device_info(device) self.scan_session.supported.append(db_entry) driver = db_entry.drivers.get(self.os, None) if driver: self.scan_session.supported_drivers.append( db_entry.drivers[self.os]) # else: # db_entry.info = self.get_device_info(device) # self.scan_session.unsupported.append(db_entry) self.prev_index = self.scan_session.current self.sync_and_increment_session() if self.single_step: input('press any key to continue') else: time.sleep(self.between_delay) self.print_results()
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 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()
def main(): 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() u = FacedancerUSBApp(verbose=4) d = USBProxyDevice(u, idVendor=args.vendorid, idProduct=args.productid, verbose=4) filters = USBProxySetupFilters(d) d.add_filter(filters) d.connect() try: d.run() # SIGINT raises KeyboardInterrupt except KeyboardInterrupt: d.disconnect()
def __init__(self, arguments): """ Initializes a new FaceDancerPhy. Parameters: arguments -- The argument string passed in from the command line. """ # Generate our logging backend. self.logger = logging.getLogger('numap') # And create our FD2 connection. # TODO: support specifying exact types / parameters? self.backend = FacedancerUSBApp()
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()
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()
#!/usr/bin/env python3 # # facedancer-procontroller.py # # Custom SPI flash can be provided as a parameter to SPIFlash() - should be # 512kb in size. Otherwise by default all reads will be 0xff from facedancer import FacedancerUSBApp from USBProController import * from SPIFlash import SPIFlash u = FacedancerUSBApp(verbose=3) d = USBProControllerDevice(u, spi_flash=SPIFlash(), verbose=3) d.connect() try: d.run() # SIGINT raises KeyboardInterrupt except KeyboardInterrupt: d.disconnect()
def load_phy(self, phy_string): # TODO: support options; bring GadgetFS into FaceDancer2? return FacedancerUSBApp()