Search in sources :

Example 1 with StateDetails

use of com.xebia.vulnmanager.models.nmap.objects.StateDetails in project vulnmanager by xebia-research.

the class HostsParserHelper method parseHostDataFromNodeList.

private Host parseHostDataFromNodeList(NodeList hostDataList) {
    StateDetails stateDetails = null;
    AddressDetails addressDetails = null;
    HostNamesDetails hostNamesDetails = null;
    HostPorts hostPorts = null;
    TimingData timingData = null;
    for (int x = 0; x < hostDataList.getLength(); x++) {
        Node currentHostDetail = hostDataList.item(x);
        NamedNodeMap currentChildAttributes = currentHostDetail.getAttributes();
        String currentNodeName = currentHostDetail.getNodeName();
        switch(currentNodeName) {
            case NMapConstants.PARSER_LITERAL_STATUS:
                stateDetails = getStatusDetails(currentChildAttributes);
                break;
            case NMapConstants.PARSER_LITERAL_ADDRESS:
                addressDetails = getAddressDetails(currentChildAttributes);
                break;
            case NMapConstants.PARSER_LITERAL_HOST_NAMES:
                hostNamesDetails = getHostNamesDetails(currentHostDetail.getChildNodes());
                break;
            case NMapConstants.PARSER_LITERAL_PORTS:
                hostPorts = getPortDetails(currentHostDetail.getChildNodes());
                break;
            case NMapConstants.PARSER_LITERAL_TIMES:
                timingData = getTimingData(currentChildAttributes);
                break;
            default:
                break;
        }
    }
    return new Host(stateDetails, addressDetails, hostNamesDetails, hostPorts, timingData);
}
Also used : HostPorts(com.xebia.vulnmanager.models.nmap.objects.HostPorts) NamedNodeMap(org.w3c.dom.NamedNodeMap) AddressDetails(com.xebia.vulnmanager.models.nmap.objects.AddressDetails) Node(org.w3c.dom.Node) StateDetails(com.xebia.vulnmanager.models.nmap.objects.StateDetails) Host(com.xebia.vulnmanager.models.nmap.objects.Host) HostNamesDetails(com.xebia.vulnmanager.models.nmap.objects.HostNamesDetails) TimingData(com.xebia.vulnmanager.models.nmap.objects.TimingData)

Example 2 with StateDetails

use of com.xebia.vulnmanager.models.nmap.objects.StateDetails in project vulnmanager by xebia-research.

the class HostsParserHelper method getPort.

private HostPorts.Port getPort(Node currentNode) {
    NamedNodeMap portAttributesNode = currentNode.getAttributes();
    String protocol = portAttributesNode.getNamedItem(NMapConstants.PARSER_LITERAL_PROTOCOL).getNodeValue();
    String portId = portAttributesNode.getNamedItem(NMapConstants.PARSER_LITERAL_PORTID).getNodeValue();
    StateDetails stateDetails = null;
    ServiceDetails serviceDetails = null;
    NodeList portChildNodes = currentNode.getChildNodes();
    for (int i = 0; i < portChildNodes.getLength(); i++) {
        Node currentChildNode = portChildNodes.item(i);
        NamedNodeMap portAttributes = currentChildNode.getAttributes();
        if (currentChildNode.getNodeName().equals(NMapConstants.PARSER_LITERAL_STATE)) {
            stateDetails = getStateDetails(portAttributes);
        } else if (currentChildNode.getNodeName().equals(NMapConstants.PARSER_LITERAL_SERVICE)) {
            serviceDetails = getServiceDetails(portAttributes);
        }
    }
    return new HostPorts.Port(protocol, portId, stateDetails, serviceDetails);
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) ServiceDetails(com.xebia.vulnmanager.models.nmap.objects.ServiceDetails) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) StateDetails(com.xebia.vulnmanager.models.nmap.objects.StateDetails)

Aggregations

StateDetails (com.xebia.vulnmanager.models.nmap.objects.StateDetails)2 NamedNodeMap (org.w3c.dom.NamedNodeMap)2 Node (org.w3c.dom.Node)2 AddressDetails (com.xebia.vulnmanager.models.nmap.objects.AddressDetails)1 Host (com.xebia.vulnmanager.models.nmap.objects.Host)1 HostNamesDetails (com.xebia.vulnmanager.models.nmap.objects.HostNamesDetails)1 HostPorts (com.xebia.vulnmanager.models.nmap.objects.HostPorts)1 ServiceDetails (com.xebia.vulnmanager.models.nmap.objects.ServiceDetails)1 TimingData (com.xebia.vulnmanager.models.nmap.objects.TimingData)1 NodeList (org.w3c.dom.NodeList)1