1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-30 11:29:01 +00:00

This patch reorganizes the way ping probes are handled internally.

Previously the ping probe data structures were stored in NmapOps,
now they will be stored in the scan_lists struct. All other changes
auxiliary to this reorganization.
This commit is contained in:
michael
2008-05-29 07:49:37 +00:00
parent 29d2b20c98
commit 9f1c28ad9c
15 changed files with 253 additions and 240 deletions

View File

@@ -1473,12 +1473,12 @@ unsigned int UltraScanInfo::numProbesPerHost()
numprobes = 0;
if (ptech.rawtcpscan) {
if (o.pingtype & PINGTYPE_TCP_USE_ACK)
numprobes += o.num_ping_ackprobes;
numprobes += ports->ack_ping_count;
if (o.pingtype & PINGTYPE_TCP_USE_SYN)
numprobes += o.num_ping_synprobes;
numprobes += ports->syn_ping_count;
}
if (ptech.rawudpscan)
numprobes += o.num_ping_udpprobes;
numprobes += ports->udp_ping_count;
if (ptech.rawicmpscan) {
if (o.pingtype & PINGTYPE_ICMP_PING)
numprobes++;
@@ -1488,9 +1488,9 @@ unsigned int UltraScanInfo::numProbesPerHost()
numprobes++;
}
if (ptech.rawprotoscan)
numprobes += o.num_ping_protoprobes;
numprobes += ports->proto_ping_count;
if (ptech.connecttcpscan)
numprobes += o.num_ping_synprobes;
numprobes += ports->syn_ping_count;
} else assert(0); /* TODO: RPC scan */
return numprobes;
@@ -1762,22 +1762,22 @@ static int get_next_target_probe(UltraScanInfo *USI, HostScanStats *hss,
pspec->type = PS_TCP;
pspec->proto = IPPROTO_TCP;
if ((o.pingtype & PINGTYPE_TCP_USE_ACK)
&& hss->next_ackportpingidx < o.num_ping_ackprobes) {
pspec->pd.tcp.dport = o.ping_ackprobes[hss->next_ackportpingidx++];
&& hss->next_ackportpingidx < USI->ports->ack_ping_count) {
pspec->pd.tcp.dport = USI->ports->ack_ping_ports[hss->next_ackportpingidx++];
pspec->pd.tcp.flags = TH_ACK;
return 0;
}
if ((o.pingtype & PINGTYPE_TCP_USE_SYN)
&& hss->next_synportpingidx < o.num_ping_synprobes) {
pspec->pd.tcp.dport = o.ping_synprobes[hss->next_synportpingidx++];
&& hss->next_synportpingidx < USI->ports->syn_ping_count) {
pspec->pd.tcp.dport = USI->ports->syn_ping_ports[hss->next_synportpingidx++];
pspec->pd.tcp.flags = TH_SYN;
return 0;
}
}
if (USI->ptech.rawudpscan && hss->next_udpportpingidx < o.num_ping_udpprobes) {
if (USI->ptech.rawudpscan && hss->next_udpportpingidx < USI->ports->udp_ping_count) {
pspec->type = PS_UDP;
pspec->proto = IPPROTO_UDP;
pspec->pd.udp.dport = o.ping_udpprobes[hss->next_udpportpingidx++];
pspec->pd.udp.dport = USI->ports->udp_ping_ports[hss->next_udpportpingidx++];
return 0;
}
if (USI->ptech.rawicmpscan) {
@@ -1804,13 +1804,13 @@ static int get_next_target_probe(UltraScanInfo *USI, HostScanStats *hss,
}
if (USI->ptech.rawprotoscan) {
pspec->type = PS_PROTO;
pspec->proto = o.ping_protoprobes[hss->next_protoportpingidx++];
pspec->proto = USI->ports->proto_ping_ports[hss->next_protoportpingidx++];
return 0;
}
if (USI->ptech.connecttcpscan && hss->next_synportpingidx < o.num_ping_synprobes) {
if (USI->ptech.connecttcpscan && hss->next_synportpingidx < USI->ports->syn_ping_count) {
pspec->type = PS_CONNECTTCP;
pspec->proto = IPPROTO_TCP;
pspec->pd.tcp.dport = o.ping_synprobes[hss->next_synportpingidx++];
pspec->pd.tcp.dport = USI->ports->syn_ping_ports[hss->next_synportpingidx++];
pspec->pd.tcp.flags = TH_SYN;
return 0;
}
@@ -1840,14 +1840,14 @@ int HostScanStats::freshPortsLeft() {
unsigned int num_probes = 0;
if (USI->ptech.rawtcpscan) {
if ((o.pingtype & PINGTYPE_TCP_USE_ACK)
&& next_ackportpingidx < o.num_ping_ackprobes)
num_probes += o.num_ping_ackprobes - next_ackportpingidx;
&& next_ackportpingidx < USI->ports->ack_ping_count)
num_probes += USI->ports->ack_ping_count - next_ackportpingidx;
if ((o.pingtype & PINGTYPE_TCP_USE_SYN)
&& next_synportpingidx < o.num_ping_synprobes)
num_probes += o.num_ping_synprobes - next_synportpingidx;
&& next_synportpingidx < USI->ports->syn_ping_count)
num_probes += USI->ports->syn_ping_count - next_synportpingidx;
}
if (USI->ptech.rawudpscan && next_udpportpingidx < o.num_ping_udpprobes)
num_probes += o.num_ping_udpprobes - next_udpportpingidx;
if (USI->ptech.rawudpscan && next_udpportpingidx < USI->ports->udp_ping_count)
num_probes += USI->ports->udp_ping_count - next_udpportpingidx;
if (USI->ptech.rawicmpscan) {
if ((o.pingtype & PINGTYPE_ICMP_PING) && !sent_icmp_ping)
num_probes++;
@@ -1857,9 +1857,9 @@ int HostScanStats::freshPortsLeft() {
num_probes++;
}
if (USI->ptech.rawprotoscan)
num_probes += o.num_ping_protoprobes - next_protoportpingidx;
if (USI->ptech.connecttcpscan && next_synportpingidx < o.num_ping_synprobes)
num_probes += o.num_ping_synprobes - next_synportpingidx;
num_probes += USI->ports->proto_ping_count - next_protoportpingidx;
if (USI->ptech.connecttcpscan && next_synportpingidx < USI->ports->syn_ping_count)
num_probes += USI->ports->syn_ping_count - next_synportpingidx;
return num_probes;
}
assert(0);
@@ -3150,6 +3150,10 @@ static void printAnyStats(UltraScanInfo *USI) {
USI->send_rate_meter.getOverallByteRate());
}
if (o.debugging > 2) {
log_write(LOG_PLAIN, "packet_ratio: %.2f %d/%d %.5f = 1 / %.5f\n", o.TimeSinceStartMS() / 1000.0, USI->gstats->probes_replied_to, USI->gstats->probes_sent, 1.0 / USI->gstats->cc_scale(), USI->gstats->cc_scale());
}
/* Now time to figure out how close we are to completion ... */
if (USI->SPM->mayBePrinted(&USI->now)) {
list<HostScanStats *>::iterator hostI;
@@ -3351,7 +3355,7 @@ static bool do_one_select_round(UltraScanInfo *USI, struct timeval *stime) {
current_reason = ER_CONREFUSED;
break;
case EAGAIN:
log_write(LOG_STDOUT, "Machine %s MIGHT actually be listening on probe port %d\n", host->target->targetipstr(), o.ping_synprobes[probe->dport()]);
log_write(LOG_STDOUT, "Machine %s MIGHT actually be listening on probe port %d\n", host->target->targetipstr(), USI->ports->syn_ping_ports[probe->dport()]);
/* Fall through. */
#ifdef WIN32
case WSAENOTCONN: