BlackArch / blackarch

An ArchLinux based distribution for penetration testers and security researchers.
https://www.blackarch.org
Other
2.83k stars 570 forks source link

CrackMapExec: pywerview #3406

Closed noraj closed 2 years ago

noraj commented 2 years ago

Bug description

Similar to #3343 but for another dependency

$ proxychains cme smb 10.0.0.1
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 573, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 891, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 782, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (pywerview 0.4.0 (/usr/lib/python3.10/site-packages), Requirement.parse('pywerview<0.4.0,>=0.3.3'), {'crackmapexec'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/cme", line 33, in <module>
    sys.exit(load_entry_point('crackmapexec==5.2.3', 'console_scripts', 'cme')())
  File "/usr/lib/python3.10/site-packages/cme/crackmapexec.py", line 114, in main
    args = gen_cli_args()
  File "/usr/lib/python3.10/site-packages/cme/cli.py", line 72, in gen_cli_args
    protocol_object = p_loader.load_protocol(protocols[protocol]['path'])
  File "/usr/lib/python3.10/site-packages/cme/loaders/protocol_loader.py", line 12, in load_protocol
    protocol = imp.load_source('protocol', protocol_path)
  File "/usr/lib/python3.10/imp.py", line 170, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 619, in _exec
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/cme/protocols/smb.py", line 35, in <module>
    from pywerview.cli.helpers import *
  File "/usr/lib/python3.10/site-packages/pywerview/cli/helpers.py", line 20, in <module>
    from pywerview.functions.net import NetRequester
  File "/usr/lib/python3.10/site-packages/pywerview/functions/net.py", line 30, in <module>
    from pywerview.requester import LDAPRPCRequester
  File "/usr/lib/python3.10/site-packages/pywerview/requester.py", line 40, in <module>
    import pywerview.formatters as fmt
  File "/usr/lib/python3.10/site-packages/pywerview/formatters.py", line 21, in <module>
    from impacket.examples.ntlmrelayx.attacks.ldapattack import MSDS_MANAGEDPASSWORD_BLOB
  File "/usr/lib/python3.10/site-packages/impacket/examples/ntlmrelayx/attacks/__init__.py", line 18, in <module>
    import pkg_resources
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3267, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3241, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3279, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 575, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 588, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 777, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pywerview<0.4.0,>=0.3.3' distribution was not found and is required by crackmapexec

It's because we have python-pywerview 0.4.0 now.

$ pacman -Ss pywerview          
blackarch/python-pywerview 0.4.0-1 [installed]
    A Python port of PowerSploit's PowerView'.

Upstream not yet accept 0.4.0

https://github.com/byt3bl33d3r/CrackMapExec/blob/e9bcd09bd2c862200a40ecdc431fcf56f0ae5b67/pyproject.toml#L67

dualfade commented 2 years ago

Do we plan on making changes to the code or submitting pr's ? Otherwise you are instructed to use pipx as the desired installation method which works fine and has no dep issues.

Should we repackage again ? I know I had this done this in pipx prior.

I just tested locally.

~!>D

noraj commented 2 years ago

We're waiting for upstream to fix but feel free to suggest a virtualenv template. Please rather use venv cf https://github.com/BlackArch/blackarch/search?q=venv rather than pipx for packaging.

dualfade commented 2 years ago

Got it. I used pipx to install locally as I need it right now. Also stumbled into the new pip_search brokeness and fixed that from the git ghetto fix.

We can wait. That is fine.

~!>D

noraj commented 2 years ago

Upstream https://github.com/Porchetta-Industries/CrackMapExec/pull/574 as been merged. This should be fixed now. But similar issue occurred with other dependencies: #3509