Nmap Development mailing list archives

Re: Two NSE questions


From: Kris Katterjohn <katterjohn () gmail com>
Date: Wed, 30 Sep 2009 23:14:26 -0500

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

On 09/30/2009 10:13 PM, David Fifield wrote:
On Tue, Sep 29, 2009 at 03:33:34PM -0500, Ron wrote:
On 09/29/2009 03:24 PM, David Fifield wrote:
Ron, if you propose an interface for setting the source address I'll
look into writing the binding. Just show me a snippet of your code as it
would work with the new function, and any other cases you think need to
be handled.
I'm not particularly picky with how it should work, but the most logical  
(to me) would be to change the connect() function from this:

connect(hostid, port, protocol)

To this:

connect(hostid, port, protocol, lhostid, lport)

I'm not sure if setting the local address makes sense, but setting the  
local port in a connect call would be ideal. Another option would be:

local socket = nmap.new_socket()
set_local_port(socket, 67)
connect(host, 68, 'udp')
...

That's a little uglier, in my mind, but it is sufficiently usable.

Hmm, I like the second option because it's like the way to set a
timeout. I also think of a source address as a property of a socket, not
of a connection. But I think I would make it a method of a socket
object, like this:

local socket = nmap.new_socket()
socket:set_local_port(67)
connect(host, 68, 'udp')


I like this.  But I think the setting of the source address should be
supported.  I wrote the Nsock support for setting the local addr info and made
NSE (and DNS and version detection) work with -S.  Since NSE uses a user-set
address, it should allow scripts to set it as well.

Forgive my lack of recollection on Lua, but here's what I first thought of:

socket:bind({addr = "1.2.3.4", port = 31337})

Short, sweet and makes sense with connect().  Of course either field is optional.

But of course objections could come from the fact that connect() doesn't work
this way... but it should ;)

David Fifield


Cheers,
Kris Katterjohn

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

iQIcBAEBAgAGBQJKxCyiAAoJEEQxgFs5kUfulAsQALXzJE0BDUb8ULebXO6d0BS+
eaT1HSL0gRQdhmcMHXTkZrKH18tlajqbRi2zZ/mlOlVo8/t4UoP1V8NaTsfibXr4
xKIlNbAdmhb8MOj74Xp+6Y/niaANeM4e4/SFdLgKMGWZ+IOcmulGVt2Y+JZgn5r7
l10fr7wMRL/gc0Ydbsc/zS161YdbTaPDLlYwQB/q4/CD3YbJQFi5Zv/s+wn1GQSE
F2gxTl40/7xKOvpMbD64A8P49kWcoghy1A+TVka3UiNObynDOJuMB3cJZn685LPp
ccr4hwQ7+gwSvIlCfqZrkwxd64/xPNPguQn7iJ57cC1jz6Fv/BWWvVr8OgfiQxlO
2GwgZfRBdChKqVz+cs4hYBD7BmYXdBdoa5G/nn8uGuWxqb8GkZfoXp1fO+fF9eU1
5vPeNxFJ0bXxFxGJX+qtL9PH/psPyucN7gsR5I84Te5848TG66w0oSkO//VPcYDZ
rDRoQQXsvYPsYYXCn5DsuKp6wibGyH/Dkp/NgKRupiSwGkbkyLFO8HNvo1UubzkQ
u6wFaAhAB5jd79DaYiHUoNHcAsoziXFoJY7AZL27mr8aTjESl1dVZQfvPjPwcyJB
tGV/1DoIfhvwS/QP/n2WJ1B9CWCVn6wFNHaorcbu9D26WYrkHP2t/yk9rhGi0Zr7
33PodMcjNjD+V/ZAZuW2
=GehQ
-----END PGP SIGNATURE-----

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


Current thread: