summaryrefslogtreecommitdiff
path: root/hypodermic
diff options
context:
space:
mode:
authorjakob <jakob@memeware.net>2017-08-30 21:36:20 -0400
committerjakob <jakob@memeware.net>2017-08-30 21:36:20 -0400
commitea82e4f3f9187fe90c9f9d8c3c3eb6de59d0a63c (patch)
treebdcd586a4c875db8dea2c611e99bac19238cb7eb /hypodermic
parentede6bb6dd1002ff259381bd5620a792bd7dcb8b6 (diff)
Improved interface for getting a process RTLD
Diffstat (limited to 'hypodermic')
-rw-r--r--hypodermic/main.py5
-rw-r--r--hypodermic/ptrace.py26
2 files changed, 29 insertions, 2 deletions
diff --git a/hypodermic/main.py b/hypodermic/main.py
index 0f77de5..635e3a7 100644
--- a/hypodermic/main.py
+++ b/hypodermic/main.py
@@ -55,9 +55,14 @@ def main():
usage="%(prog)s [-a pid] [-c path] [options]",
description="Don't share needles, brah!"
)
+ parser._positionals.title = "Positional Arguments"
parser._optionals.title = "Optional Arguments"
parser.add_argument(
+ "target",
+ help="The target shared object to inject."
+ )
+ parser.add_argument(
"-q",
"--quiet",
help="Suppress everything but critical output"
diff --git a/hypodermic/ptrace.py b/hypodermic/ptrace.py
index c77fb8e..714b567 100644
--- a/hypodermic/ptrace.py
+++ b/hypodermic/ptrace.py
@@ -19,8 +19,9 @@
import ctypes
import os.path
+import re
-from hypodermic.memory import maps
+from hypodermic.memory import Region, maps
class Process(object):
@@ -103,5 +104,26 @@ class Process(object):
raise OSError("Could not continue")
@property
- def maps(self):
+ def maps(self) -> list:
+ """Obtain the process' memory map.
+
+ Returns:
+ A list of Region objects.
+ """
return maps(self.pid)
+
+ # FIXME: This approach does not work outside of seeing if the
+ # process has an RTLD page. The reality is that the RTLD is
+ # broken up into independent several pages.
+ @property
+ def rtld(self) -> Region:
+ """Obtain the region of memory for the process' RTLD, if it
+ exists.
+
+ Returns:
+ The Region object belonging to the RTLD, or None if no
+ RTLD was found.
+ """
+ for region in self.maps:
+ if re.search(r"ld.+\.so", region.path):
+ return region