Nmap Development mailing list archives

Re: Nsock unconnected sockets


From: Kris Katterjohn <katterjohn () gmail com>
Date: Sun, 10 Oct 2010 23:39:44 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/09/2010 06:25 PM, David Fifield wrote:
On Tue, Oct 05, 2010 at 04:37:54PM -0700, David Fifield wrote:
On Mon, Oct 04, 2010 at 11:01:50PM -0500, Kris Katterjohn wrote:
On 10/04/2010 10:18 PM, David Fifield wrote:
Another thing to consider is that at least one function, bind, needs to
be called before the socket is connected.

Sorry, but I'm not sure how this would be an issue.

new_socket("tcp")
bind("192.168.10.69", 31337)
connect("192.168.10.1", 80)

and

new_socket("udp")
bind("192.168.10.69", 31337)
sendto("192.168.10.1", 53, "stuff")

How would these not work?  I suspect something may have to be moved around,
but are these really not possible?

You're right, this is a better interface. I'll see what's needed to make
it work.

This is what I've implemented now. new_socket works the way it always
has, except that you can optionally declare a protocol and address
family.

s = nmap.new_socket("udp")

The iod isn't created at this point. The address family and protocol are
just cached for later. You can connect it as before. If you try to do an
operation such as a send or receive without first connecting, an iod is
created on demand using the information you provided to new_socket.

s:bind(nil, 888)
s:receive()
s:sendto("1.2.3.4", 888, data)

If you connect with a different protocol, it overrides whatever you set
earlier. The third argument to connect is optional if it's what you
already set in new_socket.


Cool.  I've been gone all weekend, but now at first consideration this sounds
good.  Thanks for looking into my suggestions.

David Fifield

Cheers,
Kris Katterjohn

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMspUPAAoJEEQxgFs5kUfuflcP/0b0VsFLIonlS8CpxCf+wNJd
QbiC6hq2AheYNj7OcWmNN3jhZ0mVdlwj9Ow/gf2IT4718JgFaaSeuDjcf3WYY4R8
3FBPO3q5PzAXK+5VidAUSf0Ge0FjHuLEP6RN6zN711uDT97bKy4WRk4PrEeaPFmX
HNY0roNGxm/fxtuRrHR3QrcTJDW6Sg8OR+tU7fZjtg/2kcH8Wg3152m5f4qb+nAt
tigVFZd8kJeqhDzUHpf2DObluUQ9lrmvq4Ge4ehwibZK3bv4F8VARkfLdPwk1OFv
d4jEmKDBUybwNg9jv4MLzTDshzxOZZsb/McKlXZD/IMiJgnOrCBQj6b+VkQr2KwO
WS/h+GAK2kB94n//o3xWoqu3PZawExB5akbsyekOFgm989cKO6H9vCFIgxS3hYmW
VeJxYE6JcExBrvI3a8dRqh0ODPBxjSfgfJVDvYJJws2X5Tp6LBPLN5s5V42RWDOw
13Q5u73OvoWEEvlz3rDlHa1kxFpE28mqCgzknpqsK7we/tYyq6QxE29285TudXxV
XFN7Y7RTvE6pa6uzkRkWwk4ZvDoJSVeBMp7MxF7LE6kTt7GFPq6a8YefmZ3GXRp3
6GrbNy2j9ME08zJAfmTCu8cEjTalCC+DQSvHubuK48LTfByc30r87nP1lMslFzb0
YmFogRQw4EFnlJA3TTgF
=obPT
-----END PGP SIGNATURE-----
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: