forked from calebstewart/pwncat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81e0005
commit 148c0ba
Showing
60 changed files
with
560 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import pwncat | ||
from pwncat.db.base import Base | ||
from pwncat.db.binary import Binary | ||
from pwncat.db.history import History | ||
from pwncat.db.host import Host | ||
from pwncat.db.persist import Persistence | ||
from pwncat.db.suid import SUID | ||
from pwncat.db.tamper import Tamper | ||
from pwncat.db.user import User, Group, SecondaryGroupAssociation | ||
from pwncat.db.user import User, Group | ||
from pwncat.db.fact import Fact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,38 @@ | ||
#!/usr/bin/env python3 | ||
from typing import Optional | ||
|
||
import persistent | ||
from typing import Optional | ||
from persistent.list import PersistentList | ||
|
||
from pwncat.modules import Result | ||
|
||
|
||
class Fact(Result, persistent.Persistent): | ||
"""Abstract enumerated facts about an enumerated target. Individual | ||
enumeration modules will create subclasses containing the data for | ||
the fact. A generic fact is guaranteed to have a list of types, a | ||
module source, a __repr__ implementation, a __str__ implementation. | ||
class Fact(persistent.Persistent): | ||
"""Store enumerated facts. The pwncat.enumerate.Fact objects are pickled and | ||
stored in the "data" column. The enumerator is arbitrary, but allows for | ||
organizations based on the source enumerator.""" | ||
By default, a category property is defined which is the first type | ||
in the list of types. This can be overloaded if needed, and is used | ||
when formatted and displaying enumeration results. | ||
def __init__(self, arg_type, source): | ||
Lastly, if the description property is not None, it indicates that | ||
the fact has a "long form" description as opposed to a single-line | ||
content. This only effects the way reports are generated. | ||
""" | ||
|
||
def __init__(self, types, source): | ||
super().__init__() | ||
|
||
if not isinstance(types, PersistentList): | ||
types = PersistentList(types) | ||
|
||
# The type of fact (e.g.., "system.user") | ||
self.type: Optional[str] = arg_type | ||
self.types: PersistentList = types | ||
# The original procedure that found this fact | ||
self.source: Optional[str] = source | ||
|
||
# The original SQLAlchemy-style code held a property, "data", | ||
# which was a pickle object. We will re-implement that as a subclass | ||
# but that may need to include the class properties used previously. | ||
self.source: str = source | ||
|
||
@property | ||
def category(self) -> str: | ||
return f"{self.type}" | ||
return f"{self.types[0]} facts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import persistent | ||
import persistent.list | ||
from typing import Optional | ||
|
||
from persistent.list import PersistentList | ||
|
||
from pwncat.db.fact import Fact | ||
|
||
class Group(persistent.Persistent): | ||
""" | ||
Stores a record of changes on the target (i.e., things that have been | ||
tampered with) | ||
""" | ||
|
||
def __init__(self, name, members): | ||
class Group(Fact): | ||
"""Basic representation of a user group on the target system. Individual | ||
platform enumeration modules may subclass this to implement other user | ||
properties as needed for their platform.""" | ||
|
||
self.name: Optional[str] = name | ||
self.members: persistent.list.PersistentList = persistent.list.PersistentList() | ||
def __init__(self, source: str, name: str, gid, members): | ||
super().__init__(["group"], source) | ||
|
||
self.name: str = name | ||
self.id = gid | ||
self.members: PersistentList = PersistentList(members) | ||
|
||
def __repr__(self): | ||
return f"""Group(gid={self.id}, name={repr(self.name)}), members={repr(",".join(m.name for m in self.members))})""" | ||
return f"""Group(gid={self.id}, name={repr(self.name)}), members={repr(",".join(m for m in self.members))})""" | ||
|
||
|
||
class User(Fact): | ||
"""Basic representation of a user on the target system. Individual platform | ||
enumeration modules may subclass this to implement other user properties as | ||
needed for their platform.""" | ||
|
||
class User(persistent.Persistent): | ||
def __init__(self, name, gid, fullname, homedir, password, hash, shell, groups): | ||
def __init__( | ||
self, | ||
source: str, | ||
name, | ||
uid, | ||
password: Optional[str] = None, | ||
hash: Optional[str] = None, | ||
): | ||
super().__init__(["user"], source) | ||
|
||
self.name: Optional[str] = name | ||
self.gid: Optional[int] = gid | ||
self.fullname: Optional[str] = fullname | ||
self.homedir: Optional[str] = homedir | ||
self.password: Optional[str] = password | ||
self.hash: Optional[str] = hash | ||
self.shell: Optional[str] = shell | ||
self.groups: persistent.list.PersistentList = persistent.list.PersistentList( | ||
groups | ||
) | ||
self.name: str = name | ||
self.id = uid | ||
self.password: Optional[str] = None | ||
self.hash: Optional[str] = None | ||
|
||
def __repr__(self): | ||
return f"""User(uid={self.id}, gid={self.gid}, name={repr(self.name)})""" | ||
if self.password is None and self.hash is None: | ||
return f"""User(uid={self.id}, name={repr(self.name)})""" | ||
elif self.password is not None: | ||
return f"""User(uid={repr(self.id)}, name={repr(self.name)}, password={repr(self.password)})""" | ||
else: | ||
return f"""User(uid={repr(self.id)}, name={repr(self.name)}, hash={repr(self.hash)})""" |
Oops, something went wrong.