enable --ttl support for connect() scans

This commit is contained in:
kris 2007-10-14 14:37:56 +00:00
parent 8725d37b47
commit dfc9eba4db
3 changed files with 13 additions and 0 deletions

View file

@ -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__);
}

View file

@ -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

View file

@ -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. */