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

After a successful traceroute, set the distance to the host in question

so it appears in OS fingerprints.
This commit is contained in:
david
2009-08-20 20:57:35 +00:00
parent 0ffa072a6b
commit 5c1168c024
2 changed files with 26 additions and 1 deletions

View File

@@ -802,6 +802,16 @@ Traceroute::trace(vector < Target * >&Targets) {
swap(total_complete, total_size);
SPM->printStats(MIN((double) total_complete / total_size, 0.99), NULL);
}
/* Now set the distance in the Target structure for each of the valid
* targets. */
for (targ = valid_targets.begin(); targ != valid_targets.end(); ++targ) {
int distance;
distance = TraceGroups[t->v4host().s_addr]->getDistance();
if (distance != -1)
(*targ)->distance = distance;
}
SPM->endTask(NULL, NULL);
delete SPM;
}
@@ -1135,7 +1145,6 @@ TraceGroup::retransmissions(vector < TraceProbe * >&retrans) {
if ((++consecTimeouts) > 5 && maxRetransmissions > 2)
maxRetransmissions = 2;
if (it->second->probeType() == PROBE_TTL) {
hopDistance = 1;
noDistProbe = true;
/* Give up on this host. We should be able to do a trace against
an unresponsive target but for now it's too slow. */
@@ -1274,6 +1283,17 @@ TraceGroup::setHopDistance(u8 hop_distance, u8 ttl) {
return this->hopDistance;
}
/* Get the number of hops to the target, or -1 if unknown. Use this instead of
* reading hopDistance, which despite its name does not contain the final hop
* count. */
int TraceGroup::getDistance() {
if (this->getState() != G_FINISH)
return -1;
/* After a successful trace, hopDistance is 1 greater than the number of
* hops. */
return this->hopDistance - 1;
}
TraceProbe::TraceProbe(u32 dip, u32 sip, u16 sport, struct probespec& probe) {
this->sport = sport;
this->probe = probe;

View File

@@ -227,6 +227,11 @@ class TraceGroup {
u8 setState(u8 state);
u8 setHopDistance(u8 hop_distance, u8 ttl);
/* Get the number of hops to the target, or -1 if unknown. Use this instead
* of reading hopDistance, which despite its name does not contain the final
* hop count. */
int getDistance();
bool gotReply;
bool noDistProbe;