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

Conversation

AndreasLrx
Copy link

Hi 👋

This PR aims to allow usage of ept_lookup with Samba Active Directory.

[MS-RPC] protocol documentation section 2.2.1.2.4 (about ept_lookup) specify the status 0x16C9A0D6 must not be treated as an error but instead inform the caller there are no more elements.

Of course this is not what an MSAD does, it instead always return a status code of 0 and clear the handle when there is no more elements (which explain the existing codebase)

When looking at error codes in rpcrt.py, 0x16C9A0D6 is associated with ept_s_not_registered message.
And the rpc_s_no_more_entries message with 0x16c9a091 code.
I couldn't find actual documentation of this error code (outside in [MS-RPC]), it doesn't even appear in [MS-ERREF] documentation, which is why I didn't changed the error codes in rpcrt.py but instead used it directly in ept_lookup.

@anadrianmanrique anadrianmanrique added in review This issue or pull request is being analyzed low Low priority item and removed in review This issue or pull request is being analyzed labels Nov 22, 2024
@anadrianmanrique
Copy link
Contributor

Thanks for the PR @AndreasLrx . Could you provide more context regarding the scenario you're trying (besides being SAMBA AD) ? Is rpcdump.py failing against the target?
Regarding code, I thing DCERPCException should be re raised if error code is diffent that 0x16C9A0D6

@anadrianmanrique anadrianmanrique added the waiting for response Further information is needed from people who opened the issue or pull request label Nov 22, 2024
@AndreasLrx
Copy link
Author

AndreasLrx commented Nov 25, 2024

Nothing specific about the context, expect being a SAMBA AD. I'm just trying to list the rpc endpoints to find a specific one which is missing in SAMBA AD.

Without the fix, rpcdump.py is failing with the following output:

$ rpcdump.py MYDOMAIN/admin:[email protected] -debug
Impacket v0.13.0.dev0+20241119.85549.6d3cce8c - Copyright Fortra, LLC and its affiliated companies 

[+] Impacket Library Installation Path: /usr/local/lib/python3.9/site-packages/impacket-0.13.0.dev0+20241119.85549.6d3cce8c-py3.9.egg/impacket
[*] Retrieving endpoint list from mydomain.lan
[+] StringBinding ncacn_ip_tcp:mydomain.lan[135]
[-] Protocol failed: DCERPC Runtime Error: code: 0x16c9a0d6 - ept_s_not_registered 
[*] No endpoints found.

And with the fix it behaves as expected:

$ rpcdump.py MYDOMAIN/admin:[email protected] -debug
Impacket v0.13.0.dev0+20241119.85549.6d3cce8c - Copyright Fortra, LLC and its affiliated companies 

[+] Impacket Library Installation Path: /usr/local/lib/python3.9/site-packages/impacket-0.13.0.dev0+20241119.85549.6d3cce8c-py3.9.egg/impacket
[*] Retrieving endpoint list from mydomain.lan
[+] StringBinding ncacn_ip_tcp:mydomain.lan[135]
[...]
[*] Received 53 endpoints.

And yes you're totally right about re raising the exception, I'll amend the commit 👍

@anadrianmanrique anadrianmanrique removed the waiting for response Further information is needed from people who opened the issue or pull request label Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low Low priority item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants