Nmap Development mailing list archives

Re: Some hints for nmap scripts


From: jah <jah () zadkiel plus com>
Date: Tue, 02 Dec 2008 18:51:37 +0000

On 02/12/2008 17:44, Patrick Donnelly wrote:
On Tue, Dec 2, 2008 at 9:00 AM, jah <jah () zadkiel plus com> wrote:
  
On 02/12/2008 15:41, Patrick Donnelly wrote:
    
On Tue, Dec 2, 2008 at 7:49 AM, jah <jah () zadkiel plus com> wrote:

      
The only script currently using this stuff is one named promiscuous.nse
in Nmap versions up to 4.76 (now named sniffer-detect.nse) (as an aside,
this script has a commented-out section between --[[ and ]]-- which is
not the correct way [3] - it should be --[[ and --]], but for some
reason the script still works as expected and considers the improperly
commented section as a properly commented section - v. odd.)

        
This is actually a "trick" Roberto mentions in his book, PiL, in [1].
The comments in sniffer-detect.nse are correct.

[1] http://www.lua.org/pil/1.3.html
      
I think the trick you refer to is to uncomment a previously commented
block by adding a third hyphen ---[[ --]]
    

This is correct. I misread your earlier post taking to mean that --[[
]] commenting should be --[[ --]]. The --[[ ]]-- works because the
final two hyphens are interpreted as a single line comment (which of
course is empty as there is nothing between the hyphens and the
newline).
I expected that improperly closing a multiline comment in this way would
mean that the comment would extend to the end of the file, but it
clearly doesn't.
]] is all that's required to close such a comment.

It all starts to get rather messy if a commented block happens to
contain a multiline string  foo=[[  ]]  which results in a script
compilation error: nesting of [[...]] is deprecated near '['

Not a big deal of course, but worth noting.

jah

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


Current thread: