Home page logo
/

nmap-dev logo Nmap Development mailing list archives

RE: Question on NSE script output
From: "Sina Bahram" <sbahram () nc rr com>
Date: Sat, 6 Jun 2009 00:59:58 -0400

Must have done it wrong then.

And I misspoke, I'm sorry.  I received an error message with the print (when
I was just playing around in lua on the cli), as you cleared up for me ...
What happened when I made the modification was I started receiving nothing
at all for the output.

I probably in some way concatted with null?

Been a long day, sorry again for messing that up.

I'll try it again tomorrow, and send stuff to you.

Take care,
Sina

-----Original Message-----
From: nmap-dev-bounces () insecure org [mailto:nmap-dev-bounces () insecure org]
On Behalf Of David Fifield
Sent: Saturday, June 06, 2009 12:37 AM
To: Sina Bahram
Cc: 'nmap-dev'
Subject: Re: Question on NSE script output

On Sat, Jun 06, 2009 at 12:03:35AM -0400, Sina Bahram wrote:
Unless if I did it wrong, you can't actually do this:

                return host.ip .. " Anonymous FTP login allowed"
 
Let me preface with, I'm a programmer, but not a LUA one.

Here's what I've discovered.

If you are printing something, then unless if you have parentheses around
it, you can't inline concat a string.  Even if you assign it to a local
variable first, then pass the variable to the print.  Probably because it
does expansion at that point, just like lisp or something.

That is a separate issue. print is a function, not a keyword like
return. Function calls normally require parentheses around the
arguments. The exception to this rule is if there is only one argument,
and it is a literal string or a table constructor. So you can do
        print(x)
        print "Hello"
But not
        print x
        print "Hello" .. " world"
See http://www.lua.org/manual/5.1/manual.html#2.5.8

Since we're returning a string, not printing it ... I'm not sure if the
print that eventually gets called has parentheses around it; thus, when I
tried to do the line of code above, almost exactly what you wrote as your
suggestion in your email, I got the same error as if I had done a print
with
a string being concatted without parentheses around it.

Does this make sense?

No, expression is evaluated and converted to a string before the return.
Whatever error message you see must be cause by something else.

I don't know why the line of code above doesn't work for you. I copied
it directly from the script after testing the modification. Can you copy
in the error message you see? A return statement must be the last thing
in a block, so if you moved the return, it may not work.

David Fifield

_______________________________________________
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


  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]
AlienVault