mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
Fixed scanning the same IP multiple times with a type of scan that is now raw, incompleteHosts and completedHosts are now multisets instead of sets
This commit is contained in:
@@ -760,7 +760,7 @@ UltraScanInfo::UltraScanInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UltraScanInfo::~UltraScanInfo() {
|
UltraScanInfo::~UltraScanInfo() {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
|
|
||||||
for (hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) {
|
for (hostI = incompleteHosts.begin(); hostI != incompleteHosts.end(); hostI++) {
|
||||||
delete *hostI;
|
delete *hostI;
|
||||||
@@ -819,7 +819,7 @@ HostScanStats *UltraScanInfo::nextIncompleteHost() {
|
|||||||
/* Return a number between 0.0 and 1.0 inclusive indicating how much of the scan
|
/* Return a number between 0.0 and 1.0 inclusive indicating how much of the scan
|
||||||
is done. */
|
is done. */
|
||||||
double UltraScanInfo::getCompletionFraction() {
|
double UltraScanInfo::getCompletionFraction() {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
double total;
|
double total;
|
||||||
|
|
||||||
/* Add 1 for each completed host. */
|
/* Add 1 for each completed host. */
|
||||||
@@ -1076,7 +1076,7 @@ unsigned int UltraScanInfo::numProbesPerHost() {
|
|||||||
bool UltraScanInfo::sendOK(struct timeval *when) {
|
bool UltraScanInfo::sendOK(struct timeval *when) {
|
||||||
struct timeval lowhtime = {0};
|
struct timeval lowhtime = {0};
|
||||||
struct timeval tmptv;
|
struct timeval tmptv;
|
||||||
std::set<HostScanStats *>::iterator host;
|
std::multiset<HostScanStats *>::iterator host;
|
||||||
bool ggood = false;
|
bool ggood = false;
|
||||||
bool thisHostGood = false;
|
bool thisHostGood = false;
|
||||||
bool foundgood = false;
|
bool foundgood = false;
|
||||||
@@ -1134,7 +1134,7 @@ bool UltraScanInfo::sendOK(struct timeval *when) {
|
|||||||
/* Find a HostScanStats by its IP address in the incomplete and completed lists.
|
/* Find a HostScanStats by its IP address in the incomplete and completed lists.
|
||||||
Returns NULL if none are found. */
|
Returns NULL if none are found. */
|
||||||
HostScanStats *UltraScanInfo::findHost(struct sockaddr_storage *ss) {
|
HostScanStats *UltraScanInfo::findHost(struct sockaddr_storage *ss) {
|
||||||
std::set<HostScanStats *>::iterator hss;
|
std::multiset<HostScanStats *>::iterator hss;
|
||||||
|
|
||||||
HssPredicate::ss = ss;
|
HssPredicate::ss = ss;
|
||||||
HostScanStats *fakeHss = NULL;
|
HostScanStats *fakeHss = NULL;
|
||||||
@@ -1160,7 +1160,7 @@ HostScanStats *UltraScanInfo::findHost(struct sockaddr_storage *ss) {
|
|||||||
is here to replace numIncompleteHosts() < n, which would have to walk
|
is here to replace numIncompleteHosts() < n, which would have to walk
|
||||||
through the entire list. */
|
through the entire list. */
|
||||||
bool UltraScanInfo::numIncompleteHostsLessThan(unsigned int n) {
|
bool UltraScanInfo::numIncompleteHostsLessThan(unsigned int n) {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
@@ -1180,7 +1180,7 @@ static bool pingprobe_is_better(const probespec *new_probe, int new_state,
|
|||||||
list, and remove any hosts from completedHosts which have exceeded their
|
list, and remove any hosts from completedHosts which have exceeded their
|
||||||
lifetime. Returns the number of hosts removed. */
|
lifetime. Returns the number of hosts removed. */
|
||||||
int UltraScanInfo::removeCompletedHosts() {
|
int UltraScanInfo::removeCompletedHosts() {
|
||||||
std::set<HostScanStats *>::iterator hostI, nxt;
|
std::multiset<HostScanStats *>::iterator hostI, nxt;
|
||||||
HostScanStats *hss = NULL;
|
HostScanStats *hss = NULL;
|
||||||
int hostsRemoved = 0;
|
int hostsRemoved = 0;
|
||||||
bool timedout = false;
|
bool timedout = false;
|
||||||
@@ -2290,7 +2290,7 @@ static void sendGlobalPingProbe(UltraScanInfo *USI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void doAnyPings(UltraScanInfo *USI) {
|
static void doAnyPings(UltraScanInfo *USI) {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
HostScanStats *hss = NULL;
|
HostScanStats *hss = NULL;
|
||||||
|
|
||||||
gettimeofday(&USI->now, NULL);
|
gettimeofday(&USI->now, NULL);
|
||||||
@@ -2365,7 +2365,7 @@ static void retransmitProbe(UltraScanInfo *USI, HostScanStats *hss,
|
|||||||
/* Go through the ProbeQueue of each host, identify any
|
/* Go through the ProbeQueue of each host, identify any
|
||||||
timed out probes, then try to retransmit them as appropriate */
|
timed out probes, then try to retransmit them as appropriate */
|
||||||
static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
|
static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
std::list<UltraProbe *>::iterator probeI;
|
std::list<UltraProbe *>::iterator probeI;
|
||||||
/* A cache of the last processed probe from each host, to avoid re-examining a
|
/* A cache of the last processed probe from each host, to avoid re-examining a
|
||||||
bunch of probes to find the next one that needs to be retransmitted. */
|
bunch of probes to find the next one that needs to be retransmitted. */
|
||||||
@@ -2445,7 +2445,7 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
|
|||||||
/* Print occasional remaining time estimates, as well as
|
/* Print occasional remaining time estimates, as well as
|
||||||
debugging information */
|
debugging information */
|
||||||
static void printAnyStats(UltraScanInfo *USI) {
|
static void printAnyStats(UltraScanInfo *USI) {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
HostScanStats *hss;
|
HostScanStats *hss;
|
||||||
struct ultra_timing_vals hosttm;
|
struct ultra_timing_vals hosttm;
|
||||||
|
|
||||||
@@ -2515,7 +2515,7 @@ static void waitForResponses(UltraScanInfo *USI) {
|
|||||||
/* Go through the data structures, making appropriate changes (such as expiring
|
/* Go through the data structures, making appropriate changes (such as expiring
|
||||||
probes, noting when hosts are complete, etc. */
|
probes, noting when hosts are complete, etc. */
|
||||||
static void processData(UltraScanInfo *USI) {
|
static void processData(UltraScanInfo *USI) {
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
std::list<UltraProbe *>::iterator probeI, nextProbeI;
|
std::list<UltraProbe *>::iterator probeI, nextProbeI;
|
||||||
HostScanStats *host = NULL;
|
HostScanStats *host = NULL;
|
||||||
UltraProbe *probe = NULL;
|
UltraProbe *probe = NULL;
|
||||||
|
|||||||
@@ -738,11 +738,11 @@ public:
|
|||||||
|
|
||||||
/* Any function which messes with (removes elements from)
|
/* Any function which messes with (removes elements from)
|
||||||
incompleteHosts may have to manipulate nextI */
|
incompleteHosts may have to manipulate nextI */
|
||||||
std::set<HostScanStats *, HssPredicate> incompleteHosts;
|
std::multiset<HostScanStats *, HssPredicate> incompleteHosts;
|
||||||
/* Hosts are moved from incompleteHosts to completedHosts as they are
|
/* Hosts are moved from incompleteHosts to completedHosts as they are
|
||||||
completed. We keep them around because sometimes responses come back very
|
completed. We keep them around because sometimes responses come back very
|
||||||
late, after we consider a host completed. */
|
late, after we consider a host completed. */
|
||||||
std::set<HostScanStats *, HssPredicate> completedHosts;
|
std::multiset<HostScanStats *, HssPredicate> completedHosts;
|
||||||
/* How long (in msecs) we keep a host in completedHosts */
|
/* How long (in msecs) we keep a host in completedHosts */
|
||||||
unsigned int completedHostLifetime;
|
unsigned int completedHostLifetime;
|
||||||
/* The last time we went through completedHosts to remove hosts */
|
/* The last time we went through completedHosts to remove hosts */
|
||||||
@@ -759,7 +759,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned int numInitialTargets;
|
unsigned int numInitialTargets;
|
||||||
std::set<HostScanStats *>::iterator nextI;
|
std::multiset<HostScanStats *>::iterator nextI;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
|
|||||||
int timeleft;
|
int timeleft;
|
||||||
ConnectScanInfo *CSI = USI->gstats->CSI;
|
ConnectScanInfo *CSI = USI->gstats->CSI;
|
||||||
int sd;
|
int sd;
|
||||||
std::set<HostScanStats *>::iterator hostI;
|
std::multiset<HostScanStats *>::iterator hostI;
|
||||||
HostScanStats *host;
|
HostScanStats *host;
|
||||||
UltraProbe *probe = NULL;
|
UltraProbe *probe = NULL;
|
||||||
int optval;
|
int optval;
|
||||||
@@ -530,7 +530,7 @@ bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
|
|||||||
and find the relevant ones. Note the peculiar structure of the loop--we
|
and find the relevant ones. Note the peculiar structure of the loop--we
|
||||||
iterate through both incompleteHosts and completedHosts, because global
|
iterate through both incompleteHosts and completedHosts, because global
|
||||||
timing pings are sent to hosts in completedHosts. */
|
timing pings are sent to hosts in completedHosts. */
|
||||||
std::set<HostScanStats *>::iterator incompleteHostI, completedHostI;
|
std::multiset<HostScanStats *>::iterator incompleteHostI, completedHostI;
|
||||||
incompleteHostI = USI->incompleteHosts.begin();
|
incompleteHostI = USI->incompleteHosts.begin();
|
||||||
completedHostI = USI->completedHosts.begin();
|
completedHostI = USI->completedHosts.begin();
|
||||||
while ((incompleteHostI != USI->incompleteHosts.end()
|
while ((incompleteHostI != USI->incompleteHosts.end()
|
||||||
|
|||||||
Reference in New Issue
Block a user