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

Remove dsinternals dependency #1704

Merged

Conversation

anadrianmanrique
Copy link
Contributor

@anadrianmanrique anadrianmanrique commented Feb 22, 2024

This PR removes dependency with dsinternals library, used in the context of shadow credentials in ntlmrelayx.
fixes #1637

@anadrianmanrique anadrianmanrique added the high High priority item label Feb 22, 2024
@gabrielg5
Copy link
Collaborator

Hey!

From a functional point of view working fine with changes implemented (working like the current master version)

Only one detail, related to the new added helper file impacket/examples/ntlmrelayx/attacks/shadow_credentials.py
If running ntlmrelayx with debug flag enabled, it shows an error that an attribute in that attack is not present

[+] module 'impacket.examples.ntlmrelayx.attacks.shadow_credentials' has no attribute 'PROTOCOL_ATTACK_CLASS'

They are automatically loaded at

for file in pkg_resources.resource_listdir('impacket.examples.ntlmrelayx', 'attacks'):
if file.find('__') >= 0 or file.endswith('.py') is False:
continue
# This seems to be None in some case (py3 only)
# __spec__ is py3 only though, but I haven't seen this being None on py2
# so it should cover all cases.
try:
package = __spec__.name # Python 3
except NameError:
package = __package__ # Python 2
__import__(package + '.' + os.path.splitext(file)[0])
module = sys.modules[package + '.' + os.path.splitext(file)[0]]
try:
pluginClasses = set()
try:
if hasattr(module, 'PROTOCOL_ATTACK_CLASSES'):
# Multiple classes
for pluginClass in module.PROTOCOL_ATTACK_CLASSES:
pluginClasses.add(getattr(module, pluginClass))
else:
# Single class
pluginClasses.add(getattr(module, getattr(module, 'PROTOCOL_ATTACK_CLASS')))
except Exception as e:
LOG.debug(e)
pass
for pluginClass in pluginClasses:
for pluginName in pluginClass.PLUGIN_NAMES:
LOG.debug('Protocol Attack %s loaded..' % pluginName)
PROTOCOL_ATTACKS[pluginName] = pluginClass
except Exception as e:
LOG.debug(str(e))

Perhaps moving that class to another folder (ie: impacket/examples/ntlmrelayx/utils)?

I'm still checking the code, later today will update 🚀

@gabrielg5 gabrielg5 merged commit fa59178 into fortra:master Mar 1, 2024
9 checks passed
@anadrianmanrique anadrianmanrique deleted the remove_dsinternals_dependency branch March 1, 2024 12:35
@anadrianmanrique anadrianmanrique restored the remove_dsinternals_dependency branch June 13, 2024 13:02
@anadrianmanrique anadrianmanrique deleted the remove_dsinternals_dependency branch June 13, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high High priority item
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove dsinternals dependency
2 participants