mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-24 09:35:39 +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"):
|
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")
|
group_file = session.platform.Path("/etc/group")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -23,19 +26,18 @@ class Module(EnumerateModule):
|
|||||||
try:
|
try:
|
||||||
# Extract the group fields
|
# Extract the group fields
|
||||||
(group_name, hash, gid, members) = group_line.split(":")
|
(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
|
# Build a group object
|
||||||
group = LinuxGroup(
|
group = LinuxGroup(self.name, group_name, hash, gid, members)
|
||||||
self.name,
|
|
||||||
group_name,
|
|
||||||
hash,
|
|
||||||
int(gid),
|
|
||||||
(m.strip() for m in members.split(",") if m.strip()),
|
|
||||||
)
|
|
||||||
|
|
||||||
yield group
|
yield group
|
||||||
|
|
||||||
except Exception as exc:
|
except (KeyError, ValueError, IndexError):
|
||||||
# Bad group line
|
# Bad group line
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user