Discussion:
nasl command line execution
Russell Fulton
2004-05-03 07:55:05 UTC
Permalink
Hi All,
I have been looking at using some plugins (currently smb_kb835732.nasl)
from the command line nasl tool. I want to do this rather than use the
server for a variety of reasons mainly to do with the fact that I am
generating the addresses to be probed from inside other applications and
I want to be able to do the probes from within those apps. The
alternative is to get the verbose results and then have to parse them
back into the app. All I need to do is run a single plugin and get a
yes/no answer.

So far as I can see nasl prints "Success" if the script finds a
vulnerability. What I would find much more useful would be if the
program return a non zero exit code so I can catch it in the wait().

I've looked at the source and I am having trouble figuring out where the
'Success' code is generated -- so far as I can tell it is in the guts of
the regex code -- but that does not seem likely.

Any hints on how to set the exit code for nasl would be appreciated.

As an alternative I would like to get it to print the probed IP along
with the 'Success'.

I am more than happy to contribute any changes I make back to the
project.

Cheers, Russell
--
Russell Fulton /~\ The ASCII
Network Security Officer \ / Ribbon Campaign
The University of Auckland X Against HTML
New Zealand / \ Email!
George Theall
2004-05-05 19:44:28 UTC
Permalink
Post by Russell Fulton
I have been looking at using some plugins (currently smb_kb835732.nasl)
from the command line nasl tool.
A potential problem with this approach in general is that the
commandline nasl tool can't read KBs at present. Many plugins need to
be able to do so to run properly.
Post by Russell Fulton
Any hints on how to set the exit code for nasl would be appreciated.
I took at look at the source and developed some patches (see attached)
that *seem* to do this. This seems like a useful feature and would be
nice if Renaud / Michel (1) find that they work correctly and (2) choose
to integrate them into the source.

They modify libnasl/exec.c to use the return code from the script itself
when executing a NASL script as well as libnasl/nasl.c to keep track of
the return code from running each NASL script and to exit with the most
recent.

Use at your own risk. Note that I haven't done anything more than use
them to modify the standalone NASL interpreter and verify that I can set
the return code with a simple NASL plugin.

George
--
***@tifaware.com
Pavel Kankovsky
2004-05-05 20:31:05 UTC
Permalink
Post by George Theall
A potential problem with this approach in general is that the
commandline nasl tool can't read KBs at present. Many plugins need to
be able to do so to run properly.
I made a patch for this and sent it to nessus-devel.
See http://list.nessus.org/nessus-devel/0403/0998.html
and http://list.nessus.org/nessus-devel/0403/1000.html

Unfortunately, there was no feedback.

--Pavel Kankovsky aka Peak [ Boycott Microsoft--http://www.vcnet.com/bms ]
"Resistance is futile. Open your source code and prepare for assimilation."
Loading...