Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cname probe not work #239

Closed
iflody opened this issue Apr 17, 2021 · 10 comments · Fixed by #308 or #314
Closed

cname probe not work #239

iflody opened this issue Apr 17, 2021 · 10 comments · Fixed by #308 or #314
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Milestone

Comments

@iflody
Copy link
Contributor

iflody commented Apr 17, 2021

In pr #108 seems that cname probe has been added, but when I try it locally it seems that not work,

Use the test case in the original pr:

https://www.hackerone.com
https://api.hackerone.com
https://mta-sts.hackerone.com
https://mta-sts.managed.hackerone.com
https://support.hackerone.com
https://mta-sts.forwarding.hackerone.com
https://docs.hackerone.com
https://resources.hackerone.com
./httpx -l domains.txt -cname

    __    __  __       _  __
   / /_  / /_/ /_____ | |/ /
  / __ \/ __/ __/ __ \|   /
 / / / / /_/ /_/ /_/ /   |
/_/ /_/\__/\__/ .___/_/|_|
             /_/              v1.0.5

		projectdiscovery.io

Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
https://mta-sts.forwarding.hackerone.com
http://mta-sts.managed.hackerone.com
http://mta-sts.hackerone.com
http://api.hackerone.com
http://docs.hackerone.com
http://www.hackerone.com
http://resources.hackerone.com
http://support.hackerone.com

When I dig into source code I find that in internal/runner/runner.go:

dnsData, err := hp.Dialer.GetDNSData(domain)

and in fast dialer GetDNSData function:

		data, err = d.dnsclient.Resolve(hostname)
		if err != nil && d.options.EnableFallback {
			data, err = d.dnsclient.ResolveWithSyscall(hostname)
		}
		if err != nil {
			return nil, err
		}
		if data == nil {
			return nil, errors.New("could not resolve host")
		}
		b, _ := data.Marshal()
		err = d.hm.Set(hostname, b)
		if err != nil {
			return nil, err
		}
		return data, nil

It call retryabledns's Resolve function which only query for the A record:

func (c *Client) Resolve(host string) (*DNSData, error) {
	return c.Query(host, dns.TypeA)
}

So I think it is the root cause? I think the fastdialer need to add an function for A|CNAME type record.

@iflody iflody changed the title cname probe not worker cname probe not worke Apr 17, 2021
@iflody iflody changed the title cname probe not worke cname probe not work Apr 17, 2021
iflody added a commit to iflody/fastdialer that referenced this issue Apr 17, 2021
projectdiscovery/httpx#239 describes that -cname flag not work because
fastdialer doesn't query for cname, so the result can't be found in
cache.

This commit add function GetDNSDataWithCName to support cname query
which could be called in httpx.

Resolves: projectdiscovery/httpx#239
See also: projectdiscovery/httpx#108
@iflody
Copy link
Contributor Author

iflody commented Apr 17, 2021

I have make a pr projectdiscovery/fastdialer#11 , it is ugly but seems will work

@ehsandeep
Copy link
Member

test $cat h1.txt 

https://www.hackerone.com
https://api.hackerone.com
https://mta-sts.hackerone.com
https://mta-sts.managed.hackerone.com
https://support.hackerone.com
https://mta-sts.forwarding.hackerone.com
https://docs.hackerone.com
https://resources.hackerone.com

test $cat h1.txt | httpx -silent -cname
https://docs.hackerone.com [hacker0x01.github.io]
https://mta-sts.managed.hackerone.com [hacker0x01.github.io]
https://mta-sts.hackerone.com [hacker0x01.github.io]
https://api.hackerone.com
https://support.hackerone.com [hackerone.zendesk.com]
https://resources.hackerone.com [read.uberflip.com]
https://www.hackerone.com
https://mta-sts.forwarding.hackerone.com [hacker0x01.github.io]

@iflody this works for me, I'm unable to reproduce this, on what system you running this, as per banner you are on the latest version of httpx.

@ehsandeep ehsandeep added Status: Review Needed The issue has a PR attached to it which needs to be reviewed Type: Question A query or seeking clarification on parts of the spec. Probably doesn't need the attention of all. labels Apr 17, 2021
@iflody
Copy link
Contributor Author

iflody commented Apr 17, 2021

Thanks for your reply, I try to clear my dns cache locally, and it just works, I can't repeat this bug again, sorry.

My system is MacOS Big Sur

@ehsandeep
Copy link
Member

Np @iflody, thanks for confirming this, can we close this issue now and related PR?

@iflody
Copy link
Contributor Author

iflody commented Apr 17, 2021

Yes, I will do it.

@iflody iflody closed this as completed Apr 17, 2021
@ehsandeep ehsandeep removed Status: Review Needed The issue has a PR attached to it which needs to be reviewed Type: Question A query or seeking clarification on parts of the spec. Probably doesn't need the attention of all. labels Apr 17, 2021
@nvdadt
Copy link

nvdadt commented Jun 15, 2021

-cname - does not work in latest build . Any work around for this ?

@ehsandeep ehsandeep added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Jun 15, 2021
@ehsandeep ehsandeep reopened this Jun 15, 2021
@ehsandeep ehsandeep added this to the v1.1.0 milestone Jun 15, 2021
@Mzack9999 Mzack9999 linked a pull request Jun 16, 2021 that will close this issue
@nvdadt
Copy link

nvdadt commented Jun 17, 2021

Thanks for the quick fix. From where do I get this latest build ?

@ehsandeep ehsandeep added the Status: Completed Nothing further to be done with this issue. Awaiting to be closed. label Jun 17, 2021
@ehsandeep
Copy link
Member

@nvdadt fix is merged into dev branch, you can pull dev branch with GO111MODULE=on go get -v github.com/projectdiscovery/httpx/cmd/httpx@dev before we create a new build.

@nvdadt
Copy link

nvdadt commented Jun 23, 2021

Thanks @ehsandeep this worked. Please let me know when this goes to new build.

@ehsandeep ehsandeep linked a pull request Jun 24, 2021 that will close this issue
@ehsandeep
Copy link
Member

@nvdadt this is now fixed in the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
3 participants