Skip to content

Commit ffd8890

Browse files
author
jvazquez-r7
committed
Merge branch 'smb_login_option' of https://github.com/wchen-r7/metasploit-framework into wchen-r7-smb_login_option
2 parents 5735930 + 6e6e90d commit ffd8890

File tree

1 file changed

+40
-28
lines changed

1 file changed

+40
-28
lines changed

modules/auxiliary/scanner/smb/smb_login.rb

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ def initialize
3131
and connected to a database this module will record successful
3232
logins and hosts so you can track your access.
3333
},
34-
'Author' => [
35-
'tebo <tebo [at] attackresearch [dot] com>', # Original
36-
'Ben Campbell <eat_meatballs [at] hotmail.co.uk>' # Refactoring
37-
],
34+
'Author' =>
35+
[
36+
'tebo <tebo [at] attackresearch [dot] com>', # Original
37+
'Ben Campbell <eat_meatballs [at] hotmail.co.uk>' # Refactoring
38+
],
3839
'References' =>
3940
[
4041
[ 'CVE', '1999-0506'], # Weak password
@@ -45,15 +46,18 @@ def initialize
4546
deregister_options('RHOST','USERNAME','PASSWORD')
4647

4748
@accepts_guest_logins = {}
48-
@correct_credentials_status_codes = ["STATUS_INVALID_LOGON_HOURS",
49-
"STATUS_INVALID_WORKSTATION",
50-
"STATUS_ACCOUNT_RESTRICTION",
51-
"STATUS_ACCOUNT_EXPIRED",
52-
"STATUS_ACCOUNT_DISABLED",
53-
"STATUS_ACCOUNT_RESTRICTION",
54-
"STATUS_PASSWORD_EXPIRED",
55-
"STATUS_PASSWORD_MUST_CHANGE",
56-
"STATUS_LOGON_TYPE_NOT_GRANTED"]
49+
50+
@correct_credentials_status_codes = [
51+
"STATUS_INVALID_LOGON_HOURS",
52+
"STATUS_INVALID_WORKSTATION",
53+
"STATUS_ACCOUNT_RESTRICTION",
54+
"STATUS_ACCOUNT_EXPIRED",
55+
"STATUS_ACCOUNT_DISABLED",
56+
"STATUS_ACCOUNT_RESTRICTION",
57+
"STATUS_PASSWORD_EXPIRED",
58+
"STATUS_PASSWORD_MUST_CHANGE",
59+
"STATUS_LOGON_TYPE_NOT_GRANTED"
60+
]
5761

5862
# These are normally advanced options, but for this module they have a
5963
# more active role, so make them regular options.
@@ -63,7 +67,7 @@ def initialize
6367
OptString.new('SMBUser', [ false, "SMB Username" ]),
6468
OptString.new('SMBDomain', [ false, "SMB Domain", '']),
6569
OptBool.new('PRESERVE_DOMAINS', [ false, "Respect a username that contains a domain name.", true]),
66-
OptBool.new('RECORD_GUEST', [ false, "Record guest-privileged random logins to the database", false]),
70+
OptBool.new('RECORD_GUEST', [ false, "Record guest-privileged random logins to the database", false])
6771
], self.class)
6872

6973
end
@@ -98,19 +102,22 @@ def check_login_status(domain, user, pass)
98102
connect()
99103
status_code = ""
100104
begin
101-
simple.login( datastore['SMBName'],
102-
user,
103-
pass,
104-
domain,
105-
datastore['SMB::VerifySignature'],
106-
datastore['NTLM::UseNTLMv2'],
107-
datastore['NTLM::UseNTLM2_session'],
108-
datastore['NTLM::SendLM'],
109-
datastore['NTLM::UseLMKey'],
110-
datastore['NTLM::SendNTLM'],
111-
datastore['SMB::Native_OS'],
112-
datastore['SMB::Native_LM'],
113-
{:use_spn => datastore['NTLM::SendSPN'], :name => self.rhost})
105+
simple.login(
106+
datastore['SMBName'],
107+
user,
108+
pass,
109+
domain,
110+
datastore['SMB::VerifySignature'],
111+
datastore['NTLM::UseNTLMv2'],
112+
datastore['NTLM::UseNTLM2_session'],
113+
datastore['NTLM::SendLM'],
114+
datastore['NTLM::UseLMKey'],
115+
datastore['NTLM::SendNTLM'],
116+
datastore['SMB::Native_OS'],
117+
datastore['SMB::Native_LM'],
118+
{:use_spn => datastore['NTLM::SendSPN'], :name => self.rhost}
119+
)
120+
114121
# Windows SMB will return an error code during Session Setup, but nix Samba requires a Tree Connect:
115122
simple.connect("\\\\#{datastore['RHOST']}\\IPC$")
116123
status_code = 'STATUS_SUCCESS'
@@ -212,13 +219,18 @@ def try_user_pass(domain, user, pass)
212219
print_status(output_message % "GUEST LOGIN")
213220
report_creds(domain,user,pass,true)
214221
elsif datastore['VERBOSE']
215-
print_status(output_message % "GUEST LOGIN")
222+
print_status(output_message % "GUEST LOGIN")
216223
end
217224
end
225+
226+
return :next_user
227+
218228
when *@correct_credentials_status_codes
219229
print_status(output_message % "FAILED LOGIN, VALID CREDENTIALS" )
220230
report_creds(domain,user,pass,false)
221231
validuser_case_sensitive?(domain, user, pass)
232+
return :skip_user
233+
222234
when 'STATUS_LOGON_FAILURE', 'STATUS_ACCESS_DENIED'
223235
vprint_error(output_message % "FAILED LOGIN")
224236
else

0 commit comments

Comments
 (0)