Ejemplo n.º 1
0
  def _GetDisk(self, label: str) -> str:
    """Leverages the drive label to define the drive letter.

    The BeyondCorp USB device is not gaurenteed to be on a certain drive letter.

    Args:
      label: Drive label to use when querying for drive letter.

    Raises:
      BCError: Error executing WMI query.
      BCError: BeyondCorp drive letter was empty.

    Returns:
      Drive letter for the drive that contains the seed.
    """
    query = f'SELECT Name FROM win32_logicaldisk WHERE volumename="{label}"'
    try:
      drive_letter = wmi_query.WMIQuery().Query(query)[0].Name
    except wmi_query.WmiError as e:
      raise BCError(f'Failed to query WMI for BeyondCorp drive letter: {e}')

    if not drive_letter:
      raise BCError('BeyondCorp drive letter was empty.')

    logging.debug('BeyondCorp Drive letter = %s', drive_letter)

    return drive_letter
Ejemplo n.º 2
0
 def setUp(self):
   # modules
   ## pythoncom
   self.pythoncom = mock.Mock()
   sys.modules['pythoncom'] = self.pythoncom
   ## pywintypes
   self.pywintypes = mock.Mock()
   self.pywintypes.com_error = Exception
   self.pywintypes.error = Exception
   sys.modules['pywintypes'] = self.pywintypes
   ## win32com
   self.win32com = mock.Mock()
   sys.modules['win32com'] = self.win32com
   server = self.win32com.client.Dispatch.return_value
   self.handler = server.ConnectServer.return_value
   # init
   self.wmi = wmi_query.WMIQuery()
Ejemplo n.º 3
0
 def __init__(self):
     self.wmi = wmi_query.WMIQuery()
Ejemplo n.º 4
0
 def __init__(self, active_only=True, poll=True):
     self._wmi = wmi_query.WMIQuery()
     self._interfaces = []
     if poll:
         self.Poll(active_only)
Ejemplo n.º 5
0
 def __init__(self):
     self.wmi = wmi_query.WMIQuery(
         namespace=r'root\cimv2\security\microsofttpm')