mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-24 01:25:37 +01:00
Fixed group membership for linux enumeration
Added user to member list if primary group matches
This commit is contained in:
parent
31ba4990c8
commit
812776ac28
@ -15,6 +15,9 @@ class Module(EnumerateModule):
|
||||
|
||||
def enumerate(self, session: "pwncat.manager.Session"):
|
||||
|
||||
# Grab all the users and sort by their group ID
|
||||
users = {user.gid: user for user in session.run("enumerate", types=["user"])}
|
||||
|
||||
group_file = session.platform.Path("/etc/group")
|
||||
|
||||
try:
|
||||
@ -23,19 +26,18 @@ class Module(EnumerateModule):
|
||||
try:
|
||||
# Extract the group fields
|
||||
(group_name, hash, gid, members) = group_line.split(":")
|
||||
gid = int(gid)
|
||||
members = [m.strip() for m in members.split(",") if m.strip()]
|
||||
|
||||
if gid in users:
|
||||
members.append(users[gid].name)
|
||||
|
||||
# Build a group object
|
||||
group = LinuxGroup(
|
||||
self.name,
|
||||
group_name,
|
||||
hash,
|
||||
int(gid),
|
||||
(m.strip() for m in members.split(",") if m.strip()),
|
||||
)
|
||||
group = LinuxGroup(self.name, group_name, hash, gid, members)
|
||||
|
||||
yield group
|
||||
|
||||
except Exception as exc:
|
||||
except (KeyError, ValueError, IndexError):
|
||||
# Bad group line
|
||||
continue
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user