dnsx icon indicating copy to clipboard operation
dnsx copied to clipboard

-wd method not working

Open Phoenix1112 opened this issue 6 months ago • 4 comments

I am using the -wd parameter to clean wildcard subdomains with the latest version, but it does not produce any results.

root@localhost:~/deneme# cat domains
tk.octopus.energy
status.electroverse.octopus.energy
octopus.energy
asasasas.octopus.energy
555asasasas.octopus.energy
root@localhost:~/deneme#
root@localhost:~/deneme#
root@localhost:~/deneme# dnsx -l domains -wd octopus.energy

      _             __  __
   __| | _ __   ___ \ \/ /
  / _' || '_ \ / __| \  /
 | (_| || | | |\__ \ /  \
  \__,_||_| |_||___//_/\_\

                projectdiscovery.io

[INF] Current dnsx version 1.2.2 (latest)
Starting to filter wildcard subdomains
0 wildcard subdomains removed
root@localhost:~/deneme#

The following subdomain addresses have the same IP address, but they still do not respond.

octopus.energy
asasasas.octopus.energy
555asasasas.octopus.energy

Phoenix1112 avatar Jul 14 '25 12:07 Phoenix1112

True, having the same issue

forghani77 avatar Jul 14 '25 21:07 forghani77

İ installed 1.2.1 version again

Phoenix1112 avatar Jul 14 '25 22:07 Phoenix1112

hi team I looked into the issue and found that the problem was caused by the unmarshal below, so I tried to fix it. Can I open a PR for this?

# runner.go
if r.options.WildcardDomain != "" {
    gologger.Print().Msgf("Starting to filter wildcard subdomains\n")
    ipDomain := make(map[string]map[string]struct{})
    listIPs := []string{}
    // prepare in-memory structure similarly to shuffledns
    r.hm.Scan(func(k, v []byte) error {
        var dnsdata retryabledns.DNSData
        if err := json.Unmarshal(v, &dnsdata); err != nil {
            // the item has no record - ignore
            log.Println(err)
            return nil
        }

        for _, a := range dnsdata.A {
            _, ok := ipDomain[a]
            log.Println(a)
            if !ok {
                ipDomain[a] = make(map[string]struct{})
                listIPs = append(listIPs, a)
            }
            ipDomain[a][string(k)] = struct{}{}
        }

        return nil
    })

    gologger.Debug().Msgf("Found %d unique IPs:%s\n", len(listIPs), strings.Join(listIPs, ", "))
    // wildcard workers
    numThreads := r.options.Threads
    if numThreads > len(listIPs) {
        numThreads = len(listIPs)
    }
    for i := 0; i < numThreads; i++ {
        r.wgwildcardworker.Add(1)
        go r.wildcardWorker()
    }
numThreads := r.options.Threads
if numThreads > len(listIPs) {
    numThreads = len(listIPs)
}
  • numThreads is reset from the default 100 to 0 (because it’s set to len(listIPs)).
  • r.hm.Scan is not appending; listIPs is not being populated.
r.hm.Scan(func(k, v []byte) error {
    var dnsdata retryabledns.DNSData
    if err := json.Unmarshal(v, &dnsdata); err != nil {
        // the item has no record - ignore
        log.Println(err)
        return nil
    }
  • When printing err, it shows that unmarshalling fails. 2025/09/12 01:24:20 json: cannot unmarshal object into Go struct field Msg.raw_resp.Answer of type dns.RR
func (r *Runner) storeDNSData(dnsdata *retryabledns.DNSData) error {
	dnsdata.RawResp = nil

	data, err := dnsdata.JSON()
	if err != nil {
		return err
	}
	return r.hm.Set(dnsdata.Host, []byte(data))
}
  • set RawResp to nil before JSON marshal

result

 ./dnsx -l test.txt -wd octopus.energy -wt 1

      _             __  __
   __| | _ __   ___ \ \/ /
  / _' || '_ \ / __| \  / 
 | (_| || | | |\__ \ /  \ 
  \__,_||_| |_||___//_/\_\

                projectdiscovery.io

[INF] Current dnsx version 1.2.2 (latest)
Starting to filter wildcard subdomains
octopus.energy
status.electroverse.octopus.energy
tk.octopus.energy
2 wildcard subdomains removed

jjhwan-h avatar Sep 11 '25 17:09 jjhwan-h

Can I open a PR for this?

Feel free.

dwisiswant0 avatar Sep 11 '25 17:09 dwisiswant0