File tree Expand file tree Collapse file tree 8 files changed +35
-29
lines changed
modules/auxiliary/scanner Expand file tree Collapse file tree 8 files changed +35
-29
lines changed Original file line number Diff line number Diff line change @@ -101,13 +101,13 @@ def run_host(ip)
101
101
end
102
102
end
103
103
104
- disconnect_snmp ( )
105
-
106
- rescue SNMP ::RequestTimeout
107
- print_status ( "#{ ip } , SNMP request timeout." )
104
+ # No need to make noise about timeouts
105
+ rescue ::Rex ::ConnectionError , ::SNMP ::RequestTimeout , ::SNMP ::UnsupportedVersion
108
106
rescue ::Interrupt
109
107
raise $!
110
108
rescue ::Exception => e
111
- print_status ( "Unknown error: #{ e . class } #{ e } " )
109
+ print_error ( "#{ ip } Error: #{ e . class } #{ e } #{ e . backtrace } "
110
+ ensure
111
+ disconnect_snmp
112
112
end
113
113
end
Original file line number Diff line number Diff line change @@ -69,8 +69,11 @@ def run_host(ip)
69
69
70
70
print_status ( status )
71
71
end
72
- disconnect_snmp
73
- rescue SNMP ::RequestTimeout , Rex ::ConnectionError , ::Errno ::ECONNREFUSED
72
+
73
+ # No need to make noise about timeouts
74
+ rescue ::Rex ::ConnectionError , ::SNMP ::RequestTimeout , ::SNMP ::UnsupportedVersion
75
+ rescue ::Interrupt
76
+ raise $!
74
77
rescue Exception => e
75
78
print_error ( "#{ ip } #{ e . class } , #{ e . message } " )
76
79
ensure
Original file line number Diff line number Diff line change @@ -153,14 +153,14 @@ def run_host(ip)
153
153
varbind = SNMP ::VarBind . new ( "#{ cccopyentryrowstatus } #{ session } " , SNMP ::Integer . new ( 6 ) )
154
154
value = snmp . set ( varbind )
155
155
156
- disconnect_snmp
157
-
158
156
# No need to make noise about timeouts
159
- rescue ::SNMP ::RequestTimeout , ::Rex :: ConnectionRefused
157
+ rescue ::Rex :: ConnectionError , :: SNMP ::RequestTimeout , ::SNMP :: UnsupportedVersion
160
158
rescue ::Interrupt
161
159
raise $!
162
160
rescue ::Exception => e
163
161
print_error ( "#{ ip } Error: #{ e . class } #{ e } #{ e . backtrace } " )
162
+ ensure
163
+ disconnect_snmp
164
164
end
165
165
end
166
166
Original file line number Diff line number Diff line change @@ -127,14 +127,16 @@ def run_host(ip)
127
127
varbind = SNMP ::VarBind . new ( "#{ ciscoFlashCopyEntryStatus } #{ session } " , SNMP ::Integer . new ( 1 ) )
128
128
value = snmp . set ( varbind )
129
129
130
- disconnect_snmp
130
+
131
131
132
132
# No need to make noise about timeouts
133
- rescue ::SNMP ::RequestTimeout , ::Rex :: ConnectionRefused
133
+ rescue ::Rex :: ConnectionError , :: SNMP ::RequestTimeout , ::SNMP :: UnsupportedVersion
134
134
rescue ::Interrupt
135
135
raise $!
136
136
rescue ::Exception => e
137
137
print_error ( "#{ ip } Error: #{ e . class } #{ e } #{ e . backtrace } " )
138
+ ensure
139
+ disconnect_snmp
138
140
end
139
141
end
140
142
Original file line number Diff line number Diff line change @@ -951,20 +951,22 @@ def run_host(ip)
951
951
952
952
print_line ( '' )
953
953
954
- disconnect_snmp
954
+
955
955
956
956
rescue SNMP ::RequestTimeout
957
- vprint_status ( "#{ ip } , SNMP request timeout." )
958
- rescue Errno :: ECONNREFUSED
959
- print_status ( "#{ ip } , Connection refused." )
957
+ vprint_status ( "#{ ip } SNMP request timeout." )
958
+ rescue Rex :: ConnectionError
959
+ print_status ( "#{ ip } Connection refused." )
960
960
rescue SNMP ::InvalidIpAddress
961
- print_status ( "#{ ip } , Invalid Ip Address. Check it with 'snmpwalk tool'." )
961
+ print_status ( "#{ ip } Invalid IP Address. Check it with 'snmpwalk tool'." )
962
962
rescue SNMP ::UnsupportedVersion
963
- print_status ( "Unsupported SNMP version specified. Select from '1' or '2c'." )
963
+ print_status ( "#{ ip } Unsupported SNMP version specified. Select from '1' or '2c'." )
964
964
rescue ::Interrupt
965
965
raise $!
966
966
rescue ::Exception => e
967
967
print_status ( "Unknown error: #{ e . class } #{ e } " )
968
+ ensure
969
+ disconnect_snmp
968
970
end
969
971
end
970
972
Original file line number Diff line number Diff line change @@ -59,12 +59,13 @@ def run_host(ip)
59
59
)
60
60
end
61
61
62
- rescue ::SNMP ::UnsupportedVersion
63
- rescue ::SNMP ::RequestTimeout
62
+ rescue ::Rex ::ConnectionError , ::SNMP ::RequestTimeout , ::SNMP ::UnsupportedVersion
64
63
rescue ::Interrupt
65
64
raise $!
66
65
rescue ::Exception => e
67
- print_error ( "Unknown error: #{ e . class } #{ e } " )
66
+ print_error ( "#{ ip } Unknown error: #{ e . class } #{ e } " )
67
+ ensure
68
+ disconnect_snmp
68
69
end
69
70
70
71
end
Original file line number Diff line number Diff line change @@ -84,18 +84,18 @@ def run_host(ip)
84
84
print_status ( "#{ ip } - OID not writable or does not provide WRITE access with community '#{ comm } '" )
85
85
end
86
86
87
- disconnect_snmp
88
-
89
87
rescue ::SNMP ::RequestTimeout
90
88
print_error ( "#{ ip } - SNMP request timeout with community '#{ comm } '." )
91
- rescue ::Rex ::ConnectionRefused
89
+ rescue ::Rex ::ConnectionError
92
90
print_error ( "#{ ip } - 'Connection Refused'" )
93
91
rescue SNMP ::UnsupportedVersion
94
92
print_error ( "#{ ip } - Unsupported SNMP version specified. Select from '1' or '2c'." )
95
93
rescue ::Interrupt
96
94
raise $!
97
95
rescue ::Exception => e
98
96
print_error ( "#{ ip } Error: #{ e . class } #{ e } #{ e . backtrace } " )
97
+ ensure
98
+ disconnect_snmp
99
99
end
100
100
end
101
101
Original file line number Diff line number Diff line change @@ -58,16 +58,14 @@ def run_host(ip)
58
58
end
59
59
end
60
60
61
- disconnect_snmp
62
-
63
61
# No need to make noise about timeouts
64
- rescue ::SNMP ::UnsupportedVersion
65
- rescue ::SNMP ::RequestTimeout
66
- rescue ::Rex ::ConnectionRefused
62
+ rescue ::Rex ::ConnectionError , ::SNMP ::RequestTimeout , ::SNMP ::UnsupportedVersion
67
63
rescue ::Interrupt
68
64
raise $!
69
65
rescue ::Exception => e
70
66
print_error ( "#{ ip } Error: #{ e . class } #{ e } #{ e . backtrace } " )
67
+ ensure
68
+ disconnect_snmp
71
69
end
72
70
end
73
71
end
You can’t perform that action at this time.
0 commit comments