From ede6bb6dd1002ff259381bd5620a792bd7dcb8b6 Mon Sep 17 00:00:00 2001 From: jakob Date: Tue, 29 Aug 2017 17:34:30 -0400 Subject: Fixed library symbolic link for development tree. --- hypodermic/main.py | 19 +++++++++++++++++-- hypodermic/ptrace.py | 6 ++++++ wrapper/Makefile | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/hypodermic/main.py b/hypodermic/main.py index b0d709b..0f77de5 100644 --- a/hypodermic/main.py +++ b/hypodermic/main.py @@ -20,9 +20,7 @@ import argparse import sys import textwrap -import pprint # -from hypodermic.memory import maps from hypodermic.ptrace import Process @@ -43,6 +41,13 @@ class CustomHelp(argparse.HelpFormatter): return both.add_usage(usage, actions, groups, prefix) +def _alert(quiet: bool): + def alert(*args): + if not quiet: + print(*args) + return alert + + def main(): parser = argparse.ArgumentParser( add_help=False, @@ -50,6 +55,13 @@ def main(): usage="%(prog)s [-a pid] [-c path] [options]", description="Don't share needles, brah!" ) + parser._optionals.title = "Optional Arguments" + + parser.add_argument( + "-q", + "--quiet", + help="Suppress everything but critical output" + ) doc = parser.add_argument_group("Documentation") doc.add_argument( @@ -82,12 +94,15 @@ def main(): ) args = parser.parse_args() + alert = _alert(args.quiet) if args.attach is None and args.create is None: print("No action specified. Quitting!") sys.exit(1) if args.create: + alert("Creating process at path {}".format(args.create)) p = Process(path=args.create) else: + alert("Attaching to process with pid {}".format(args.attach)) p = Process(pid=args.attach) diff --git a/hypodermic/ptrace.py b/hypodermic/ptrace.py index f54d982..c77fb8e 100644 --- a/hypodermic/ptrace.py +++ b/hypodermic/ptrace.py @@ -20,6 +20,8 @@ import ctypes import os.path +from hypodermic.memory import maps + class Process(object): """Process attached via ptrace. @@ -99,3 +101,7 @@ class Process(object): """ if self._cont(ctypes.c_int(self.pid)): raise OSError("Could not continue") + + @property + def maps(self): + return maps(self.pid) diff --git a/wrapper/Makefile b/wrapper/Makefile index 2e7efee..9ca7761 100644 --- a/wrapper/Makefile +++ b/wrapper/Makefile @@ -12,7 +12,7 @@ all: libhypodermicw.so $(BIN): ptrace.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) - ln -s $@ ../$@ + ln -rs $@ ../ # GNU extension clean: -- cgit v1.3