| 1 | |||
| 2 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | 3 | ▶ | use Class::Generate qw(class); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 3 | class 'Nmap::Scanner::OS' => { | |
| 7 | qw(ports_used @Nmap::Scanner::OS::PortUsed | ||
| 8 | osmatches @Nmap::Scanner::OS::Match | ||
| 9 | osclasses @Nmap::Scanner::OS::Class | ||
| 10 | osfingerprint Nmap::Scanner::OS::Fingerprint | ||
| 11 | uptime Nmap::Scanner::OS::Uptime | ||
| 12 | tcpsequence Nmap::Scanner::OS::TCPSequence | ||
| 13 | tcptssequence Nmap::Scanner::OS::TCPTSSequence | ||
| 14 | ipidsequence Nmap::Scanner::OS::IPIdSequence), | ||
| 15 | '&add_port_used' => q!push(@{$self->{'ports_used'}}, $_[0]);!, | ||
| 16 | '&add_os_match' => q!push(@{$self->{'osmatches'}}, $_[0]);!, | ||
| 17 | '&add_os_class' => q!push(@{$self->{'osclasses'}}, $_[0]);!, | ||
| 18 | '&as_xml' => q! | ||
| 19 | |||
| 20 | # No fingerprinting happened if no ports found to fingerprint with. | ||
| 21 | return unless scalar($self->ports_used()) > 0; | ||
| 22 | |||
| 23 | my $xml = "<os>\n"; | ||
| 24 | |||
| 25 | for my $port ($self->ports_used()) { | ||
| 26 | $xml .= $port->as_xml() . "\n"; | ||
| 27 | } | ||
| 28 | |||
| 29 | for my $c ($self->osclasses()) { | ||
| 30 | $xml .= $c->as_xml() . "\n"; | ||
| 31 | } | ||
| 32 | |||
| 33 | for my $m ($self->osmatches()) { | ||
| 34 | $xml .= $m->as_xml() . "\n"; | ||
| 35 | } | ||
| 36 | |||
| 37 | $xml .= "</os>\n"; | ||
| 38 | |||
| 39 | $xml .= join("\n", | ||
| 40 | ($self->{'uptime'} ? $self->{'uptime'}->as_xml() : ''), | ||
| 41 | ($self->{'osfingerprint'} ? $self->{'osfingerprint'}->as_xml() : ''), | ||
| 42 | ($self->{'tcpsequence'} ? $self->{'tcpsequence'}->as_xml() : ''), | ||
| 43 | ($self->{'tcptssequence'} ? $self->{'tcptssequence'}->as_xml() : ''), | ||
| 44 | ($self->{'ipidsequence'} ? $self->{'ipidsequence'}->as_xml() : '')); | ||
| 45 | |||
| 46 | return $xml; | ||
| 47 | |||
| 48 | ! | ||
| 49 | }; | ||
| 50 | |||
| 51 | =pod | ||
| 52 | |||
| 53 | =head1 DESCRIPTION | ||
| 54 | |||
| 55 | This class represents an nmap OS deduction as output by nmap. It is | ||
| 56 | generally returned as part of a host object, and only so if guess_os() | ||
| 57 | is used as an option with the Nmap::Scanner::Scanner instance. | ||
| 58 | |||
| 59 | =head1 PROPERTIES | ||
| 60 | |||
| 61 | =head2 ports_used() | ||
| 62 | |||
| 63 | The open ports used to try and fingerprint the remote OS. | ||
| 64 | |||
| 65 | =head2 add_port_used() | ||
| 66 | |||
| 67 | Add a port to the list of ports used to try and fingerprint the remote hosts' OS. | ||
| 68 | |||
| 69 | =head2 osmatches() | ||
| 70 | |||
| 71 | Object representing nmaps' best attempt to fingerprint the remote OS. | ||
| 72 | |||
| 73 | =head2 uptime | ||
| 74 | |||
| 75 | Object representing uptime/last reboot time for this host. | ||
| 76 | This MAY be available if guess_os() is called on the | ||
| 77 | Nmap::Scanner::Scanner reference. Not available for all hosts. | ||
| 78 | |||
| 79 | =cut | ||