diff options
| author | jakob <jakob@memeware.net> | 2017-08-29 15:19:54 -0400 |
|---|---|---|
| committer | jakob <jakob@memeware.net> | 2017-08-29 15:19:54 -0400 |
| commit | a0aac5609c87443ea12d04ffb280234c24d13e3f (patch) | |
| tree | 0d509580be6e30a3ff6a26e55a2f46472c91afcd /hypodermic/ptrace.py | |
| parent | e687f96e883af18ef293b6844ef28f0c829d6e3c (diff) | |
Implemented parsing for procfs maps
Diffstat (limited to 'hypodermic/ptrace.py')
| -rw-r--r-- | hypodermic/ptrace.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/hypodermic/ptrace.py b/hypodermic/ptrace.py index d073930..7a14dea 100644 --- a/hypodermic/ptrace.py +++ b/hypodermic/ptrace.py @@ -15,28 +15,31 @@ # You should have received a copy of the GNU General Public License along # with Hypodermic. If not, see <http://www.gnu.org/licenses/>. -"""Wrapper for the ptrace system call, since python-ptrace sucks.""" +"""ctypes wrapper for ptrace.""" import ctypes -# TODO: Instantiate from binary path, as well. class Process(object): """Process attached via ptrace. Note: The process is implicitly detached from upon destruction of this - object. + object, if appropriate. Args: pid (:obj:`int`, optional): The pid of the process to attach to. - Defaults to 0, which means that it will not be used. + Defaults to 0, which means that the argument will not be + used. path (:obj:`str`, optional): The path of the binary to run. - Defaults to "", which will be used if no pid is specified. + Defaults to "", which will as the target if a pid is not + specified, either. Raises: - TypeError: If the pid argument is not an int. - OSError: If the pid cannot be attached to. + TypeError: If the pid argument is not an int, or if the path + argument is not a string. + OSError: If the pid cannot be attached to, or if the process + could not be created for the given binary. """ def __init__(self, pid=0, path=""): @@ -56,14 +59,12 @@ class Process(object): if self.pid < 0: raise OSError("Could not create process {}".format(path)) - def __del__(self): if hasattr(self, "_is_parent") and not self._is_parent: self.detach() def _load_ffi_methods(self): - # FIXME: How are we going to deal with the path? - self._so = ctypes.cdll.LoadLibrary("/tmp/libptracew.so") + self._so = ctypes.cdll.LoadLibrary("/tmp/libhypodermicw.so") self._new_proc = self._so.new_proc self._attach = self._so.attach self._detach = self._so.detach |