mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 12:41:29 +00:00
For generating ICMP IDs to send, use modulus and addition on a single random
number to guarantee it's nonzero (which some target hosts require) rather than looping for new random numbers. * ICMP ID values are unimportant, as long as they are nonzero * The original code to get random numbers was exactly duplicated (new variable, comment, loop, even whitespace) in the same function, so using a single variable set initially (albeit differently) simplifies duplication
This commit is contained in:
@@ -3160,6 +3160,8 @@ static UltraProbe *sendIPScanProbe(UltraScanInfo *USI, HostScanStats *hss,
|
||||
u32 vtag = 0;
|
||||
char *chunk = NULL;
|
||||
int chunklen = 0;
|
||||
/* Some hosts do not respond to ICMP requests if the identifier is 0. */
|
||||
u16 icmp_ident = (get_random_u16() % 0xffff) + 1;
|
||||
|
||||
if (USI->ethsd) {
|
||||
memcpy(eth.srcmac, hss->target->SrcMACAddress(), 6);
|
||||
@@ -3286,13 +3288,6 @@ static UltraProbe *sendIPScanProbe(UltraScanInfo *USI, HostScanStats *hss,
|
||||
&packetlen);
|
||||
break;
|
||||
case IPPROTO_ICMP:
|
||||
u16 icmp_ident;
|
||||
|
||||
/* Some hosts do not respond to ICMP requests if the identifier is 0. */
|
||||
do {
|
||||
icmp_ident = get_random_u16();
|
||||
} while (icmp_ident == 0);
|
||||
|
||||
packet = build_icmp_raw(&o.decoys[decoy], hss->target->v4hostip(),
|
||||
o.ttl, ipid, IP_TOS_DEFAULT, false,
|
||||
o.ipoptions, o.ipoptionslen,
|
||||
@@ -3353,13 +3348,6 @@ static UltraProbe *sendIPScanProbe(UltraScanInfo *USI, HostScanStats *hss,
|
||||
free(packet);
|
||||
}
|
||||
} else if (pspec->type == PS_ICMP) {
|
||||
u16 icmp_ident;
|
||||
|
||||
/* Some hosts do not respond to ICMP requests if the identifier is 0. */
|
||||
do {
|
||||
icmp_ident = get_random_u16();
|
||||
} while (icmp_ident == 0);
|
||||
|
||||
for(decoy = 0; decoy < o.numdecoys; decoy++) {
|
||||
packet = build_icmp_raw(&o.decoys[decoy], hss->target->v4hostip(),
|
||||
o.ttl, ipid, IP_TOS_DEFAULT, false,
|
||||
|
||||
Reference in New Issue
Block a user