Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle no more entries response from ept_lookup rpc call #1849

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion impacket/dcerpc/v5/epm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,13 @@ 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
raise e

for i in range(resp['num_ents']):
tmpEntry = {}
Expand All @@ -1244,6 +1250,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