36
36
* These restrictions only apply when you actually redistribute Nmap. For *
37
37
* example, nothing stops you from writing and selling a proprietary *
38
38
* front-end to Nmap. Just distribute it by itself, and point people to *
39
* http://insecure.org/nmap/ to download Nmap. *
39
* http://nmap.org to download Nmap. *
41
41
* We don't consider these to be added restrictions on top of the GPL, but *
42
42
* just a clarification of how we interpret "derived works" as it applies *
75
75
* Source code also allows you to port Nmap to new platforms, fix bugs, *
76
76
* and add new features. You are highly encouraged to send your changes *
77
77
* to fyodor@insecure.org for possible incorporation into the main *
78
* distribution. By sending these changes to Fyodor or one the *
78
* distribution. By sending these changes to Fyodor or one of the *
79
79
* Insecure.Org development mailing lists, it is assumed that you are *
80
80
* offering Fyodor and Insecure.Com LLC the unlimited, non-exclusive right *
81
81
* to reuse, modify, and relicense the code. Nmap will always be *
347
347
open_port = (!scaninfo.open_response) ? 0 : 1;
350
/* First we try to find an open port, if not we try to find a closed
351
* port and lastly we try to find a filtered port */
352
if (open_port && t->ports.getStateCounts (proto, scaninfo.open_state))
353
state = scaninfo.open_state;
354
else if (closed_port && t->ports.getStateCounts (proto, scaninfo.closed_state))
355
state = scaninfo.closed_state;
356
else if (filtered_port && t->ports.getStateCounts (proto, PORT_FILTERED)) {
350
/* For UDP we try for a closed port, then an open one. For everything else
351
* we try the opposite. When all else fails, we try for filtered */
352
if (proto == IPPROTO_UDP) {
353
if (closed_port && t->ports.getStateCounts (proto, scaninfo.closed_state))
354
state = scaninfo.closed_state;
355
else if (open_port && t->ports.getStateCounts (proto, scaninfo.open_state))
356
state = scaninfo.open_state;
358
if (open_port && t->ports.getStateCounts (proto, scaninfo.open_state))
359
state = scaninfo.open_state;
360
else if (closed_port && t->ports.getStateCounts (proto, scaninfo.closed_state))
361
state = scaninfo.closed_state;
364
if (state == -1 && filtered_port &&
365
t->ports.getStateCounts (proto, PORT_FILTERED)) {
357
366
state = PORT_FILTERED;
359
368
log_write (LOG_PLAIN, "%s: only filtered %s available, results may be incorrect\n",
360
369
t->targetipstr (), o.ipprotscan ? "protocols" : "ports");
365
375
np = t->ports.nextPort (NULL, proto, state);
1125
1135
addr.s_addr = commonPath[ttl_count];
1126
1136
log_write(LOG_XML, "<hop ttl=\"%d\" rtt=\"--\" ", ttl_count);
1127
1137
log_write(LOG_XML, "ipaddr=\"%s\"", inet_ntoa(addr));
1128
if((hostname_tmp = lookup_cached_host(commonPath[ttl_count])) != "")
1138
if((hostname_tmp = lookup_cached_host(commonPath[ttl_count])) != NULL)
1129
1139
log_write(LOG_XML, " host=\"%s\"", hostname_tmp);
1130
1140
log_write(LOG_XML, "/>\n");
1493
1503
memset (nameipbuf, '\0', MAXHOSTNAMELEN + INET6_ADDRSTRLEN);
1494
1504
addr.s_addr = ip;
1495
if((hname = lookup_cached_host(ip)) == "")
1505
if((hname = lookup_cached_host(ip)) == NULL)
1496
1506
Snprintf(nameipbuf, MAXHOSTNAMELEN+INET6_ADDRSTRLEN, "%s", inet_ntoa(addr));
1498
1508
Snprintf (nameipbuf, MAXHOSTNAMELEN + INET6_ADDRSTRLEN, "%s (%s)", hname, inet_ntoa (addr));