robertdavidgraham / masscan

TCP port scanner, spews SYN packets asynchronously, scanning entire Internet in under 5 minutes.
GNU Affero General Public License v3.0
23.25k stars 3.04k forks source link

stop active host scan on first open port #678

Open asabellico opened 2 years ago

asabellico commented 2 years ago

does it make sense to add a --lazy-scan option to stop scan additional ports when an open port on a host is found?

this could potentially allow to save time and packets when scanning a block and only need to know that an host is up.

mzpqnxow commented 9 months ago

does it make sense to add a --lazy-scan option to stop scan additional ports when an open port on a host is found?

this could potentially allow to save time and packets when scanning a block and only need to know that an host is up.

Could also be called --tcp-ping, but that doesn't capture the short-circuit behavior. Maybe --tcp-up? Meh. Semantics...

The challenge, I think, is how will the transmit_thread() function suppress transmission of packets to an address without needing to have expensive logic in the tight loop, where performance is critical. Especially when there are tens of millions of hosts, thousands of ports, etc.

The receiver thread is not performance critical so it's not a problem using it to mark that an address is no longer "in scope". But I'm still not sure how the transmit thread would check what is "out of scope" without unacceptable overhead

I think it's a potentially useful feature but I don't think it's something I can help with, I'm not prepared to properly regression check changes in the transmit thread and I'm pretty sure there has to he logic added there to support this

Maybe it would be best to implement an alternative transmit_thread() function, used only when this option is specified. That avoids needing to worry about impacting performance in the the existing modes

Basically, I would like to contribute, but will have to defer to @robertdavidgraham