Skip to content

Commit bdca86f

Browse files
committed
Map the GKDI endpoint as a workaround
1 parent 878653a commit bdca86f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

lib/msf/core/exploit/remote/ms_gkdi.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,32 @@ def connect_gkdi(opts = {})
6565
end
6666

6767
def bind_gkdi(dcerpc_client)
68-
dcerpc_client.connect
69-
vprint_status('Binding to GKDI...')
68+
tower = gkdi_get_endpoints.first
69+
dcerpc_client.connect(port: tower[:port])
70+
vprint_status("Binding to GKDI via #{tower[:endpoint]}...")
7071
dcerpc_client.bind(
71-
endpoint: RubySMB::Dcerpc::Gkdi,
7272
auth_level: RubySMB::Dcerpc::RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
7373
auth_type: RubySMB::Dcerpc::RPC_C_AUTHN_WINNT
7474
)
7575
vprint_status('Bound to GKDI')
7676
end
7777

78+
def gkdi_get_endpoints(opts = {})
79+
vprint_status('Mapping GKDI endpoints...')
80+
dcerpc_client = RubySMB::Dcerpc::Client.new(
81+
opts.fetch(:rhost) { rhost },
82+
RubySMB::Dcerpc::Epm
83+
)
84+
dcerpc_client.connect
85+
dcerpc_client.bind
86+
# This works around an odd error where if the target has just booted, then no towers (endpoint connection infos)
87+
# will be returned if max_towers is set to 1. Here we map it our self and set max_towers to a higher number to work
88+
# around the behavior. Subsequent mapping attempts will work with max_towers set to 1, but 4 will always work.
89+
towers = dcerpc_client.ept_map_endpoint(RubySMB::Dcerpc::Gkdi, max_towers: 4)
90+
dcerpc_client.close
91+
towers
92+
end
93+
7894
def gkdi_compute_kek(gke, key_identifier)
7995
l2_key = gkdi_compute_l2_key(gke, key_identifier)
8096

0 commit comments

Comments
 (0)