| 1 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 2 | # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be] | ||||||||||||||||||||||||||||||||
| 3 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 4 | # 2011/mm/dd, v3.002.003, package ASNMTAP::Asnmtap::Plugins::IO | ||||||||||||||||||||||||||||||||
| 5 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | package ASNMTAP::Asnmtap::Plugins::IO; | ||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use Carp qw(cluck); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use warnings; # Must be used in test mode only. This reduces a little process speed | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use ASNMTAP::Asnmtap qw(%STATE %ERRORS %TYPE); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 3 | @ASNMTAP::Asnmtap::Plugins::IO::ISA = qw(Exporter ASNMTAP::Asnmtap); | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 3 | %ASNMTAP::Asnmtap::Plugins::IO::EXPORT_TAGS = ( ALL => [ qw(&scan_socket_info) ], | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | SOCKET => [ qw(&scan_socket_info) ] ); | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | 3 | @ASNMTAP::Asnmtap::Plugins::IO::EXPORT_OK = ( @{ $ASNMTAP::Asnmtap::Plugins::IO::EXPORT_TAGS{ALL} } ); | |||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | 3 | $ASNMTAP::Asnmtap::Plugins::IO::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; | |||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | # Utility methods - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 14 | ▶ | sub scan_socket_info { | ||||||||||||||||||||||||||||||
|
Subroutine
scan_socket_info: called CC=70 SCAR=76.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 42 | 14 | my %defaults = ( asnmtapInherited => undef, | |||||||||||||||||||||||||||||||
| 43 | custom => undef, | ||||||||||||||||||||||||||||||||
| 44 | customArguments => undef, | ||||||||||||||||||||||||||||||||
| 45 | protocol => undef, | ||||||||||||||||||||||||||||||||
| 46 | host => undef, | ||||||||||||||||||||||||||||||||
| 47 | port => undef, | ||||||||||||||||||||||||||||||||
| 48 | service => undef, | ||||||||||||||||||||||||||||||||
| 49 | request => undef, | ||||||||||||||||||||||||||||||||
| 50 | socketTimeout => undef, | ||||||||||||||||||||||||||||||||
| 51 | timeout => 10, | ||||||||||||||||||||||||||||||||
| 52 | POP3 => {} | ||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 14 | my %parms = (%defaults, @_); | |||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | 14 | my $asnmtapInherited = $parms{asnmtapInherited}; | |||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | unless ( defined $asnmtapInherited ) { cluck ( 'ASNMTAP::Asnmtap::Plugins::IO: asnmtapInherited missing' ); exit $ERRORS{UNKNOWN} } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 14 | ▶ | unless ( defined $parms{protocol} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute protocol' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 62 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | 13 | ▶ | unless ( $parms{protocol} =~ /(?:tcp|udp)/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Wrong value for attribute protocol: '. $parms{protocol} }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 67 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | 12 | ▶ | unless ( defined $parms{host} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute host' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 72 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 11 | ▶ | unless ( $parms{host} =~ /^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z][-a-zA-Z0-9]+)*)$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Wrong value for attribute host: '. $parms{host} }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 77 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | 10 | ▶ | unless ( defined $parms{port} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute port' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 82 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 9 | ▶ | unless ( $parms{port} =~ /^([1-9]?(?:\d*))$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 86 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Wrong value for attribute port: '. $parms{port} }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 87 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 8 | ▶ | unless ( defined $parms{service} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 91 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute service' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 92 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | if ( $parms{port} == 110 and $parms{service} eq 'pop3' ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$parms{"port"} == 110 and $parms{"service"} eq "pop3"
MC/DC0%0/2
$parms{"port"} == 110 and $parms{"service"} eq "pop3"
$parms{"port"} == 110
$parms{"service"} eq "pop3"
Truth table33%1/3
A and B
A= $parms{"port"} == 110B= $parms{"service"} eq "pop3"
| |||||||||||||||||||||||||||||||||
| 96 | 7 | ▶ | unless ( defined $parms{POP3}{username} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute username' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 98 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 6 | ▶ | unless ( defined $parms{POP3}{password} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 102 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute password' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 103 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | 5 | ▶ | unless ( defined $parms{POP3}{serviceReady} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 107 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute serviceReady' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 108 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | 4 | ▶ | unless ( defined $parms{POP3}{passwordRequired} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 112 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute passwordRequired' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 113 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||
| 116 | 3 | ▶ | unless ( defined $parms{POP3}{mailMessages} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute mailMessages' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 118 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | unless ( defined $parms{POP3}{closingSession} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 122 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Missing attribute closingSession' }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 123 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 1 | ▶ | if ( defined $parms{socketTimeout} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 128 | 1 | ▶ | unless ( $parms{socketTimeout} =~ /^([1-9]?(?:\d*))$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 129 | 1 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Wrong value for attribute socketTimeout: '. $parms{socketTimeout} }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 130 | 1 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | unless ( $parms{timeout} =~ /^([1-9]?(?:\d*))$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | 0 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'Wrong value for attribute timeout: '. $parms{timeout} }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 136 | 0 | return ( $ERRORS{UNKNOWN} ); | |||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $debug = $$asnmtapInherited->getOptionsValue ( 'debug' ) || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$$asnmtapInherited->getOptionsValue('debug') || 0
MC/DC0%0/1
$$asnmtapInherited->getOptionsValue('debug') || 0
$$asnmtapInherited->getOptionsValue('debug')
Truth table0%0/2
A
A= $$asnmtapInherited->getOptionsValue('debug')
| |||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( $debug >= 2 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 142 | 0 | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::protocol: ', $parms{protocol}, "\n"; | |||||||||||||||||||||||||||||||
| 143 | 0 | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::host: ', $parms{host}, "\n"; | |||||||||||||||||||||||||||||||
| 144 | 0 | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::port: ', $parms{port}, "\n"; | |||||||||||||||||||||||||||||||
| 145 | 0 | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::service: ', $parms{service}, "\n"; | |||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::request: ', $parms{request}, "\n" if ( defined $parms{request} ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 147 | 0 | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::socketTimeout: ', $parms{socketTimeout}, "\n"; | |||||||||||||||||||||||||||||||
| 148 | 0 | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::timeout: ', $parms{timeout}, "\n"; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||
| 153 | 0 | my ($exit, $action, $INET); | |||||||||||||||||||||||||||||||
| 154 | 0 | $exit = 0; | |||||||||||||||||||||||||||||||
| 155 | 0 | $action = '<NIHIL>'; | |||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | $SIG{ALRM} = sub { alarm (0); $exit = 1 }; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 158 | 0 | alarm ( $parms{timeout} ); $exit = 0; | |||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | use IO::Socket; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( defined $parms{socketTimeout} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | $INET = IO::Socket::INET->new ( Proto => $parms{protocol}, PeerAddr => $parms{host}, PeerPort => $parms{port} ); | |||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||
| 165 | 0 | $INET = IO::Socket::INET->new ( Proto => $parms{protocol}, PeerAddr => $parms{host}, PeerPort => $parms{port}, Timeout => $parms{socketTimeout} ); | |||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ( $INET ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action::IO::Socket::INET: $INET\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 170 | } else { | ||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action::IO::Socket::INET: Cannot connect to ${parms{host}}:${parms{service}}\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | 0 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{CRITICAL}, alert => "Cannot connect to ${parms{host}}:${parms{service}}" }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 173 | 0 | return ( $ERRORS{CRITICAL} ); | |||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | 0 | $INET->autoflush ( 1 ); | |||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( $INET && ($parms{protocol} eq 'tcp') ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$INET and $parms{"protocol"} eq "tcp"
MC/DC0%0/2
$INET and $parms{"protocol"} eq "tcp"
$INET
$parms{"protocol"} eq "tcp"
Truth table0%0/3
A and B
A= $INETB= $parms{"protocol"} eq "tcp"
| |||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ( $parms{port} == 25 and $parms{service} eq 'smtp' ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$parms{"port"} == 25 and $parms{"service"} eq "smtp"
MC/DC0%0/2
$parms{"port"} == 25 and $parms{"service"} eq "smtp"
$parms{"port"} == 25
$parms{"service"} eq "smtp"
Truth table0%0/3
A and B
A= $parms{"port"} == 25B= $parms{"service"} eq "smtp"
| |||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action::smtp(25): wait for answer\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | while ( <$INET> ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 183 | 0 | chomp; | |||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action::smtp(25): <$_>\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ( $exit ) { $action = '<TIMEOUT>'; last; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||
| 188 | SWITCH: { | ||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ( $_ =~ /^220 / ) { print $INET "HELP\n"; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | if ( $_ =~ /^211 / ) { print $INET "QUIT\n"; $action = 'OK (211)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ( $_ =~ /^214 / ) { print $INET "QUIT\n"; $action = 'OK (214)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( $_ =~ /^250 / ) { print $INET "QUIT\n"; $action = 'OK (250)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ( $_ =~ /^421 / ) { print $INET "QUIT\n"; $action = 'OK (421)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $_ =~ /^500 / ) { print $INET "QUIT\n"; $action = 'OK (500)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ( $_ =~ /^501 / ) { print $INET "QUIT\n"; $action = 'OK (501)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ( $_ =~ /^502 / ) { print $INET "QUIT\n"; $action = 'OK (502)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ( $_ =~ /^504 / ) { print $INET "QUIT\n"; $action = 'OK (504)'; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ( $_ =~ /^221 / ) { $action = 'OK (221)'; last; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | ▶ | } elsif ( $parms{port} == 110 and $parms{service} eq 'pop3' ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$parms{"port"} == 110 and $parms{"service"} eq "pop3"
MC/DC0%0/2
$parms{"port"} == 110 and $parms{"service"} eq "pop3"
$parms{"port"} == 110
$parms{"service"} eq "pop3"
Truth table0%0/3
A and B
A= $parms{"port"} == 110B= $parms{"service"} eq "pop3"
| |||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action::pop3(110): wait for answer\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | while ( <$INET> ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 205 | 0 | chomp; | |||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action::pop3(110): <$_>\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | if ( $exit ) { $action = "<TIMEOUT>"; last; } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ($_ =~ /^\+OK /) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 211 | SWITCH: { | ||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( $_ =~ /${parms{POP3}{serviceReady}}/ ) { $action = 'USER (POP3)'; print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action: $action\n" if ( $debug >= 2 ); print $INET "USER ${parms{POP3}{username}}\r\n"; } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ( $_ =~ /${parms{POP3}{passwordRequired}}/ ) { $action = 'PASS (POP3)'; print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action: $action\n" if ( $debug >= 2 ); print $INET "PASS ${parms{POP3}{password}}\r\n"; } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if ( $_ =~ /${parms{POP3}{mailMessages}}/ ) { $action = 'QUIT (POP3)'; print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action: $action\n" if ( $debug >= 2 ); print $INET "QUIT\r\n"; } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if ( $_ =~ /${parms{POP3}{closingSession}}/ ) { $action = 'OK (POP3)'; print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::action: $action\n" if ( $debug >= 2 ); last; } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||
| 217 | 0 | } elsif ($_ =~ /^\-ERR /){ $action = "<$_>"; print $INET "HELP\n"; last; } | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | } else { | ||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::tcp: no RFC implementation: ${parms{protocol}} ${parms{service}}(${parms{port}})\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||
| 222 | ▶ | } elsif ( $INET && $parms{protocol} eq 'udp' ) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$INET and $parms{"protocol"} eq "udp"
MC/DC0%0/2
$INET and $parms{"protocol"} eq "udp"
$INET
$parms{"protocol"} eq "udp"
Truth table0%0/3
A and B
A= $INETB= $parms{"protocol"} eq "udp"
| |||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | print "ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info::udp: no RFC implementation: ${parms{protocol}} ${parms{service}}(${parms{port}})\n" if ( $debug >= 2 ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | if ( defined $parms{custom} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | ( defined $parms{customArguments} ) ? $parms{custom}->($$asnmtapInherited, \%parms, \$INET, \$action, $parms{customArguments}) : $parms{custom}->($$asnmtapInherited, \%parms, \$INET, \$action); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 228 | } else { | ||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | print 'ASNMTAP::Asnmtap::Plugins::IO::scan_socket_info: ', $$asnmtapInherited->{_programDescription}, "\n" if ($debug); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||
| 232 | 0 | alarm (0); $SIG{ALRM} = 'DEFAULT'; | |||||||||||||||||||||||||||||||
| 233 | 0 | close ( $INET ); | |||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $INET = ( defined $parms{request} ? $parms{request} : "${parms{service}}(${parms{port}})" ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if ( $INET eq $action ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | 0 | $$asnmtapInherited->pluginValue ( stateValue => $ERRORS{OK} ); | |||||||||||||||||||||||||||||||
| 239 | 0 | return ( $ERRORS{OK} ); | |||||||||||||||||||||||||||||||
| 240 | } else { | ||||||||||||||||||||||||||||||||
| 241 | 0 | $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{CRITICAL}, alert => "Wrong answer from ${parms{host}} ${parms{service}}: $action" }, $TYPE{APPEND} ); | |||||||||||||||||||||||||||||||
| 242 | 0 | return ( $ERRORS{CRITICAL} ); | |||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||
| 246 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | 3 | 1; | |||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||
| 250 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||
| 252 | __END__ | ||||||||||||||||||||||||||||||||