Beispiel #1
0
    def __init__(self):
        '''
        Constructor
        Initializes the bus and sets device, OUI variables
        '''
        self._bus = Bus()
        try:
            self._bus.enable_sbp2()
        except IOError:
            poll('FireWire modules do not seem to be loaded. Load them? ' +
                 '[Y/n]: ')
            answer = input().lower()
            if answer in ['y', '']:
                status = call('modprobe firewire-ohci', shell=True)
                if status == 0:
                    try:
                        self._bus.enable_sbp2()
                    except IOError:
                        time.sleep(2)  # Give some more time
                        self._bus.enable_sbp2()  # If this fails, fail hard
                    info('FireWire modules loaded successfully')
                else:
                    fail('Could not load FireWire modules')
            else:
                fail('FireWire modules not loaded')

        # Enable SBP-2 support to ensure we get DMA
        self._devices = self._bus.devices()
        self._oui = self.init_OUI()
        self._vendors = []
        self._max_request_size = cfg.PAGESIZE
Beispiel #2
0
 def __init__(self):
     '''
     Constructor
     Initializes the bus and sets device, OUI variables
     '''
     self._bus = Bus()
     try:
         self._bus.enable_sbp2()
     except IOError:
         poll('FireWire modules do not seem to be loaded. Load them? ' +
              '[Y/n]: ')
         answer = input().lower()
         if answer in ['y', '']:
             status = call('modprobe firewire-ohci', shell=True)
             if status == 0:
                 try:
                     self._bus.enable_sbp2()
                 except IOError:
                     time.sleep(2) # Give some more time
                     self._bus.enable_sbp2() # If this fails, fail hard
                 info('FireWire modules loaded successfully')
             else:
                 fail('Could not load FireWire modules')
         else:
             fail('FireWire modules not loaded')
             
     # Enable SBP-2 support to ensure we get DMA
     self._devices = self._bus.devices()
     self._oui = self.init_OUI()
     self._vendors = []
     self._max_request_size = cfg.PAGESIZE
Beispiel #3
0
 def select_device(self):
     '''
     Present the user of the option to select what device (connected to the
     bus) to attack
     '''
     if not self._vendors:
         self.businfo()
     nof_devices = len(self._vendors)
     if nof_devices == 1:
         info('Only one device present, device auto-selected as target')
         return 0
     else:
         poll('Please select a device to attack (or type \'q\' to quit): ')
         selected = input()
         try:
             selected = int(selected)
         except:
             if selected == 'q': sys.exit()
             else:
                 warn('Invalid selection, please try again. Type \'q\' ' +
                      'to quit')
                 return self.select_device()
     if 0 < selected <= nof_devices:
         i = selected - 1
         vendor = self._vendors[i]
         # If the target is a Mac, and we are in memdump mode with the
         # --override switch set, make sure we don't touch OS X's g-spot
         if 'apple' in vendor.lower() and cfg.memdump and cfg.override:
             cfg.apple_target = True
             info('The target seems to be a Mac, forcing avoidance ' +
                  '(not dumping {0:#x}-{1:#x})'.format(
                      cfg.apple_avoid[0], cfg.apple_avoid[1]))
         return i
     else:
         warn('Please enter a selection between 1 and ' + str(nof_devices) +
              '. Type \'q\' to quit')
         return self.select_device()
Beispiel #4
0
 def select_device(self):
     '''
     Present the user of the option to select what device (connected to the
     bus) to attack
     '''
     if not self._vendors:
         self.businfo()
     nof_devices = len(self._vendors)
     if nof_devices == 1:
         info('Only one device present, device auto-selected as target')
         return 0
     else:
         poll('Please select a device to attack (or type \'q\' to quit): ')
         selected = input()
         try:
             selected = int(selected)
         except:
             if selected == 'q': sys.exit()
             else:
                 warn('Invalid selection, please try again. Type \'q\' ' +
                      'to quit')
                 return self.select_device()
     if 0 < selected <= nof_devices:
         i = selected - 1 
         vendor = self._vendors[i]
         # If the target is a Mac, and we are in memdump mode with the
         # --override switch set, make sure we don't touch OS X's g-spot
         if 'apple' in vendor.lower() and cfg.memdump and cfg.override:
             cfg.apple_target = True
             info('The target seems to be a Mac, forcing avoidance ' +
                  '(not dumping {0:#x}-{1:#x})'
                  .format(cfg.apple_avoid[0], cfg.apple_avoid[1]))
         return i
     else:
         warn('Please enter a selection between 1 and ' + str(nof_devices) + 
              '. Type \'q\' to quit')
         return self.select_device()
Beispiel #5
0
def select_target(targets, selected=False):
    '''
    Provides easy selection of targets. Input is a list of targets (dicts)
    '''
    if len(targets) == 1:
        info('Only one target present, auto-selected')
        return targets[0]
    if not selected:
        poll('Please select target (or enter \'q\' to quit):')
        selected = input()
    nof_targets = len(targets)
    try:
        selected = int(selected)
    except:
        if selected == 'q': sys.exit()
        else:
            warn('Invalid selection, please try again. Type \'q\' to quit')
            return select_target(targets)
    if 0 < selected <= nof_targets:
        return targets[selected - 1]
    else:
        warn('Please enter a selection between 1 and ' + str(nof_targets) + 
             '. Type \'q\' to quit')
        return select_target(targets)