d3mondev / puredns

Puredns is a fast domain resolver and subdomain bruteforcing tool that can accurately filter out wildcard subdomains and DNS poisoned entries.
GNU General Public License v3.0
1.61k stars 151 forks source link

puredns error: error resolving domains: bufio.Scanner: token too long #55

Closed brutexploiter closed 7 months ago

brutexploiter commented 7 months ago

puredns error: error resolving domains: bufio.Scanner: token too long

Screenshot 2023-11-20 221828

d3mondev commented 7 months ago

Hi, does your wordlist contains lines that are longer than 65536 characters?

If not, is there a test case I can use to reproduce this?

Thanks

brutexploiter commented 7 months ago

Hey,

I'm using best-dns-wordlist.txt in my 2 GB VPS I've started facing problem only in my VPS recently

Thanks

edit: Can you confirm that this issue is only from my end and due to memory?

image

d3mondev commented 7 months ago

The issue is not due to memory and might not only be on your end. But I've never seen it before.

It's likely happening because puredns is trying to parse a line of text that is longer than 65536 characters. Given that DNS records can't really exceed 255 characters, this is not a case that is handled in puredns. However it's possible that massdns produces a longer line than expected and that would probably cause this issue.

To investigate it further I would need to know the domain you are trying to resolve and I could run a few tests on my end. Feel free to DM me the domain on Twitter if you don't want to share it publicly.

Thanks

d3mondev commented 7 months ago

We iterated over this issue via DM and we figured out that a corrupted wordlist was causing the issue. The corruption caused the file to have lines longer than 65536 characters, going over the default size of the bufio.Scanner buffer that's reading from the file.

To fix this, we would need to change domainreader.go to use something other than a bufio.Scanner, as simply increasing the buffer size isn't an option given that a corruption can cause a line to have excessively long length.

I'm closing it for now as I don't think it's worth fixing it at the moment but we should definitely consider it if this code is refactored.