org.xbill.DNS.CNAMERecord Java Examples

The following examples show how to use org.xbill.DNS.CNAMERecord. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DNSResolver.java    From burp-javascript-security-extension with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Follow the CNAME breadcrumb trail and find any which can't resolve
 * @param hostName a string of the hostname, or fqdn, to lookup 
 * @return a set of strings which list the CNAME entries which could not be resolved
 */
public Set<String> getBadCnames(String hostName){
    Set<String> retval = new TreeSet<String>();
    try {
        Lookup thisLookup = new Lookup(hostName, CNAME);
        thisLookup.setResolver(myResolver);
        Record[] results = thisLookup.run();
        if (results != null){
            List<Record> records = Arrays.asList(results);
            for (Record record : records){
                CNAMERecord thisRecord = (CNAMERecord) record;
                String target = thisRecord.getTarget().toString();
                if (hasRecordsOfType(target, CNAME)){
                    // check for more cnames down the tree
                    retval.addAll(getBadCnames(target));
                } else {
                    if (!(hasRecordsOfType(target, A) || hasRecordsOfType(target, AAAA))){
                        // This one doesn't point to anything
                        retval.add(target);
                    }
                }
            }
        }
    }
    catch (TextParseException e){
        System.err.println("[SRI][-] There was an error parsing the name " + hostName);
    }
    return retval;
}
 
Example #2
Source File: TldController.java    From yeti with MIT License 5 votes vote down vote up
public void expandDomain(String domainToCheck) throws TextParseException {
    String domainName = null;

    // Check for domain name alias - CNAME
    Record[] recs = new Lookup(domainToCheck, Type.CNAME).run();
    if (recs != null && recs.length != 0) {
        domainName = ((CNAMERecord) recs[0]).getName().canonicalize().toString(true);
        Log.debug("Found: " + domainName + "CNAME rec: " + domainName);
    }

    // Now get the SOA record that would signify a domain exists
    recs = new Lookup(domainToCheck, Type.SOA).run();
    for (int idx = 0; idx < retryCount; idx++) {
        if (recs != null) {
            if (domainName == null) {
                domainName = ((SOARecord) recs[0]).getName().canonicalize().toString(true);
                Log.debug("Found: " + domainName + " SOA rec: " + domainName);
            }

            DomainResult newDomain = new DomainResult(domainName);
            newDomain.setNameServer(((SOARecord) recs[0]).getHost().toString(true));
            newDomain.setAdminName(((SOARecord) recs[0]).getAdmin().toString(true));
            String name = domainToCheck.split("\\.", 2)[0];
            String tld = domainToCheck.split("\\.", 2)[1];
            newDomain.setRegistrant(NetworkTools.getHostNameWhoisResult(name, tld, true));
            Map<String, String> attrs = new HashMap<>();
            attrs.put(DataStore.DNS_RECORD, DataStore.SOA);
            newDomain.setAttributes(attrs);
            addResult(newDomain);
            break;
        }
    }
}
 
Example #3
Source File: DNS.java    From yeti with MIT License 4 votes vote down vote up
public static CNAMERecord getCNAMERecord(String hostName) {
    return null;
}
 
Example #4
Source File: DataAPI.java    From yeti with MIT License 4 votes vote down vote up
public CNAMERecord getCNAMERecord(String hostName) {
    return null;
}