@@ -58,11 +58,9 @@ def run
58
58
2 # Program Version: 2
59
59
)
60
60
rescue Rex ::ConnectionError
61
- print_error ( 'Could not connect to portmapper' )
62
- return
61
+ fail_with ( Failure ::Unreachable , 'Could not connect to portmapper' )
63
62
rescue Rex ::Proto ::SunRPC ::RPCError
64
- print_error ( 'Could not connect to ypserv' )
65
- return
63
+ fail_with ( Failure ::Unreachable , 'Could not connect to ypserv' )
66
64
end
67
65
68
66
# Flavor: AUTH_NULL (0)
@@ -80,41 +78,39 @@ def run
80
78
ypserv_all_call # Yellow Pages Service ALL call
81
79
)
82
80
rescue Rex ::Proto ::SunRPC ::RPCError
83
- print_error ( 'Could not call ypserv procedure' )
84
- return
81
+ fail_with ( Failure ::NotFound , 'Could not call ypserv procedure' )
85
82
ensure
86
83
# Shut it down! Shut it down forever!
87
84
sunrpc_destroy
88
85
end
89
86
90
- if res . nil? || res . length < 8
91
- print_error ( 'Invalid response from server' )
87
+ unless res && res . length > 8
88
+ fail_with ( Failure :: UnexpectedReply , 'Invalid response from server' )
92
89
return
93
90
end
94
91
95
92
# XXX: Rex::Encoder::XDR doesn't do signed ints
96
93
case res [ 4 , 4 ] . unpack ( 'l>' ) . first
97
94
# Status: YP_NOMAP (-1)
98
95
when -1
99
- print_error ( "Invalid map #{ map_name } specified" )
100
- return
96
+ fail_with ( Failure ::BadConfig , "Invalid map #{ map_name } specified" )
101
97
# Status: YP_NODOM (-2)
102
98
when -2
103
- print_error ( "Invalid domain #{ domain } specified" )
104
- return
99
+ fail_with ( Failure ::BadConfig , "Invalid domain #{ domain } specified" )
105
100
end
106
101
107
102
map = begin
108
103
Timeout . timeout ( datastore [ 'XDRTimeout' ] ) do
109
104
parse_map ( res )
110
105
end
111
106
rescue Timeout ::Error
112
- print_error ( 'XDR decoding timed out (try increasing XDRTimeout?)' )
107
+ fail_with ( Failure ::TimeoutExpired ,
108
+ 'XDR decoding timed out (try increasing XDRTimeout?)' )
113
109
return
114
110
end
115
111
116
- if map . nil? || map . empty ?
117
- print_error ( "Could not parse map #{ map_name } " )
112
+ if map . blank ?
113
+ fail_with ( Failure :: Unknown , "Could not parse map #{ map_name } " )
118
114
return
119
115
end
120
116
@@ -140,7 +136,11 @@ def parse_map(res)
140
136
String # Key: [redacted]
141
137
)
142
138
143
- status == 1 ? map [ key ] = value : break
139
+ if status == 1 && key && value
140
+ map [ key ] = value
141
+ else
142
+ break
143
+ end
144
144
rescue Rex ::ArgumentError
145
145
vprint_status ( "Finished XDR decoding at #{ res . inspect } " )
146
146
break
0 commit comments