Nmap Development mailing list archives

Re: Lua bugfixes and a new buffering feature


From: Fyodor <fyodor () insecure org>
Date: Wed, 4 Jul 2007 01:04:57 -0700

On Mon, Jul 02, 2007 at 09:36:05PM +0200, Stoiko Ivanov wrote:

I am caching the compiled PCRE regexps into the NSE registry using
a fairly straightfoward scheme:

Great! - I'll make sure to update the docs on pcre

Hi Stoiko.  Updating docs is wonderful, particularly with all the
changes NSE has been going through.  But I'm not 100% sold on the idea
of caching compiled regular expressions in the NSE registry as a
general rule.  Before we recommend that, I'd love to see some
empirical data that it makes a material performance difference.

Perhaps it would be useful to look for an init function which is called
only once per script per nmap invocation and only right before action()
is called? Another solution we should consider is passing a table to the
action function that scripts can use for cross-invocation persistent data

Actually variables defined (either as local or not) outside of functions in
a nse-script keep their value during multiple invocations of the script. 
So if you define an empty table right before the action function and fill
it during the first run of the action, the data saved in it will be
still there during the next invocation(s).

That is great to know!  Is this in the docs?  Maybe this would be a
better way to store variables such as compiled PCREs.

IMPORTANT NOTE FOR NSE SCRIPT WRITERS: Don't use the function
receive_lines() unless you plan on doing your own line parsing.
This function WILL RETURN MORE THAN JUST THE FIRST LINE OF DATA
IF MORE IS AVAILABLE.

I'll take a look at it - maybe there is an easy way to replace
receive_lines with your buffer-approach, which seems more flexible anyway.

That could be.  It might even be best to add the feature to nsock
itself.  Or maybe you'll find it more convenient/performant to add it
at another layer.

Cheers,
-F

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


Current thread: