| 1 | # | ||
| 2 | # | ||
| 3 | # | ||
| 4 | |||
| 5 | package NessusParser::Host; | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | use base "NessusParser"; | ||
| 11 | |||
| 12 | my @ISA = "NessusParser"; | ||
| 13 | |||
| 14 | use vars qw($AUTOLOAD); | ||
| 15 | |||
| 16 | ## passed | ||
| 17 | sub new { | ||
| 18 | my $pkg = shift; | ||
| 19 | my $self = bless {}, $pkg; | ||
| 20 | $self->initialize(@_); | ||
| 21 | return $self; | ||
| 22 | } | ||
| 23 | |||
| 24 | # passed | ||
| 25 | sub initialize { | ||
| 26 | my $self = shift; | ||
| 27 | $self->SUPER::initialize(shift, shift); | ||
| 28 | $self->{HOST} = shift; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub get_ip { | ||
| 32 | my ($self,$ip) = shift; | ||
| 33 | my $returnValue = "-1"; | ||
| 34 | if ( $ip eq $self->{stem}{HostProperties}{'host-ip'}) { | ||
| 35 | if ( defined($self->{stem}{HostProperties}{'host-ip'})) { | ||
| 36 | $returnValue = $self->{stem}{HostProperties}{'host-ip'}; | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | return $returnValue; | ||
| 41 | } | ||
| 42 | |||
| 43 | sub get_credentialed { | ||
| 44 | my ($self,$ip) = shift; | ||
| 45 | my $returnValue = "-1"; | ||
| 46 | if ( $ip eq $self->{stem}{HostProperties}{'host-ip'}) { | ||
| 47 | if ( defined($self->{stem}{HostProperties}{'Credentialed_Scan'})) { | ||
| 48 | $returnValue = $self->{stem}{HostProperties}{'Credentialed_Scan'}; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | return $returnValue; | ||
| 54 | } | ||
| 55 | |||
| 56 | sub get_policy { | ||
| 57 | my ($self,$ip) = shift; | ||
| 58 | my $returnValue = "-1"; | ||
| 59 | if ( $ip eq $self->{stem}{HostProperties}{'host-ip'}) { | ||
| 60 | if ( defined($self->{stem}{HostProperties}{'policy-used'})) { | ||
| 61 | $returnValue = $self->{stem}{HostProperties}{'policy-used'}; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | return $returnValue; | ||
| 66 | } | ||
| 67 | |||
| 68 | sub get_HostStart { | ||
| 69 | my ($self) = shift; | ||
| 70 | my $returnValue = "-1"; | ||
| 71 | |||
| 72 | if ( defined($self->{stem}{'HostProperties'}{'HOST_START'})) { | ||
| 73 | $returnValue = $self->{stem}{'HOST_START'}; | ||
| 74 | } | ||
| 75 | |||
| 76 | return $returnValue; | ||
| 77 | } | ||
| 78 | |||
| 79 | sub get_HostEnd { | ||
| 80 | my ($self,$ip) = shift; | ||
| 81 | my $returnValue = "-1"; | ||
| 82 | if ( $ip eq $self->{stem}{HostProperties}{'host-ip'}) { | ||
| 83 | if ( defined($self->{stem}{'HostProperties'}{'HOST_END'})) { | ||
| 84 | $returnValue = $self->{stem}{HostProperties}{'HOST_END'}; | ||
| 85 | } | ||
| 86 | } | ||
| 87 | |||
| 88 | return $returnValue; | ||
| 89 | } | ||
| 90 | |||
| 91 | sub get_lastAuthScan { | ||
| 92 | my ($self,$ip) = shift; | ||
| 93 | my $returnValue = "-1"; | ||
| 94 | if ( $ip eq $self->{stem}{HostProperties}{'host-ip'}) { | ||
| 95 | if ( defined($self->{stem}{'HostProperties'}{LastUnauthenticatedResults})) { | ||
| 96 | $returnValue = $self->{stem}{HostProperties}{LastUnauthenticatedResults}; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | return $returnValue; | ||
| 100 | } | ||
| 101 | |||
| 102 | |||
| 103 | #hostname | ||
| 104 | #Credentialed_Scan | ||
| 105 | #policy-used | ||
| 106 | #patch-summary-total-cves | ||
| 107 | #os | ||
| 108 | #host-fqdn | ||
| 109 | #smb-login-used | ||
| 110 | #local-checks-proto | ||
| 111 | #netbios-name | ||
| 112 | #system-type | ||
| 113 | #operating-system | ||
| 114 | #mac-address | ||
| 115 | #mcafee-epo-guid | ||
| 116 | #bios-uuid | ||
| 117 | # | ||
| 118 | # | ||
| 119 | #traceroute-hop-0 | ||
| 120 | |||
| 121 | |||
| 122 | sub get_cpe { | ||
| 123 | |||
| 124 | |||
| 125 | |||
| 126 | } | ||
| 127 | #<tag name="cpe-8">cpe:/a:oracle:jre:1.8.0:update51</tag> | ||
| 128 | #<tag name="cpe-7">cpe:/a:mozilla:firefox:39.0.0</tag> | ||
| 129 | #<tag name="cpe-6">cpe:/a:microsoft:ie:11.0.9600.17914</tag> | ||
| 130 | #<tag name="cpe-5">cpe:/a:adobe:flash_player:18.0.0.209</tag> | ||
| 131 | #<tag name="cpe-4">cpe:/a:adobe:flash_player:18.0.0.209</tag> | ||
| 132 | #<tag name="cpe-3">cpe:/a:adobe:acrobat:11.0.12</tag> | ||
| 133 | #<tag name="cpe-2">cpe:/a:adobe:acrobat_reader:11.0.12</tag> | ||
| 134 | #<tag name="cpe-1">cpe:/a:wireshark:wireshark:1.12.6</tag> | ||
| 135 | #<tag name="cpe-0">cpe:/o:microsoft:windows_7::sp1:x64-enterprise</tag> | ||
| 136 | #<tag name="cpe">cpe:/o:microsoft:windows</tag> | ||
| 137 | # | ||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | |||
| 142 | |||
| 143 | sub get_plugins { | ||
| 144 | |||
| 145 | my ($self,$ip) = @_; | ||
| 146 | my @PLUGINS; | ||
| 147 | if ( $ip eq $self->{stem}{HostProperties}{'host-ip'}) { | ||
| 148 | if ( defined($self->{stem}{ReportItems}) ) { | ||
| 149 | if ( ref($self->{stem}{ReportItems}) eq "ARRAY" ) { | ||
| 150 | for my $plugin ( @{$self->{stem}{ReportItems}} ) { | ||
| 151 | my $PLUGIN = NessusParser::Host::Plugins->new($plugin); | ||
| 152 | push(@PLUGINS, $PLUGIN) | ||
| 153 | } | ||
| 154 | } elsif ( ref($self->{stem}{ReportItems}) eq "HASH" ) { | ||
| 155 | my $PLUGIN = NessusParser::Host::Plugins->new($self->{stem}{ReportItems}); | ||
| 156 | push(@PLUGINS, $PLUGIN) | ||
| 157 | } else { die "ack!!!\n"; } | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | return @PLUGINS; | ||
| 162 | } | ||
| 163 | sub get_hostname { | ||
| 164 | my ($self,$name) = shift; | ||
| 165 | my $returnValue = -1; | ||
| 166 | if ( defined($self->{stem}{'HostProperties'}{'hostname'})) { | ||
| 167 | $returnValue = $self->{stem}{HostProperties}{'hostname'}; | ||
| 168 | } | ||
| 169 | return $returnValue; | ||
| 170 | } | ||
| 171 | |||
| 172 | sub get_Credentialed_Scan { | ||
| 173 | my ($self,$name) = shift; | ||
| 174 | my $returnValue = -1; | ||
| 175 | if ( defined($self->{stem}{'HostProperties'}{'Credentialed_Scan'})) { | ||
| 176 | $returnValue = $self->{stem}{HostProperties}{'Credentialed_Scan'}; | ||
| 177 | } | ||
| 178 | return $returnValue; | ||
| 179 | } | ||
| 180 | |||
| 181 | sub get_policy_used { | ||
| 182 | my ($self,$name) = shift; | ||
| 183 | my $returnValue = -1; | ||
| 184 | if ( defined($self->{stem}{'HostProperties'}{'policy-used'})) { | ||
| 185 | $returnValue = $self->{stem}{HostProperties}{'policy-used'}; | ||
| 186 | } | ||
| 187 | return $returnValue; | ||
| 188 | } | ||
| 189 | |||
| 190 | sub get_patch_summary_total_cves { | ||
| 191 | my ($self,$name) = shift; | ||
| 192 | my $returnValue = -1; | ||
| 193 | if ( defined($self->{stem}{'HostProperties'}{'patch-summary-total-cves'})) { | ||
| 194 | $returnValue = $self->{stem}{HostProperties}{'patch-summary-total-cves'}; | ||
| 195 | } | ||
| 196 | return $returnValue; | ||
| 197 | } | ||
| 198 | |||
| 199 | sub get_os { | ||
| 200 | my ($self,$name) = shift; | ||
| 201 | my $returnValue = -1; | ||
| 202 | if ( defined($self->{stem}{'HostProperties'}{'os'})) { | ||
| 203 | $returnValue = $self->{stem}{HostProperties}{'os'}; | ||
| 204 | } | ||
| 205 | return $returnValue; | ||
| 206 | } | ||
| 207 | |||
| 208 | sub get_host_fqdn { | ||
| 209 | my ($self,$name) = shift; | ||
| 210 | my $returnValue = -1; | ||
| 211 | if ( defined($self->{stem}{'HostProperties'}{'host-fqdn'})) { | ||
| 212 | $returnValue = $self->{stem}{HostProperties}{'host-fqdn'}; | ||
| 213 | } | ||
| 214 | return $returnValue; | ||
| 215 | } | ||
| 216 | |||
| 217 | sub get_smb_login_used { | ||
| 218 | my ($self,$name) = shift; | ||
| 219 | my $returnValue = -1; | ||
| 220 | if ( defined($self->{stem}{'HostProperties'}{'smb-login-used'})) { | ||
| 221 | $returnValue = $self->{stem}{HostProperties}{'smb-login-used'}; | ||
| 222 | } | ||
| 223 | return $returnValue; | ||
| 224 | } | ||
| 225 | |||
| 226 | sub get_local_checks_proto { | ||
| 227 | my ($self,$name) = shift; | ||
| 228 | my $returnValue = -1; | ||
| 229 | if ( defined($self->{stem}{'HostProperties'}{'local-checks-proto'})) { | ||
| 230 | $returnValue = $self->{stem}{HostProperties}{'local-checks-proto'}; | ||
| 231 | } | ||
| 232 | return $returnValue; | ||
| 233 | } | ||
| 234 | |||
| 235 | sub get_netbios_name { | ||
| 236 | my ($self,$name) = shift; | ||
| 237 | my $returnValue = -1; | ||
| 238 | if ( defined($self->{stem}{'HostProperties'}{'netbios-name'})) { | ||
| 239 | $returnValue = $self->{stem}{HostProperties}{'netbios-name'}; | ||
| 240 | } | ||
| 241 | return $returnValue; | ||
| 242 | } | ||
| 243 | |||
| 244 | sub get_system_type { | ||
| 245 | my ($self,$name) = shift; | ||
| 246 | my $returnValue = -1; | ||
| 247 | if ( defined($self->{stem}{'HostProperties'}{'system-type'})) { | ||
| 248 | $returnValue = $self->{stem}{HostProperties}{'system-type'}; | ||
| 249 | } | ||
| 250 | return $returnValue; | ||
| 251 | } | ||
| 252 | |||
| 253 | sub get_operating_system { | ||
| 254 | my ($self,$name) = shift; | ||
| 255 | my $returnValue = -1; | ||
| 256 | if ( defined($self->{stem}{'HostProperties'}{'operating-system'})) { | ||
| 257 | $returnValue = $self->{stem}{HostProperties}{'operating-system'}; | ||
| 258 | } | ||
| 259 | return $returnValue; | ||
| 260 | } | ||
| 261 | |||
| 262 | sub get_mac_address { | ||
| 263 | my ($self,$name) = shift; | ||
| 264 | my $returnValue = -1; | ||
| 265 | if ( defined($self->{stem}{'HostProperties'}{'mac-address'})) { | ||
| 266 | $returnValue = $self->{stem}{HostProperties}{'mac-address'}; | ||
| 267 | } | ||
| 268 | return $returnValue; | ||
| 269 | } | ||
| 270 | |||
| 271 | sub get_mcafee_epo_guid { | ||
| 272 | my ($self,$name) = shift; | ||
| 273 | my $returnValue = -1; | ||
| 274 | if ( defined($self->{stem}{'HostProperties'}{'mcafee-epo-guid'})) { | ||
| 275 | $returnValue = $self->{stem}{HostProperties}{'mcafee-epo-guid'}; | ||
| 276 | } | ||
| 277 | return $returnValue; | ||
| 278 | } | ||
| 279 | |||
| 280 | sub get_bios_uuid { | ||
| 281 | my ($self,$name) = shift; | ||
| 282 | my $returnValue = -1; | ||
| 283 | if ( defined($self->{stem}{'HostProperties'}{'bios-uuid'})) { | ||
| 284 | $returnValue = $self->{stem}{HostProperties}{'bios-uuid'}; | ||
| 285 | } | ||
| 286 | return $returnValue; | ||
| 287 | } | ||
| 288 |