Beispiel #1
0
def discoverSharedResourcesByWmic(client, hostOsh, oshVector):
    queryBuilder = wmiutils.WmicQueryBuilder('share')
    queryBuilder.addWmiObjectProperties('description', 'name', 'path')
    queryBuilder.addWhereClause("Path <> ''")
    wmicAgent = wmiutils.WmicAgent(client)
    
    shareItems = []
    try:
        shareItems = wmicAgent.getWmiData(queryBuilder)
    except:
        logger.debugException('Failed getting shares information via wmic' )
        return 0

    collection = {}
    for shareItem in shareItems:
        
        shareName = shareItem.name 
        shareDescription = shareItem.description
        sharePath = shareItem.path
        
        instance = SharedResource.Instance(shareName, shareDescription)
        element = collection.get(sharePath)
        if element is None:
            element = SharedResource(sharePath)
        element.addInstance(instance)
        collection[sharePath] = element

    for [path, resource] in collection.items():
        createSharedResourceOsh(resource, hostOsh, oshVector)

    return 1
Beispiel #2
0
def discoverSharedResourcesByWmic(client, hostOsh, oshVector):
    queryBuilder = wmiutils.WmicQueryBuilder('share')
    queryBuilder.addWmiObjectProperties('description', 'name', 'path')
    queryBuilder.addWhereClause("Path <> ''")
    wmicAgent = wmiutils.WmicAgent(client)

    shareItems = []
    try:
        shareItems = wmicAgent.getWmiData(queryBuilder)
    except:
        logger.debugException('Failed getting shares information via wmic')
        return 0

    collection = {}
    for shareItem in shareItems:

        shareName = shareItem.name
        shareDescription = shareItem.description
        sharePath = shareItem.path

        instance = SharedResource.Instance(shareName, shareDescription)
        element = collection.get(sharePath)
        if element is None:
            element = SharedResource(sharePath)
        element.addInstance(instance)
        collection[sharePath] = element

    for [path, resource] in collection.items():
        createSharedResourceOsh(resource, hostOsh, oshVector)

    return 1
def executeWmiQuery(client, OSHVResult, nodeOsh = None):
    containerOsh = nodeOsh or modeling.createHostOSH(client.getIpAddress()) 
    wmiProvider = wmiutils.WmiAgentProvider(client) 
    shareDiscoverer = hostresource_win_wmi.FileSystemResourceDiscoverer(wmiProvider)
    sharedResources = shareDiscoverer.getSharedResources()
    for sharedResource in sharedResources:
        createSharedResourceOsh(sharedResource, containerOsh, OSHVResult)
    logger.debug("Discovered ", len(sharedResources), " shares")
Beispiel #4
0
def executeWmiQuery(client, OSHVResult, nodeOsh=None):
    containerOsh = nodeOsh or modeling.createHostOSH(client.getIpAddress())
    wmiProvider = wmiutils.WmiAgentProvider(client)
    shareDiscoverer = hostresource_win_wmi.FileSystemResourceDiscoverer(
        wmiProvider)
    sharedResources = shareDiscoverer.getSharedResources()
    for sharedResource in sharedResources:
        createSharedResourceOsh(sharedResource, containerOsh, OSHVResult)
    logger.debug("Discovered ", len(sharedResources), " shares")
def _discoverSharedResources(powershell, hostOsh):
    '''PowerShell, osh -> vector
    @raise Exception: failed getting shared resources by WMI
    '''
    wmiProvider = wmiutils.PowerShellWmiProvider(powershell)
    discoverer = hostresource_win_wmi.FileSystemResourceDiscoverer(wmiProvider)
    vector = ObjectStateHolderVector()
    for resource in discoverer.getSharedResources():
        shared_resources_util.createSharedResourceOsh(resource, hostOsh, vector)
    return vector
def _discoverSharedResources(powershell, hostOsh):
    '''PowerShell, osh -> vector
    @raise Exception: failed getting shared resources by WMI
    '''
    wmiProvider = wmiutils.PowerShellWmiProvider(powershell)
    discoverer = hostresource_win_wmi.FileSystemResourceDiscoverer(wmiProvider)
    vector = ObjectStateHolderVector()
    for resource in discoverer.getSharedResources():
        shared_resources_util.createSharedResourceOsh(resource, hostOsh,
                                                      vector)
    return vector