mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Nping: bind to device when possible. See https://seclists.org/nmap-dev/2024/q2/9
This commit is contained in:
parent
dd7b7d76e8
commit
43234fbbdd
1 changed files with 5 additions and 10 deletions
|
|
@ -301,6 +301,11 @@ int ProbeMode::start(){
|
|||
/* Get socket descriptor. No need for it in ARP since we send at eth level */
|
||||
if ((rawipsd = obtainRawSocket()) < 0 )
|
||||
nping_fatal(QT_3,"Couldn't acquire raw socket. Are you root?");
|
||||
if ( o.issetDevice() ) {
|
||||
if (!socket_bindtodevice(rawipsd, o.getDevice()) && errno != EPERM) {
|
||||
nping_warning(QT_2, "Error binding socket to device %s", o.getDevice() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we have enough information to get the party started */
|
||||
|
|
@ -720,16 +725,6 @@ int ProbeMode::doIPv6ThroughSocket(int rawfd){
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Bind IPv6 socket to a specific network interface */
|
||||
if ( o.issetDevice() ) {
|
||||
/* It seems that SO_BINDTODEVICE only work on Linux */
|
||||
#ifdef LINUX
|
||||
if (setsockopt(rawfd, SOL_SOCKET, SO_BINDTODEVICE, o.getDevice(), strlen(o.getDevice())+1) == -1) {
|
||||
nping_warning(QT_2, "Error binding IPv6 socket to device %s", o.getDevice() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return OP_SUCCESS;
|
||||
|
||||
} /* End of doIPv6ThroughSocket() */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue