From 299e0de19efff8f6c7656918543960b17d3df478 Mon Sep 17 00:00:00 2001 From: kris Date: Mon, 14 Jul 2008 20:02:30 +0000 Subject: [PATCH] o Added --ip-options support for the connect() scan (-sT). [Kris] --- CHANGELOG | 2 ++ scan_engine.cc | 2 ++ tcpip.cc | 10 ++++++++++ tcpip.h | 2 ++ 4 files changed, 16 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6b354b2df..ef5123a40 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -58,6 +58,8 @@ o Nsock now supports binding to a local address and setting IPv4 options o Nmap's Nsock-utilizing subsystems (DNS, NSE, version detection) have been updated to support the -S and --ip-options flags. [Kris] +o Added --ip-options support for the connect() scan (-sT). [Kris] + Nmap 4.68 [2008-6-28] o Doug integrated all of your version detection submissions and diff --git a/scan_engine.cc b/scan_engine.cc index c09b1ec1f..e112f7870 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2588,6 +2588,8 @@ static UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss, unblock_socket(CP->sd); init_socket(CP->sd); set_ttl(CP->sd, o.ttl); + if (o.ipoptionslen) + set_ipoptions(CP->sd, o.ipoptions, o.ipoptionslen); if (hss->target->TargetSockAddr(&sock, &socklen) != 0) { fatal("Failed to get target socket address in %s", __func__); } diff --git a/tcpip.cc b/tcpip.cc index f0857af49..58c2f9b1c 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -161,6 +161,16 @@ setsockopt(sd, IPPROTO_IP, IP_HDRINCL, (const char *) &one, sizeof(one)); #endif } +void set_ipoptions(int sd, void *opts, size_t optslen) +{ +#ifdef IP_OPTIONS + if (sd == -1) + return; + + setsockopt(sd, IPPROTO_IP, IP_OPTIONS, opts, optslen); +#endif +} + void set_ttl(int sd, int ttl) { #ifdef IP_TTL diff --git a/tcpip.h b/tcpip.h index 8add07eb5..6adcd5788 100644 --- a/tcpip.h +++ b/tcpip.h @@ -663,6 +663,8 @@ pcap_if_t *getpcapinterfaces(); struct sys_route *getsysroutes(int *howmany); void sethdrinclude(int sd); +void set_ipoptions(int sd, void *opts, size_t optslen); + void set_ttl(int sd, int ttl); /* Fill buf (up to buflen -- truncate if necessary but always