mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
enable --ttl support for connect() scans
This commit is contained in:
parent
8725d37b47
commit
dfc9eba4db
3 changed files with 13 additions and 0 deletions
|
|
@ -2458,6 +2458,7 @@ static UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss,
|
|||
if (CP->sd == -1) pfatal("Socket creation in %s", __func__);
|
||||
unblock_socket(CP->sd);
|
||||
init_socket(CP->sd);
|
||||
set_ttl(CP->sd, o.ttl);
|
||||
if (hss->target->TargetSockAddr(&sock, &socklen) != 0) {
|
||||
fatal("Failed to get target socket address in %s", __func__);
|
||||
}
|
||||
|
|
|
|||
10
tcpip.cc
10
tcpip.cc
|
|
@ -161,6 +161,16 @@ setsockopt(sd, IPPROTO_IP, IP_HDRINCL, (const char *) &one, sizeof(one));
|
|||
#endif
|
||||
}
|
||||
|
||||
void set_ttl(int sd, int ttl)
|
||||
{
|
||||
#ifdef IP_TTL
|
||||
if (sd == -1)
|
||||
return;
|
||||
|
||||
setsockopt(sd, IPPROTO_IP, IP_TTL, &ttl, sizeof ttl);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Takes a protocol number like IPPROTO_TCP, IPPROTO_UDP, or
|
||||
// IPPROTO_IP and returns a ascii representation (or "unknown" if it
|
||||
// doesn't recognize the number). If uppercase is true, the returned
|
||||
|
|
|
|||
2
tcpip.h
2
tcpip.h
|
|
@ -663,6 +663,8 @@ pcap_if_t *getpcapinterfaces();
|
|||
struct sys_route *getsysroutes(int *howmany);
|
||||
void sethdrinclude(int sd);
|
||||
|
||||
void set_ttl(int sd, int ttl);
|
||||
|
||||
/* Fill buf (up to buflen -- truncate if necessary but always
|
||||
terminate) with a short representation of the packet stats.
|
||||
Returns buf. Aborts if there is a problem. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue