mirror of
https://github.com/nmap/nmap.git
synced 2026-01-10 08:29:02 +00:00
merge soc07 r4780 - Moved OSScan warning message (may not be reliable because could not find 1 open and 1 closed port) so it is printed along with the OSScan results instead of above it
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o Relocated OSScan warning message (could not find 1 closed and 1 open
|
||||
port). Now output.cc prints the warning along with a targets OSScan
|
||||
results. [Eddie]
|
||||
|
||||
o Fixed a bug which caused port 0 to be improperly used for gen1 OS
|
||||
detection in some cases when your scan includes port 0 (it isn't
|
||||
included by default). Thanks to Sebastian Wolfgarten for the report
|
||||
|
||||
14
Target.cc
14
Target.cc
@@ -122,7 +122,7 @@ void Target::Initialize() {
|
||||
distance = -1;
|
||||
FPR1 = NULL;
|
||||
FPR = NULL;
|
||||
osscan_performed = 0;
|
||||
osscan_flag = OS_NOTPERF;
|
||||
wierd_responses = flags = 0;
|
||||
memset(&to, 0, sizeof(to));
|
||||
memset(&targetsock, 0, sizeof(targetsock));
|
||||
@@ -443,3 +443,15 @@ const u8 *Target::SrcMACAddress() {
|
||||
const u8 *Target::NextHopMACAddress() {
|
||||
return (NextHopMACaddress_set)? NextHopMACaddress : NULL;
|
||||
}
|
||||
|
||||
int Target::osscanPerformed(void) {
|
||||
return osscan_flag;
|
||||
}
|
||||
|
||||
void Target::osscanSetFlag(int flag) {
|
||||
if(osscan_flag == OS_PERF_UNREL)
|
||||
return;
|
||||
else
|
||||
osscan_flag = flag;
|
||||
}
|
||||
|
||||
|
||||
12
Target.h
12
Target.h
@@ -112,6 +112,10 @@
|
||||
#define INET6_ADDRSTRLEN 46
|
||||
#endif
|
||||
|
||||
enum osscan_flags {
|
||||
OS_NOTPERF=0, OS_PERF, OS_PERF_UNREL
|
||||
};
|
||||
|
||||
struct host_timeout_nfo {
|
||||
unsigned long msecs_used; /* How many msecs has this Target used? */
|
||||
bool toclock_running; /* Is the clock running right now? */
|
||||
@@ -220,11 +224,13 @@ class Target {
|
||||
const char *deviceName();
|
||||
const char *deviceFullName();
|
||||
|
||||
int osscanPerformed(void);
|
||||
void osscanSetFlag(int flag);
|
||||
|
||||
struct seq_info seq;
|
||||
int distance;
|
||||
FingerPrintResults *FPR1; /* FP results get by the old OS scan system. */
|
||||
FingerPrintResults *FPR; /* FP results get by the new OS scan system. */
|
||||
int osscan_performed; /* nonzero if an osscan was performed */
|
||||
PortList ports;
|
||||
|
||||
// unsigned int up;
|
||||
@@ -253,6 +259,10 @@ class Target {
|
||||
devtype interface_type;
|
||||
char devname[32];
|
||||
char devfullname[32];
|
||||
/* 0 (OS_NOTPERF) if os detection not performed
|
||||
* 1 (OS_PERF) if os detection performed
|
||||
* 2 (OS_PERF_UNREL) if an unreliable os detection has been performed */
|
||||
int osscan_flag;
|
||||
};
|
||||
|
||||
#endif /* TARGET_H */
|
||||
|
||||
@@ -195,7 +195,7 @@ void set_hostinfo(lua_State* l, Target *currenths) {
|
||||
* result, we will use it in the scripts
|
||||
* matches which aren't perfect are not needed in the scripts
|
||||
*/
|
||||
if( currenths->osscan_performed &&
|
||||
if( currenths->osscanPerformed() &&
|
||||
FPR != NULL &&
|
||||
FPR->overall_results == OSSCAN_SUCCESS &&
|
||||
FPR->num_perfect_matches > 0 &&
|
||||
|
||||
@@ -560,7 +560,7 @@ static FingerPrint *get_fingerprint(Target *target, struct seq_info *si) {
|
||||
snprintf(filter, sizeof(filter), "dst host %s and (icmp or (tcp and src host %s))", inet_ntoa(target->v4source()), target->targetipstr());
|
||||
|
||||
set_pcap_filter(target->deviceName(), pd, filter);
|
||||
target->osscan_performed = 1; /* Let Nmap know that we did try an OS scan */
|
||||
target->osscanSetFlag(OS_PERF); /* Let Nmap know that we did try an OS scan */
|
||||
|
||||
/* Lets find an open port to use */
|
||||
openport = (unsigned long) -1;
|
||||
@@ -1506,7 +1506,7 @@ o.current_scantype = OS_SCAN;
|
||||
log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID, "Skipping OS Scan due to absence of open (or perhaps closed) ports\n");
|
||||
return 1;
|
||||
} else {
|
||||
log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID,"Warning: OS detection will be MUCH less reliable because we did not find at least 1 open and 1 closed TCP port\n");
|
||||
target->osscanSetFlag(OS_PERF_UNREL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2852,7 +2852,7 @@ HostOsScanInfo::HostOsScanInfo(Target *t, OsScanInfo *OsSI) {
|
||||
|
||||
if (target->FPR == NULL)
|
||||
target->FPR = new FingerPrintResults;
|
||||
target->osscan_performed = 1;
|
||||
target->osscanSetFlag(OS_PERF);
|
||||
|
||||
hss = new HostOsScanStats(t);
|
||||
}
|
||||
@@ -2898,7 +2898,7 @@ OsScanInfo::OsScanInfo(vector<Target *> &Targets) {
|
||||
log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID, "Skipping OS Scan against %s due to absence of open (or perhaps closed) ports\n", Targets[targetno]->NameIP());
|
||||
continue;
|
||||
} else {
|
||||
log_write(LOG_STDOUT|LOG_NORMAL|LOG_SKID,"Warning: OS detection for %s will be MUCH less reliable because we did not find at least 1 open and 1 closed TCP port\n", Targets[targetno]->targetipstr());
|
||||
Targets[targetno]->osscanSetFlag(OS_PERF_UNREL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
12
output.cc
12
output.cc
@@ -1337,10 +1337,11 @@ void printosscanoutput(Target *currenths) {
|
||||
FingerPrintResults *FPR;
|
||||
int osscanSys = 0;
|
||||
int distance = -1;
|
||||
int osscan_flag;
|
||||
|
||||
if (!currenths->osscan_performed)
|
||||
if (!(osscan_flag = currenths->osscanPerformed()))
|
||||
return;
|
||||
|
||||
|
||||
if (currenths->FPR == NULL && currenths->FPR1 == NULL) {
|
||||
return;
|
||||
} else if (currenths->FPR != NULL && currenths->FPR1 == NULL) {
|
||||
@@ -1387,7 +1388,12 @@ void printosscanoutput(Target *currenths) {
|
||||
"<portused state=\"closed\" proto=\"udp\" portid=\"%hu\" />\n",
|
||||
FPR->osscan_closedudpport);
|
||||
}
|
||||
|
||||
|
||||
if(osscan_flag == OS_PERF_UNREL &&
|
||||
!(FPR->overall_results == OSSCAN_TOOMANYMATCHES ||
|
||||
(FPR->num_perfect_matches > 8 && !o.debugging)))
|
||||
log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port\n");
|
||||
|
||||
// If the FP can't be submitted anyway, might as well make a guess.
|
||||
const char *reason = FPR->OmitSubmissionFP();
|
||||
printosclassificationoutput(FPR->getOSClassification(),
|
||||
|
||||
Reference in New Issue
Block a user