mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Make the two versions of target_needs_new_hostgroup the same.
Up to data structure differences. I'm not sure why they differed to begin with, though I remember writing the comment that explains that they differed. This is related to a problem reported by Daniel Miller: http://seclists.org/nmap-dev/2012/q1/675.
This commit is contained in:
parent
89987139db
commit
f511045723
2 changed files with 16 additions and 3 deletions
18
nmap.cc
18
nmap.cc
|
|
@ -2070,18 +2070,26 @@ int nmap_main(int argc, char *argv[]) {
|
|||
group. This happens when:
|
||||
1. it uses a different interface, or
|
||||
2. it uses a different source address, or
|
||||
3. it has the same IP address as another target already in the group.
|
||||
3. it is directly connected when the other hosts are not, or vice versa, or
|
||||
4. it has the same IP address as another target already in the group.
|
||||
These restrictions only apply for raw scans. This function is similar to one
|
||||
of the same name in targets.cc. That one is for ping scanning, this one is
|
||||
for port scanning. */
|
||||
static bool target_needs_new_hostgroup(std::vector<Target *> &targets,
|
||||
const Target *target) {
|
||||
static bool target_needs_new_hostgroup(std::vector<Target *> &targets, const Target *target) {
|
||||
std::vector<Target *>::iterator it;
|
||||
|
||||
/* We've just started a new hostgroup, so any target is acceptable. */
|
||||
if (targets.empty())
|
||||
return false;
|
||||
|
||||
/* There are no restrictions on non-root scans. */
|
||||
if (!(o.isr00t && target->deviceName() != NULL))
|
||||
return false;
|
||||
|
||||
/* Different address family? */
|
||||
if (targets[0]->af() != target->af())
|
||||
return true;
|
||||
|
||||
/* Different interface name? */
|
||||
if (targets[0]->deviceName() != NULL &&
|
||||
target->deviceName() != NULL &&
|
||||
|
|
@ -2093,6 +2101,10 @@ static bool target_needs_new_hostgroup(std::vector<Target *> &targets,
|
|||
if (sockaddr_storage_cmp(targets[0]->SourceSockAddr(), target->SourceSockAddr()) != 0)
|
||||
return true;
|
||||
|
||||
/* Different direct connectedness? */
|
||||
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
|
||||
|
|
|
|||
|
|
@ -284,6 +284,7 @@ static bool target_needs_new_hostgroup(const HostGroupState *hs, const Target *t
|
|||
|
||||
/* Different interface name? */
|
||||
if (hs->hostbatch[0]->deviceName() != NULL &&
|
||||
target->deviceName() != NULL &&
|
||||
strcmp(hs->hostbatch[0]->deviceName(), target->deviceName()) != 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue