Net-Nessus

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


      require Net::Nessus::Client;
      my $client = Net::Nessus::Client->new('host' => 'gate.company.com',
                                            'port' => 2367,
                                            'user' => 'joe',
                                            'password' => 'what_password',
                                            'ntp_proto' => '1.0');

  Reading the plugin list
      my $plugins = $self->Plugins();
      my $prefs = $self->Prefs();
      my $rules = $self->Rules();

    (Instance Methods) Read the plugin list, the current preferences or the
    list of rules. The plugin list is an array of hash refs, each hash ref
    with attributes *id*, *category* and so on. The prefs are a single hash
    ref of name/value pairs and the rules are an array ref of strings.

    When talking to an NTP/1.0 server, the Prefs() and Rules() methods will
    return undef.

    Examples:

      my $plugins = $self->Plugins();
      print("The first plugins ID is ", $plugins->[0]->{'id'}, "\n");
      print("The second plugins description is ",
            $plugins->[1]->{'description'}, "\n");
      my $prefs = $self->Prefs();
      print "\nThe current prefs are:\n";
      while (my($var, $val) = each %$prefs) {
        print "  $var = $val\n";
      }
      my $rules = $self->Rules();
      print "\nThe current rules are:\n";
      foreach my $rule (@$rules) {
        print "  $rule\n";
      }

  Sending a message to the server
      $client->Print($msg);

lib/Net/Nessus/Client.pm  view on Meta::CPAN

    die "Protocol $proto not supported: $line"
	unless ($line =~ /\<\s+NTP\/$proto\s+\>/);
    $sock->waitfor('Match' => '/[Uu]ser\s+:\s*/');
    $sock->print($user);
    $sock->waitfor('Match' => '/[Pp]assword\s+:\s*/');
    $sock->print($pass);
    my $self = \%attr;
    bless($self, (ref($class) or $class));
    $self->{'plugins'} = $self->GetMsg('PLUGIN_LIST');
    if ($proto >= 1.1) {
	$self->{'prefs'} = $self->GetMsg('PREFERENCES');
	$self->{'rules'} = $self->GetMsg('RULES');
    }
    $self;
}


=pod

=head2 Reading the plugin list

  my $plugins = $self->Plugins();
  my $prefs = $self->Prefs();
  my $rules = $self->Rules();

(Instance Methods) Read the plugin list, the current preferences or the
list of rules. The plugin list is an array of hash refs, each hash ref
with attributes I<id>, I<category> and so on. The prefs are a single
hash ref of name/value pairs and the rules are an array ref of strings.

When talking to an NTP/1.0 server, the Prefs() and Rules() methods
will return undef.

Examples:

  my $plugins = $self->Plugins();
  print("The first plugins ID is ", $plugins->[0]->{'id'}, "\n");
  print("The second plugins description is ",
        $plugins->[1]->{'description'}, "\n");
  my $prefs = $self->Prefs();
  print "\nThe current prefs are:\n";
  while (my($var, $val) = each %$prefs) {
    print "  $var = $val\n";
  }
  my $rules = $self->Rules();
  print "\nThe current rules are:\n";
  foreach my $rule (@$rules) {
    print "  $rule\n";
  }

=cut

sub Plugins { shift->{'plugins'}->Plugins() }
sub Prefs { my $prefs = shift->{'prefs'}; $prefs ? $prefs->Prefs() : undef }
sub Rules { my $rules = shift->{'rules'}; $rules ? $rules->Rules() : undef }


=pod

=head2 Sending a message to the server

  $client->Print($msg);

(Instance Method) The print method is used for sending a previously

lib/Net/Nessus/Message.pm  view on Meta::CPAN



package Net::Nessus::Message::PREFERENCES;

@Net::Nessus::Message::PREFERENCES::ISA = qw(Net::Nessus::Message::MultiLine);

sub new {
    my $proto = shift;
    my $self = $proto->SUPER::new(@_);
    if (@_ == 1) {
	$self->{'prefs'} = delete $self->{'lines'};
    } else {
	my %prefs;
	my $lines = $self->{'lines'};
	for (my $i = 0;  $i < @$lines; $i++) {
	    my $line = $lines->[$i];
	    $prefs{$line->[0]} = $line->[1];
	}
	$self->{'prefs'} = \%prefs;
    }
    $self
}
sub print {
    my $self = shift;
    my $lines = [];
    while (my($var, $val) = each %{$self->{'prefs'}}) {
	push(@$lines, "$var <|> $val");
    }
    $self->SUPER::print(@_, $lines);
}
sub Prefs { shift->{'prefs'} }


package Net::Nessus::Message::PREFERENCES_ERRORS;

@Net::Nessus::Message::PREFERENCES_ERRORS::ISA =
    qw(Net::Nessus::Message::PREFERENCES);

=pod

=head3 RULES

nessusc.PL  view on Meta::CPAN

############################################################################

sub Usage {
    print <<USAGE;
$0 <action> --user=user --password=password [options]

Possible actions are:

  --target=<targethost>  Launch an attack against <targethost>.
  --plugins		 List the Nessus servers plugin list.
  --prefs		 List the Nessus servers preference list.
  --rules		 List the Nessus servers rules.

Possible options are:

  --host=<host>		 At startup the program connects to the Nessus server
  --port=<port>		 running at the machine <host>, port <port> as user
  --user=<user>          <user> with password <password>. The default host
  --password=<password>	 is localhost, port 1241, no defaults for user and
			 password are set, you must supply these values.
  --proto=<proto>	 Use NTP version <proto>; by default version 1.1

nessusc.PL  view on Meta::CPAN

package main;

{
    my $o = {
	'host' => '127.0.0.1',
	'port' => 1241,
        'proto' => '1.1',
        'help' => \&Usage
    };
    Getopt::Long::GetOptions($o, 'host=s', 'port=s', 'proto=s', 'user=s',
			     'password=s', 'target=s', 'plugins', 'prefs',
                             'rules', 'verbose', 'help');

    Usage() unless (defined($o->{'user'}) and defined($o->{'password'}));

    my $client = eval {
        Net::Nessus::NessusC->new($o,
				  'host' => $o->{'host'},
                                  'port' => $o->{'port'},
                                  'user' => $o->{'user'},
                                  'password' => $o->{'password'},

nessusc.PL  view on Meta::CPAN

		my $prefix = $ref->[0];
		foreach my $line (split(/;/, $plugin->{$ref->[1]})) {
		    print "$prefix$line\n";
		    $prefix = '     ';
		}
	    }
	    print "\n";
	}
	$done = 1;
    }
    if ($o->{'prefs'}) {
	print "\nPreference list:\n\n";
	while (my($var, $val) = each %{$client->Prefs()}) {
	    print "  $var = $val\n";
        }
	$done = 1;
    }
    if ($o->{'rules'}) {
        print "\nRule list:\n\n";
        foreach my $rule (@{$client->Rules()}) {
	    print "  $rule\n";

nessusc.PL  view on Meta::CPAN

    nessusc --target=thost --user=user --password=password
        [ --host=nhost --port=port --proto=1.1 ]

  Print the plugin list:

    nessusc --plugins --user=user --password=password
        [ --host=nhost --port=port --proto=1.1 ]

  Print the nessus servers preferences:

    nessusc --prefs --user=user --password=password
        [ --host=nhost --port=port --proto=1.1 ]

  Print the nessus servers rules:

    nessusc --rules --user=user --password=password
        [ --host=nhost --port=port --proto=1.1 ]


=head1 DESCRIPTON

nessusc.PL  view on Meta::CPAN

I<nhost> as I<user> with the given I<password>. The I<host> option defaults
to F<localhost>, no defaults are set for the other options: You must set
these.

Do not mismatch the I<host> option with I<target>!

=item --plugins

Print the plugin list.

=item --prefs

Print the list of preferences.

=item --rules

Print the list of rules.

=item --target <thost>

Launch an attack against the host F<thost>.



( run in 0.589 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )