1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

o.ping_group_sz can be increased above 4096 with a higher --min-hostgroup value, calls to target_needs_new_hostgroup limited as much as possible

This commit is contained in:
tudor
2016-08-09 06:12:17 +00:00
parent 7c0280382e
commit 3ba4a87c75
3 changed files with 31 additions and 65 deletions

View File

@@ -302,11 +302,11 @@ static void massping(Target *hostbatch[], int num_hosts, struct scan_lists *port
These restrictions only apply for raw scans. This function is similar to one
of the same name in nmap.cc. That one is for port scanning, this one is for
ping scanning. */
static bool target_needs_new_hostgroup(const HostGroupState *hs, const Target *target) {
int i;
bool target_needs_new_hostgroup(Target **targets, int targets_sz, const Target *target) {
int i = 0;
/* We've just started a new hostgroup, so any target is acceptable. */
if (hs->current_batch_sz == 0)
if (targets_sz == 0)
return false;
/* There are no restrictions on non-root scans. */
@@ -314,30 +314,30 @@ static bool target_needs_new_hostgroup(const HostGroupState *hs, const Target *t
return false;
/* Different address family? */
if (hs->hostbatch[0]->af() != target->af())
if (targets[0]->af() != target->af())
return true;
/* Different interface name? */
if (hs->hostbatch[0]->deviceName() != NULL &&
if (targets[0]->deviceName() != NULL &&
target->deviceName() != NULL &&
strcmp(hs->hostbatch[0]->deviceName(), target->deviceName()) != 0) {
strcmp(targets[0]->deviceName(), target->deviceName()) != 0) {
return true;
}
/* Different source address? */
if (sockaddr_storage_cmp(hs->hostbatch[0]->SourceSockAddr(), target->SourceSockAddr()) != 0)
if (sockaddr_storage_cmp(targets[0]->SourceSockAddr(), target->SourceSockAddr()) != 0)
return true;
/* Different direct connectedness? */
if (hs->hostbatch[0]->directlyConnected() != target->directlyConnected())
if (targets[0]->directlyConnected() != target->directlyConnected())
return true;
/* Is there already a target with this same IP address? ultra_scan doesn't
cope with that, because it uses IP addresses to look up targets from
replies. What happens is one target gets the replies for all probes
referring to the same IP address. */
for (i = 0; i < hs->current_batch_sz; i++) {
if (sockaddr_storage_cmp(hs->hostbatch[i]->TargetSockAddr(), target->TargetSockAddr()) == 0)
for (i = 0; i < targets_sz; i++) {
if (sockaddr_storage_cmp(targets[i]->TargetSockAddr(), target->TargetSockAddr()) == 0)
return true;
}
@@ -653,7 +653,7 @@ static void refresh_hostbatch(HostGroupState *hs, const addrset *exclude_group,
break;
/* Does this target need to go in a separate host group? */
if (target_needs_new_hostgroup(hs, t)) {
if (target_needs_new_hostgroup(hs->hostbatch, hs->current_batch_sz, t)) {
if (hs->defer(t))
continue;
else