@@ -68,26 +68,23 @@ def sunrpc_create(protocol, program, version)
68
68
end
69
69
70
70
ret = rpcobj . create
71
- return print_error ( "#{ rhost } :#{ rport } - SunRPC - No response to Portmap request" ) unless ret
71
+ raise :: Rex :: Proto :: SunRPC :: RPCError , "#{ rhost } :#{ rport } - SunRPC - No response to Portmap request" unless ret
72
72
73
73
arr = XDR . decode! ( ret , Integer , Integer , Integer , String , Integer , Integer )
74
74
if arr [ 1 ] != MSG_ACCEPTED || arr [ 4 ] != SUCCESS || arr [ 5 ] == 0
75
75
err = "#{ rhost } :#{ rport } - SunRPC - Portmap request failed: "
76
76
err << 'Message not accepted' if arr [ 1 ] != MSG_ACCEPTED
77
77
err << 'RPC did not execute' if arr [ 4 ] != SUCCESS
78
78
err << 'Program not available' if arr [ 5 ] == 0
79
- print_error ( err )
80
- return nil
79
+ raise ::Rex ::Proto ::SunRPC ::RPCError , err
81
80
end
82
81
83
82
rpcobj . pport = arr [ 5 ]
84
- #progname = progresolv(rpcobj.program)
85
- #print_status("#{rhost} - SunRPC Found #{progname} on #{protocol} port #{rpcobj.pport}")
86
83
end
87
84
88
85
def sunrpc_call ( proc , buf , timeout = 20 )
89
86
ret = rpcobj . call ( proc , buf , timeout )
90
- return print_error ( "#{ rhost } :#{ rport } - SunRPC - No response to SunRPC call for procedure: #{ proc } " ) unless ret
87
+ raise :: Rex :: Proto :: SunRPC :: RPCError , "#{ rhost } :#{ rport } - SunRPC - No response to SunRPC call for procedure: #{ proc } " unless ret
91
88
92
89
arr = Rex ::Encoder ::XDR . decode! ( ret , Integer , Integer , Integer , String , Integer )
93
90
if arr [ 1 ] != MSG_ACCEPTED || arr [ 4 ] != SUCCESS
@@ -105,8 +102,7 @@ def sunrpc_call(proc, buf, timeout=20)
105
102
else err << "Unknown Error"
106
103
end
107
104
end
108
- print_error ( "#{ rhost } :#{ rport } - SunRPC - #{ err } " )
109
- return nil
105
+ raise ::Rex ::Proto ::SunRPC ::RPCError , "#{ rhost } :#{ rport } - SunRPC - #{ err } "
110
106
end
111
107
return ret
112
108
end
@@ -142,8 +138,7 @@ def portmap_qry()
142
138
when GARBAGE_ARGS then err << "Garbage Arguments"
143
139
else err << "Unknown Error"
144
140
end
145
- print_error ( "#{ rhost } :#{ rport } - SunRPC - #{ err } " )
146
- return nil
141
+ raise ::Rex ::Proto ::SunRPC ::RPCError , "#{ rhost } :#{ rport } - SunRPC - #{ err } "
147
142
end
148
143
149
144
return ret
0 commit comments