Skip to content

Commit

Permalink
Handle no more entries response from ept_lookup rpc call
Browse files Browse the repository at this point in the history
  • Loading branch information
Andréas Leroux committed Nov 19, 2024
1 parent 835e175 commit 6d3cce8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion impacket/dcerpc/v5/epm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,12 @@ def hept_lookup(destHost, inquiry_type = RPC_C_EP_ALL_ELTS, objectUUID = NULL, i
request['entry_handle'] = entry_handle
request['max_ents'] = 500

resp = dce.request(request)
try:
resp = dce.request(request)
except DCERPCException as e:
# [MS-RPCE]: Section 2.2.1.2.4 specify ept_lookup should return 0x16C9A0D6 when no more entries
if e.error_code == 0x16c9a0d6:
break

for i in range(resp['num_ents']):
tmpEntry = {}
Expand All @@ -1244,6 +1249,7 @@ def hept_lookup(destHost, inquiry_type = RPC_C_EP_ALL_ELTS, objectUUID = NULL, i
entries.append(tmpEntry)

entry_handle = resp['entry_handle']
# However MSAD implementation seems to never return 0x16C9A0D6 but instead return an empty handle to notify end of elements
if entry_handle.isNull():
break

Expand Down

0 comments on commit 6d3cce8

Please sign in to comment.