Beispiel #1
0
    def getProtocols(self, j2eePorts=None):
        ''' Get protocols with port matching one among passed "j2eePorts"
        of if ports are not specified get all protocols by ip and protocol
        @types: list(str) or None -> list(ProtocolObject)
        '''
        suitableProtocols = []
        protocols = ProtocolManager.getProtocolParameters(
            self.getProtocolName() + ProtocolManager.PROTOCOL, self.ip_address,
            self.ip_domain)
        if (j2eePorts == None) or (len(j2eePorts) == 0) or (j2eePorts[0]
                                                            == 'NA'):
            # if this is no ports in connection, when destination was entered manually and we should try all credentials for this type
            for protocol in protocols:
                suitableProtocols.append([protocol, None])
        else:
            #in case we have multiple IPs on same host we get here same port several times - we want to filter this
            seenPorts = []
            for j2eePort in j2eePorts:
                if (j2eePort in seenPorts):
                    continue
                seenPorts.append(j2eePort)
                for protocol in protocols:
                    port = self.getProtocolProperty(
                        protocol, CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT,
                        None)
                    if (port == None) or (port == j2eePort):
                        suitableProtocols.append([protocol, j2eePort])

        return suitableProtocols
Beispiel #2
0
    def getProtocols(self, j2eePorts = None):
        ''' Get protocols with port matching one among passed "j2eePorts"
        of if ports are not specified get all protocols by ip and protocol
        @types: list(str) or None -> list(ProtocolObject)
        '''
        suitableProtocols = []
        protocols = ProtocolManager.getProtocolParameters(self.getProtocolName() + ProtocolManager.PROTOCOL, self.ip_address, self.ip_domain)
        if (j2eePorts == None) or (len(j2eePorts) == 0) or (j2eePorts[0] == 'NA'):
            # if this is no ports in connection, when destination was entered manually and we should try all credentials for this type
            for protocol in protocols:
                suitableProtocols.append([protocol, None])
        else:
            #in case we have multiple IPs on same host we get here same port several times - we want to filter this
            seenPorts = []
            for j2eePort in j2eePorts:
                if (j2eePort in seenPorts):
                    continue
                seenPorts.append(j2eePort)
                for protocol in protocols:
                    port = self.getProtocolProperty(protocol, CollectorsConstants.PROTOCOL_ATTRIBUTE_PORT, None)
                    if (port == None) or (port == j2eePort):
                        suitableProtocols.append([protocol, j2eePort])

        return suitableProtocols