1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-30 12:24:14 +01:00

Added user resoltion to group output

This commit is contained in:
Caleb Stewart 2021-06-05 14:57:02 -04:00
parent 111a3d2717
commit 1dcd58208b
3 changed files with 42 additions and 5 deletions

View File

@ -118,8 +118,21 @@ class Group(Fact):
self.id = gid
self.members: PersistentList = PersistentList(members)
def __repr__(self):
return f"""Group(gid={repr(self.id)}, name={repr(self.name)}, members={repr(self.members)})"""
def title(self, session: "pwncat.manager.Session"):
members = []
for uid in self.members:
user = session.find_user(uid=uid)
if user is None and not isinstance(uid, int):
user = session.find_group(gid=uid)
if user is None:
members.append(f"UID({repr(uid)})")
else:
members.append(user.name)
return f"""Group(gid={repr(self.id)}, name={repr(self.name)}, members={repr(members)})"""
class User(Fact):

View File

@ -68,10 +68,15 @@ class Module(pwncat.modules.BaseModule):
default=True,
help="Return cached results along with new facts (default: True)",
),
"exclude": pwncat.modules.Argument(
pwncat.modules.List(str),
default=None,
help="glob pattern of module names to exclude",
),
}
PLATFORM = None
def run(self, session, output, modules, types, clear, cache):
def run(self, session, output, modules, types, clear, cache, exclude):
"""Perform a enumeration of the given moduels and save the output"""
module_names = modules
@ -83,6 +88,13 @@ class Module(pwncat.modules.BaseModule):
list(session.find_module(f"enumerate.{name}", base=EnumerateModule))
)
if exclude is not None and exclude:
modules = (
module
for module in modules
if not any(fnmatch.fnmatch(module.name, e) for e in exclude)
)
if clear:
for module in modules:
yield pwncat.modules.Status(module.name)

View File

@ -32,8 +32,20 @@ class DomainGroup(WindowsGroup):
self.distinguishedname: Optional[str] = data.get("distinguishedname") or None
self.objectcategory: str = data.get("objectcategory")
def __repr__(self):
return f"""DomainGroup(gid={repr(self.id)}, name={repr(self.name)}, domain={repr(self.domain)}, members={repr(self.members)})"""
def title(self, session: "pwncat.manager.Session"):
members = []
for uid in self.members:
user = session.find_user(uid=uid)
if user is None:
user = session.find_group(gid=uid)
if user is None:
members.append(f"UID({repr(uid)})")
else:
members.append(user.name)
return f"""DomainGroup(gid={repr(self.id)}, name={repr(self.name)}, domain={repr(self.domain)}, members={repr(members)})"""
class Module(EnumerateModule):