From 1dcd58208bbd44cdf8ae0eef9e3bc81adfbc88cd Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Sat, 5 Jun 2021 14:57:02 -0400 Subject: [PATCH] Added user resoltion to group output --- pwncat/facts/__init__.py | 17 +++++++++++++++-- pwncat/modules/agnostic/enumerate/gather.py | 14 +++++++++++++- .../modules/windows/enumerate/domain/group.py | 16 ++++++++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/pwncat/facts/__init__.py b/pwncat/facts/__init__.py index 7297727..74d644c 100644 --- a/pwncat/facts/__init__.py +++ b/pwncat/facts/__init__.py @@ -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): diff --git a/pwncat/modules/agnostic/enumerate/gather.py b/pwncat/modules/agnostic/enumerate/gather.py index 60e2b94..54dba04 100644 --- a/pwncat/modules/agnostic/enumerate/gather.py +++ b/pwncat/modules/agnostic/enumerate/gather.py @@ -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) diff --git a/pwncat/modules/windows/enumerate/domain/group.py b/pwncat/modules/windows/enumerate/domain/group.py index 3efc1dc..15c8944 100644 --- a/pwncat/modules/windows/enumerate/domain/group.py +++ b/pwncat/modules/windows/enumerate/domain/group.py @@ -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):