On Tue, Mar 22, 2005 at 04:06:15PM -0500, Lei Li wrote:
> Hi,
> get_kb_item() and get_kb_list can be used to retrieve the value of KB
> items. But how to get both the KB item name and value? What I want to do is
> writing a nasl to query the KB and get a list of all the open ports. I use
> get_kb_list("Ports/*")
> But only the value of the kb items are returned, i.e. I only got a list of
> '1's. Alternatively, I can write a for loop to query every port, but is
> there a more efficient way to do this?
The ports are stored as Ports/<proto>/<number> = TRUE.
So you want to do :
ports = get_kb_list("Ports/tcp/*");
foreach port ( keys(ports) )
{
# Remove the string "Ports/tcp/" and convert the remaining
# part to an int
port = int(port - "Ports/tcp/");
do_stuff(port:port);
}
-- Renaud
_______________________________________________
Plugins-writers mailing list
Plugins-writers@private
http://mail.nessus.org/mailman/listinfo/plugins-writers
This archive was generated by hypermail 2.1.3 : Wed Mar 23 2005 - 05:58:15 PST