in reply to NMAP Parser very slow

For instance a range of 4 addresses takes up to 20 minutes for the script to complete. That's doable but with a /24, this is simply too long. Now I have read that this kind of nmap port scanning takes a long time but is there something wrong with my code that makes it very slow?

No. Nothing particular.

You are calling ->tcp_ports('open') for each of the hosts you are investigating. In order to be able to tell you which ports are open, NMap will have to scan all of the ports for each host.

You say that it is takig 20 for 4 hosts; so 300 seconds per host. Assuming that NMap is limiting itself to the bottom 1024 privileged ports on each host, that means 300 / 1024 = 0.293 seconds per port. Active ports may well respond more quickly than that, but for inactive ports NMap will have to wait a certain amount of time before it times the port out and concludes it is not active. That calculation assumes that NMap scans the ports serially.

It is also possible that NMap scans the ports in parallel; and that the commonly used default timeout of 300 seconds means that every host will always take a minimum of 5 minutes to scan, unless it all 1024 ports are open.

Does NMAP::Parser, or one of its dependents allow you to configure the timeout?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: NMAP Parser very slow
by Anonymous Monk on Nov 02, 2016 at 18:33 UTC
    Active ports may well respond more quickly than that, but for inactive ports NMap will have to wait a certain amount of time before it times the port out and concludes it is not active.
    Closed ports are also reported immediately, unless they're blocked by a firewall. Stop portscanning people's firewalls! What's wrong with you?
Re^2: NMAP Parser very slow
by Noosrep (Novice) on Nov 02, 2016 at 15:52 UTC
    I was thinking about something in that direction but I haven't found anything yet about the ports. I think that I need to limit the number of ports in my nmap commando but it would be nice to configure a timeout. I'll look further in this, thanks!