Nmap Security Scanner
*Intro
*Ref Guide
*Install Guide
*Download
*Changelog
*Book
*Docs
Security Lists
*Nmap Hackers
*Nmap Dev
*Bugtraq
*Full Disclosure
*Pen Test
*Basics
*More
Security Tools
*Pass crackers
*Sniffers
*Vuln Scanners
*Web scanners
*Wireless
*Exploitation
*Packet crafters
*More
Site News
Site Search:
Exploit World
Advertising
About/Contact
Credits
Sponsors:




nmap-dev logo Nmap Development mailing list archives

Re: Ncat: socket bind error on Mac OS X
From: David Fifield <david () bamsoftware com>
Date: Sun, 27 Jul 2008 16:10:05 -0600

On Sun, Jul 27, 2008 at 01:14:40PM +0200, Dirk Loss wrote:
on Mac OS X 10.5.4 (Intel) Ncat dies with the following error when I try 
to put it into listening mode:

$ ncat -l 22222
bind: Invalid argument

Running Ncat as root, switching to UDP or disabling IPv6 in my system 
preferences did not help. I verified that there is no other process 
listing on my local TCP port 22222.

Apparently the bind() call in sys_wrap.c returns -1 and errno = 22 
(EINVAL). According to the man page [1], this means that either the 
"socket is already bound to an address and the protocol does not support 
binding to a new address" or the "socket may have been shut down."

I think I have tracked this down. bind is being picky about the address
length. Currently do_listen is calling Bind with sizeof(srcaddr), which
is 128. If I change it to sizeof(struct sockaddr_in), which is 16, then
it works. Of course, that only works for IPv4 addresses, so it needs to
be based on the address family.

BSDs have an extra sockaddr.sa_len (and sockaddr_storage.ss_len, and
sockaddr_in.sin_len) member. Currently it's always set to 0 by memset. I
tried setting it to a proper value and it didn't seem to make a
difference. However, changing the address length passed to bind did
work.

David Fifield

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]