Browse Source

Lands #4813, replaces print_* with exceptions

HD Moore 4 years ago
parent
commit
29ac27f357
No account linked to committer's email address

+ 7
- 11
lib/metasploit/framework/afp/client.rb View File

@@ -77,8 +77,7 @@ module Metasploit
77 77
           begin
78 78
             response = sock.timed_read(1024, self.login_timeout)
79 79
           rescue Timeout::Error
80
-            #vprint_error("AFP #{rhost}:#{rport} Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)")
81
-            return :connection_error
80
+            raise RuntimeError, "AFP Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)"
82 81
           end
83 82
 
84 83
           flags, command, request_id, error_code, length, reserved = parse_header(response)
@@ -87,8 +86,7 @@ module Metasploit
87 86
           when -5001 #kFPAuthContinue
88 87
             return parse_login_response_add_send_login_count(response, {:p => p, :g => g, :ra => ra, :ma => ma,
89 88
                                                                         :password => pass, :user => user})
90
-          when -5023 #kFPUserNotAuth (User dosen't exists)
91
-            #print_status("AFP #{rhost}:#{rport} User #{user} dosen't exists")
89
+          when -5023 #kFPUserNotAuth (User dosen't exists)      
92 90
             return :skip_user
93 91
           else
94 92
             return :connection_error
@@ -123,8 +121,7 @@ module Metasploit
123 121
           begin
124 122
             response = sock.timed_read(1024, self.login_timeout)
125 123
           rescue Timeout::Error
126
-            vprint_error("AFP #{rhost}:#{rport} Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)")
127
-            return :connection_error
124
+            raise RuntimeError, "AFP Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)"
128 125
           end
129 126
 
130 127
           flags, command, request_id, error_code, length, reserved = parse_header(response)
@@ -180,8 +177,7 @@ module Metasploit
180 177
           begin
181 178
             response = sock.timed_read(1024, self.login_timeout)
182 179
           rescue Timeout::Error
183
-            vprint_error("AFP #{rhost}:#{rport} Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)")
184
-            return :connection_error
180
+            raise RuntimeError, "AFP Login timeout (AFP server delay response for 20 - 22 seconds after 7 incorrect logins)"
185 181
           end
186 182
 
187 183
           flags, command, request_id, error_code, length, reserved = parse_header(response)
@@ -201,7 +197,7 @@ module Metasploit
201 197
           parsed_data = {}
202 198
 
203 199
           flags, command, request_id, error_code, length, reserved = parse_header(response)
204
-          raise "AFP #{rhost}:#{rport} Server response with error" if error_code != 0
200
+          raise RuntimeError, "AFP Server response with error" if error_code != 0
205 201
           body = get_body(response, length)
206 202
           machine_type_offset, afp_versions_offset, uam_count_offset, icon_offset, server_flags =
207 203
             body.unpack('nnnnn')
@@ -243,7 +239,7 @@ module Metasploit
243 239
 
244 240
         def get_body(packet, body_length)
245 241
           body = packet[16..body_length + 15]
246
-          raise "AFP #{rhost}:#{rport} Invalid body length" if body.length != body_length
242
+          raise RuntimeError, "AFP Invalid body length" if body.length != body_length
247 243
           return body
248 244
         end
249 245
 
@@ -291,7 +287,7 @@ module Metasploit
291 287
             when 7 # IPv6 address (16 bytes) followed by a two-byte port number
292 288
               parsed_addreses << "[#{IPAddr.ntop(address[1..16])}]:#{address[17..18].unpack("n").first}"
293 289
             else   # Something wrong?
294
-              raise "Error parsing network addresses"
290
+              raise RuntimeError, "Error parsing network addresses"
295 291
             end
296 292
           end
297 293
           return parsed_addreses

+ 6
- 1
lib/metasploit/framework/login_scanner/afp.rb View File

@@ -31,7 +31,12 @@ module Metasploit
31 31
           rescue Rex::ConnectionError, EOFError, Timeout::Error
32 32
             status = Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
33 33
           else
34
-            success = login(credential.public, credential.private)
34
+            begin
35
+              success = login(credential.public, credential.private)
36
+            rescue RuntimeError => e
37
+              return {:status => Metasploit::Model::Login::Status::UNABLE_TO_CONNECT, :proof => e.message}
38
+            end
39
+
35 40
             status = (success == true) ? Metasploit::Model::Login::Status::SUCCESSFUL : Metasploit::Model::Login::Status::INCORRECT
36 41
           end
37 42
 

+ 1
- 2
lib/metasploit/framework/mssql/client.rb View File

@@ -51,8 +51,7 @@ module Metasploit
51 51
 
52 52
           # Send a prelogin packet and check that encryption is not enabled
53 53
           if mssql_prelogin() != ENCRYPT_NOT_SUP
54
-            print_error("Encryption is not supported")
55
-            return false
54
+            raise ::Rex::ConnectionError, "Encryption is not supported"
56 55
           end
57 56
 
58 57
           if windows_authentication

Loading…
Cancel
Save