Nmap Development mailing list archives

Re: [NSE] specify source port


From: doug () hcsw org
Date: Wed, 30 May 2007 13:40:18 -0700

Hi all!

Eddie is right in that the connect() system call doesn't let you specify
source ports but actually it's a little known fact that you can use the
bind() system call to request a socket to use specific source ports and
source IP addresses. For ports 1025 and up you don't even need root
privileges! See the nc -p switch for an example use of this:

nc -p 9876 google.com 80

will connect from local port 9876. If it is a common need a hook could
probably be added to nsock to let you bind() a socket before connect().
This creates a few technical problems however, the biggest of which is
that you will only be able to run one of these scripts at a time (not
in parallel) because the source port will be in use. Also, what does the
script do if some other application is using that port?

Best,

Doug


On Wed, May 30, 2007 at 01:04:19PM +0100 or thereabouts, Eddie Bell wrote:
hi ferdy,

Unfortunately this is not currently possible because the connect()
syscall, which NSE uses, does not support custom source ports.

  - eddie

On 29/05/07, Ferdy Riphagen <f.riphagen () nsec nl> wrote:
Hi all,

small question (if I may do so)
Is it possible to specify the source port in the connection. I've
created a nse script, and works on some systems, but others are willing
to talk if
you can specify the right source port.

Thanks,

Ferdy

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

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

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


Current thread: