From 992edab3150c5cae82f4ab9e17261b519a4819e2 Mon Sep 17 00:00:00 2001 From: Rob Glew Date: Thu, 14 Apr 2016 17:25:59 -0500 Subject: [PATCH] Version 0.2.11 --- README.md | 153 ++++++++++++++++++ docs/source/contributing.rst | 2 - docs/source/pappyplugins.rst | 15 +- pappyproxy/__init__.py | 2 +- pappyproxy/config.py | 24 +-- pappyproxy/http.py | 53 ++++++ pappyproxy/macros.py | 102 +++++++++--- pappyproxy/plugin.py | 12 ++ pappyproxy/plugins/macrocmds.py | 68 +++++--- pappyproxy/plugins/misc.py | 77 ++++++++- pappyproxy/plugins/view.py | 7 + pappyproxy/session.py | 19 ++- pappyproxy/templates/macro.py.template | 7 +- pappyproxy/templates/macro_header.py.template | 27 ++++ .../templates/macro_resubmit.py.template | 34 ++++ pappyproxy/templates/macroheader.py.template | 8 + pappyproxy/tests/test_session.py | 25 ++- 17 files changed, 551 insertions(+), 84 deletions(-) create mode 100644 pappyproxy/templates/macro_header.py.template create mode 100644 pappyproxy/templates/macro_resubmit.py.template create mode 100644 pappyproxy/templates/macroheader.py.template diff --git a/README.md b/README.md index 6fbdb9a..a8374f3 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,8 @@ Table of Contents * [Useful Functions](#useful-functions) * [Intercepting Macros](#intercepting-macros) * [Enabling/Disabling Intercepting Macros](#enablingdisabling-intercepting-macros) + * [Macro Templates](#macro-templates) + * [Resubmitting Groups of Requests](#resubmitting-groups-of-requests) * [Logging](#logging) * [Additional Commands and Features](#additional-commands-and-features) * [Response streaming](#response-streaming) @@ -54,6 +56,7 @@ Table of Contents * [Using an HTTP Proxy](#using-an-http-proxy) * [Using a SOCKS Proxy](#using-a-socks-proxy) * [Transparent Host Redirection](#transparent-host-redirection) + * [Project File Encryption](#project-file-encryption) * [FAQ](#faq) * [Why does my request have an id of --?!?!](#why-does-my-request-have-an-id-of---) * [Boring, Technical Stuff](#boring-technical-stuff) @@ -698,6 +701,13 @@ def run_macro(args): If you enter in a value for `SHORT_NAME`, you can use it as a shortcut to run that macro. So if in a macro you set `SHORT_NAME='tm'` you can run it by running `pappy> rma tm`. +Remember, you can use the wildcard to generate a macro with all in-context requests: + +``` +# Generate a macro with all in-context requests +pappy> gma allreqs * +``` + ### Passing Arguments to Macros When you run the macro, any additional command line arguments will be passed to the run_macro function in the `args` argument. For example, if you run your macro using @@ -802,6 +812,7 @@ def run_macro(args): | get_request(url, url_params={}) | Returns a Request object that contains a GET request to the given url with the given url params | | post_request(url, post_params={}, url_params={}) | Returns a Request object that contains a POST request to the given url with the given url and post params | | request_by_id(reqid) | Get a request object from its id. | +| main_context_ids() | Returns a list of the IDs that are in the current context. Use this for macros that need to act on every in-context request. For example, it can be used in a macro to resubmit a set of requests. | Intercepting Macros ------------------- @@ -903,6 +914,77 @@ You can use the following commands to start/stop intercepting macros | `lim` | `list_int_macros`, `lsim` | List all enabled/disabled intercepting macros | | `gima ` | `generate_int_macro`, `gima` | Generate an intercepting macro with the given name. | +Macro Templates +--------------- +Pappy also includes some other templates for generating macros. They can be generated with the `gtma` command. You can then modify the generated macros to do what you want. For example, you could modify the resubmit macro to get a new session token before submitting each request. Using a template can save you from writing boilerplate for commonly created macros. + +Examples: +``` +# The same as gma foo 1,2,3 +pappy> gtma foo macro 1,2,3 +Wrote script to macro_foo.py + +# Generate a macro that resubmits all in-context requests +pappy> gtma suball resubmit +Wrote script to macro_suball.py + +# Generate an intercepting macro that modifies headers as they pass through the proxy +pappy> gtma headers modheader +Wrote script to int_headers.py +``` + +Command information: +| Command | Aliases | Description | +|:--------|:--------|:------------| +| `gtma