BlackArch / blackarch

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

[CrackMapExec] error running with low privs #2694

Closed noraj closed 4 years ago

noraj commented 4 years ago
cme smb 10.10.10.10
Traceback (most recent call last):
  File "/usr/bin/cme", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3251, in <module>
    @_call_aside
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws = cls()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 567, in __init__
    self.add_entry(entry)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 623, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2065, in find_on_path
    for dist in factory(fullpath):
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2135, in distributions_from_metadata
    root, entry, metadata, precedence=DEVELOP_DIST,
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2592, in from_location
    py_version=py_version, platform=platform, **kw
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2994, in _reload_version
    md_version = self._get_version()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2772, in _get_version
    version = _version_from_file(lines)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2556, in _version_from_file
    line = next(iter(version_lines), '')
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2767, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1432, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1420, in get_metadata
    value = self._get(path)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1616, in _get
    with open(path, 'rb') as stream:
IOError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/prettytable-0.7.2-py2.7.egg-info/PKG-INFO'

Works fine with root.

perms on the dependency are wrong:

-rw------- 1 root root 710 févr. 14 11:35 /usr/lib/python2.7/site-packages/prettytable-0.7.2-py2.7.egg-info/PKG-INFO

I don't see a perm issue in https://github.com/BlackArch/blackarch/blob/master/packages/python2-prettytable/PKGBUILD

It may come from another package that has it in dependencies.

noraj commented 4 years ago

FWorkaround: sudo chmod go+r /usr/lib/python2.7/site-packages/prettytable-0.7.2-py2.7.egg-info/PKG-INFO

aancw commented 4 years ago

Same with me. I think prettytable folder need read privileges.

After investigating all of my .egg-info, it has read priv like this.

ls -al /usr/lib/python2.7/site-packages/crackmapexec-4.0.1.dev0-py2.7.egg-info
total 108
drwxr-xr-x   2 root root  4096 Feb 18 16:10 .
drwxr-xr-x 739 root root 53248 Mar 11 14:36 ..
-rw-r--r--   1 root root     1 Feb 10 19:03 dependency_links.txt
-rw-r--r--   1 root root   107 Feb 10 19:03 entry_points.txt
-rw-r--r--   1 root root     1 Feb 10 19:03 not-zip-safe
-rw-r--r--   1 root root   510 Feb 10 19:03 PKG-INFO
-rw-r--r--   1 root root   144 Feb 10 19:03 requires.txt
-rw-r--r--   1 root root 22316 Feb 10 19:03 SOURCES.txt
-rw-r--r--   1 root root     4 Feb 10 19:03 top_level.txt
aancw commented 4 years ago

Reference patch: https://patchwork.openembedded.org/patch/139547/

noraj commented 4 years ago

So the PR fixed it ?

aancw commented 4 years ago

Yes. You can try.

aancw commented 4 years ago

If this issue fixed, it can be closed?

noraj commented 4 years ago

It seems yes.