Skip to content

Commit 4d3bfcf

Browse files
dmaloney-r7dmaloney-r7
authored andcommitted
Merge pull request rapid7#109 from rapid7/bug/MSP-10713/smb-error-code
Move error_name to InvalidPacket and check for nil
2 parents a4ff2fd + 51a9a76 commit 4d3bfcf

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/rex/proto/smb/exceptions.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,18 +736,18 @@ def initialize(*args)
736736
super(*args)
737737
end
738738

739-
def error_name
740-
get_error(error_code)
741-
end
742-
743739
# returns an error string if it exists, otherwise just the error code
744740
def get_error(error)
745741
string = ''
746-
if @@errors[error]
742+
if error && @@errors[error]
747743
string = @@errors[error]
748-
else
744+
elsif error
749745
string = sprintf('0x%.8x',error)
746+
else
747+
string = "Unknown error"
750748
end
749+
750+
string
751751
end
752752
end
753753

@@ -785,6 +785,10 @@ class InvalidPacket < Error
785785
attr_accessor :word_count
786786
attr_accessor :command
787787
attr_accessor :error_code
788+
789+
def error_name
790+
get_error(error_code)
791+
end
788792
end
789793

790794
class InvalidWordCount < InvalidPacket

modules/auxiliary/scanner/smb/smb_login.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def run_host(ip)
112112
print_brute :level => :verror, :ip => ip, :msg => "Could not connect"
113113
:abort
114114
when :failed
115-
print_brute :level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}', #{result.proof.error_name}"
115+
print_brute :level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}', #{result.proof}"
116116
invalidate_login(
117117
address: ip,
118118
port: rport,

0 commit comments

Comments
 (0)