Parse::Nessus::Plugin - OO methods to parse Nessus plugins
use Parse::Nessus::Plugin; $plugin = Parse::Nessus::Plugin->new || undef; if(!$plugin) { die("It wasn't posible to initialize parser"); } $plugin->parse_file($nasl_file); # Parse from a filename $plugin->parse_string($nasl_string); # Parse from a string $plugin->description; # Get description $plugin->solution; # Get solution
Parse::Nessus::Plugin provides OO methods that easily parse Nessus plugins written in NASL. With this module you can get the script id, solution, description, risk factor and many other information in your NASL plugin with a simple call to an OO method.
Usage :
my $plugin = Parse::Nessus::Plugin->new;
This method returns an instance of the Parse::Nessus::Plugin class.
$plugin->parse_file($nasl_filename);
This method tells Parse::Nessus::Plugin to be ready to parse $nasl_filename, where $nasl_filename is the path to the .nasl plugin (for example /usr/nessus/cifs445.nasl). If this method returns true, then you can continue with the parsing, otherwise, the argument given wasn't a valid .nasl plugin.
$plugin->parse_string($nasl_string);
This method tells Parse::Nessus::Plugin to be ready to parse $nasl_string, where $nasl_string is a SCALAR variable that contains the code of a Nessus plugin written in NASL. If this method returns true, then you can continue with the parsing, otherwise, the string given as argument isn't a valid .nasl plugin.
my $id = $plugin->id;
This method returns the plugin id of the last plugin processed with parse_file or parse_string, as SCALAR variable.
my $filename = $plugin->filename;
This method returns the name of the plugin's file (only if you used parse_file method).
my @cve = $plugin->cve;
This method returns the list of CVE names associated with the current plugin.
my @bugtraq = $plugin->bugtraq;
This method returns the list of bugtraq ids associated with the current plugin.
my $version = $plugin->version;
This method returns the version of the current plugin.
my $name = $plugin->name;
This method returns the name of the current plugin.
my $summary = $plugin->summary;
This method returns the summary of the current plugin.
my $description = $plugin->description;
This method returns the description of the current plugin. Attention: JUST the description. Other data as solution, risk factor, etc. can be reached via their own methods.
my $solution = $plugin->solution;
This method returns the solution of the current plugin.
my $risk = $plugin->risk;
This method returns the risk factor of the current plugin.
my $family = $plugin->family;
This method returns the family of the current plugin.
my $category = $plugin->category;
This method returns the category of the current plugin.
my $copyright = $plugin->copyright;
This method returns the copyright of the current plugin.
my $is_fs = $plugin->register_service;
This method returns True if the plugin registers a service or False if it doesn't
Usage:
my $proto = $plugin->register_service_proto;
This method return the 'proto' argument of a call to the register_service function
my $error = $plugin->error;
This method returns the last error happened during the parsing of the current plugin.
List of errors:
NO_FILE: The filename gived to parse_file method doesn't exist or it's empty. NO_NESSUS_PLUGIN: The string gived to parse_string method isn't a valid NASL plugin. NO_CVE: The current plugin hasn't an associated a CVE names list. NO_BUGTRAQID: The current plugin hasn't associated a BUGTRAQIDs list. NO_NAME: The current plugin hasn't a script_name field. NO_SUMMARY: The current plugin hasn't a script_summary field. NO_DESCRIPTION: The current plugin hasn't a script_description field. NO_SOLUTION: The current plugin hasn't a solution field inside the script_description field. NO_RISK: The current plugin hasn't a risk factor field inside the script_description field. NO_FAMILY: The current plugin hasn't a script_family field. NO_CATEGORY: The current plugin hasn't a script_category field. NO_COPYRIGHT: The current plugin hasn't a script_copyright field. NO_REGISTER_SERVICE: The current plugin doesn't execute the register_service function NO_REGISTER_SERVICE_PROTO: The current plugin does execute the register_service function but it doesn't specify a proto
# This example takes a .nasl file and prints its file name, plugin id, name and CVE list use Parse::Nessus::Plugin; my $plugin = Parse::Nessus::Plugin->new; if($plugin->error) { die ("There were an error. Reason: ".$plugin->error); } if(!$plugin->parse_file('/path/to/plugin.nasl') { die ("There were an error. Reason: ".$plugin->error); } print "FILENAME:".$plugin->filename."\n"; print "PLUGIN ID:".$plugin->id."\n"; print "NAME:".$plugin->name."\n"; my $cve = $plugin->cve; if($cve) { print " CVE:\n"; foreach my $cve (@{$cve}) { print " $cve\n"; } }
Check the examples directory to see more examples.
There aren't reported bugs yet, but that doesn't mean that it's free of them :)
Roberto Alamos Moreno <ralamosm@cpan.org>
Copyright (c) 2005-2007 Roberto Alamos Moreno. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
=back doesn't take any parameters, but you said =back 4
To install Parse::Nessus::Plugin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Parse::Nessus::Plugin
CPAN shell
perl -MCPAN -e shell install Parse::Nessus::Plugin
For more information on module installation, please visit the detailed CPAN module installation guide.