A fork of pappy proxy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1807 lines
93 KiB

9 years ago
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The Pappy Proxy &mdash; Pappy Proxy 0.2.0 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '0.2.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Pappy Proxy 0.2.0 documentation" href="index.html" />
<link rel="next" title="The Pappy Proxy Tutorial" href="tutorial.html" />
<link rel="prev" title="Welcome to Pappy Proxy’s documentation!" href="index.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="tutorial.html" title="The Pappy Proxy Tutorial"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to Pappy Proxy’s documentation!"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Pappy Proxy 0.2.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="the-pappy-proxy">
<h1>The Pappy Proxy<a class="headerlink" href="#the-pappy-proxy" title="Permalink to this headline"></a></h1>
<p><a class="reference external" href="https://roglew.github.io/pappy-proxy/">Documentation</a> -
<a class="reference external" href="https://roglew.github.io/pappy-proxy/tutorial.html">Tutorial</a></p>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>The Pappy (<strong>P</strong>roxy <strong>A</strong>ttack <strong>P</strong>roxy <strong>P</strong>rox<strong>Y</strong>) Proxy
is an intercepting proxy for performing web application security
testing. Its features are often similar, or straight up rippoffs from
<a class="reference external" href="https://portswigger.net/burp/">Burp Suite</a>. However, Burp Suite is
neither open source nor a command line tool, thus making a proxy like
Pappy inevitable. The project is still in its early stages, so there are
bugs and only the bare minimum features, but it can already do some cool
stuff.</p>
</div>
<div class="section" id="contributing">
<h2>Contributing<a class="headerlink" href="#contributing" title="Permalink to this headline"></a></h2>
<p><strong>I am taking any and all feature requests.</strong> If you&#8217;ve used Burp and
had any inconvenience with it, tell me about it and I&#8217;ll do everything
in my power to make sure Pappy doesn&#8217;t have those issues. Or even
better, if you want Burp to do something that it doesn&#8217;t already, let me
know so that I can [STRIKEOUT:use it to stomp them into the dust]
improve my project.</p>
<p>If you&#8217;re brave and want to try and contribute code, please let me know.
Right now the codebase is kind of rough and I have refactored it a few
times already, but I would be more than happy to find a stable part of
the codebase that you can contribute to.</p>
<p>Another option is to try writing a plugin. It might be a bit easier than
contributing code and plugins are extremely easy to integrate as a core
feature. So you can also contribute by writing a plugin and letting me
know about it. You can find out more by looking at <a class="reference external" href="https://roglew.github.io/pappy-proxy/pappyplugins.html">the official plugin
docs</a>.</p>
</div>
</div>
<div class="section" id="how-to-use-it">
<h1>How to Use It<a class="headerlink" href="#how-to-use-it" title="Permalink to this headline"></a></h1>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h2>
<p>Pappy supports OS X and Linux (sorry Windows). Installation requires
<code class="docutils literal"><span class="pre">pip</span></code> or some other command that can handle a <code class="docutils literal"><span class="pre">setup.py</span></code> with
requirements. Once the requirements are installed, you can check that it
installed correctly by running <code class="docutils literal"><span class="pre">pappy</span> <span class="pre">-l</span></code> to start the proxy.</p>
<div class="highlight-python"><div class="highlight"><pre>$ git clone --recursive https://github.com/roglew/pappy-proxy.git
$ cd pappy-proxy
$ pip install .
</pre></div>
</div>
</div>
<div class="section" id="quickstart">
<h2>Quickstart<a class="headerlink" href="#quickstart" title="Permalink to this headline"></a></h2>
<p>Pappy projects take up an entire directory. Any generated scripts,
exported responses, plugin data, etc. will be placed in the current
directory so it&#8217;s good to give your project a directory of its own. To
start a project, do something like:</p>
<div class="highlight-python"><div class="highlight"><pre>$ mkdir test_project
$ cd test_project
$ pappy
Copying default config to directory
Proxy is listening on port 8000
pappy&gt; exit
$ ls
data.db project_config.json
$
</pre></div>
</div>
<p>And that&#8217;s it! The proxy will by default be running on port 8000 and
bound to localhost (to keep the hackers out). You can modify the
port/interface in <code class="docutils literal"><span class="pre">config.json</span></code>. You can list all your intercepted
requests with <code class="docutils literal"><span class="pre">ls</span></code>, view a full request with <code class="docutils literal"><span class="pre">vfq</span> <span class="pre">&lt;reqid&gt;</span></code> or view a
full response with <code class="docutils literal"><span class="pre">vfs</span> <span class="pre">&lt;reqid&gt;</span></code>. Right now, the only command to
delete requests is <code class="docutils literal"><span class="pre">filter_prune</span></code> which deletes all the requests that
aren&#8217;t in the current context (look at the sections on the
context/filter strings for more information on that).</p>
</div>
<div class="section" id="lite-mode">
<h2>Lite Mode<a class="headerlink" href="#lite-mode" title="Permalink to this headline"></a></h2>
<p>If you don&#8217;t want to dirty up a directory, you can run Pappy in &#8220;lite&#8221;
mode. Pappy will use the default configuration settings and will create
a temporary data file in <code class="docutils literal"><span class="pre">/tmp</span></code> to use. When you quit, the file will
be deleted. If you want to run Pappy in lite mode, run Pappy with either
<code class="docutils literal"><span class="pre">-l</span></code> or <code class="docutils literal"><span class="pre">--lite</span></code>.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre>$ pappy -l
Temporary datafile is /tmp/tmpw4mGv2
Proxy is listening on port 8000
pappy&gt; quit
Deleting temporary datafile
$
</pre></div>
</div>
</div>
<div class="section" id="adding-the-ca-cert-to-your-browser">
<h2>Adding The CA Cert to Your Browser<a class="headerlink" href="#adding-the-ca-cert-to-your-browser" title="Permalink to this headline"></a></h2>
<p>In order for Pappy to view data sent using HTTPS, you need to add a
generated CA cert (<code class="docutils literal"><span class="pre">certificate.crt</span></code>) to your browser. Certificates
are generated using the <code class="docutils literal"><span class="pre">gencerts</span></code> command and are by default stored
in <code class="docutils literal"><span class="pre">~/.pappy/certs</span></code>. This allows Pappy to act as a CA and sign any
HTTPS certificate it wants without the browser complaining. This allows
Pappy to decrypt and modify HTTPS requests. The certificate installation
instructions are different for each browser.</p>
<div class="section" id="firefox">
<h3>Firefox<a class="headerlink" href="#firefox" title="Permalink to this headline"></a></h3>
<p>You can add the CA cert to Firefox by going to
<code class="docutils literal"><span class="pre">Preferences</span> <span class="pre">-&gt;</span> <span class="pre">Advanced</span> <span class="pre">-&gt;</span> <span class="pre">View</span> <span class="pre">Certificates</span> <span class="pre">-&gt;</span> <span class="pre">Authorities</span> <span class="pre">-&gt;</span> <span class="pre">Import</span></code>
and selecting the <code class="docutils literal"><span class="pre">certificate.crt</span></code> file in the <code class="docutils literal"><span class="pre">certs</span></code> directory.</p>
</div>
<div class="section" id="chrome">
<h3>Chrome<a class="headerlink" href="#chrome" title="Permalink to this headline"></a></h3>
<p>You can add the CA cert to Chrome by going to
<code class="docutils literal"><span class="pre">Settings</span> <span class="pre">-&gt;</span> <span class="pre">Show</span> <span class="pre">advanced</span> <span class="pre">settings</span> <span class="pre">-&gt;</span> <span class="pre">HTTPS/SSL</span> <span class="pre">-&gt;</span> <span class="pre">Manage</span> <span class="pre">Certificates</span> <span class="pre">-&gt;</span> <span class="pre">Authorities</span> <span class="pre">-&gt;</span> <span class="pre">Import</span></code>
and selecting the <code class="docutils literal"><span class="pre">certificate.crt</span></code> file in the <code class="docutils literal"><span class="pre">certs</span></code> directory.</p>
</div>
<div class="section" id="safari">
<h3>Safari<a class="headerlink" href="#safari" title="Permalink to this headline"></a></h3>
<p>For Safari (on macs, obviously), you need to add the CA cert to your
system keychain. You can do this by double clicking on the CA cert and
following the prompts.</p>
</div>
<div class="section" id="internet-explorer">
<h3>Internet Explorer<a class="headerlink" href="#internet-explorer" title="Permalink to this headline"></a></h3>
<p>I didn&#8217;t search too hard for instructions on this (since Pappy doesn&#8217;t
support windows) and I don&#8217;t own a Windows machine to try this, so if
you have trouble, I&#8217;m not the one to ask. According to Google you can
double-click the cert to install it to the system, or you can do
<code class="docutils literal"><span class="pre">Tools</span> <span class="pre">-&gt;</span> <span class="pre">Content</span> <span class="pre">-&gt;</span> <span class="pre">Certificates</span> <span class="pre">-&gt;</span> <span class="pre">Trusted</span> <span class="pre">Root</span> <span class="pre">Certificates</span> <span class="pre">-&gt;</span> <span class="pre">Import</span></code>.</p>
</div>
</div>
<div class="section" id="configuration">
<h2>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline"></a></h2>
<p>Configuration for each project is done in the <code class="docutils literal"><span class="pre">config.json</span></code> file. The
file is a JSON-formatted dictionary that contains settings for the
proxy. The following fields can be used to configure the proxy:</p>
<table border="1" class="docutils">
<colgroup>
<col width="7%" />
<col width="93%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Key</th>
<th class="head">Value</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">data_file</span></code></td>
<td>The file where requests and images will be stored</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">debug_dir</span></code> (optional)</td>
<td>Where connection debug info should be stored. If not present, debug info is not saved to a file.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">cert_dir</span></code></td>
<td>Where the CA cert and the private key for the CA cert are stored</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">proxy_listeners</span></code></td>
<td>A list of dicts which describe which ports the proxy will listen on. Each item is a dict with &#8220;port&#8221; and &#8220;interface&#8221; values which determine which port and interface to listen on. For example, if port=8000 and the interface is 127.0.0.1, the proxy will only accept connections from localhost on port 8000. To accept connections from anywhere, set the interface to 0.0.0.0.</td>
</tr>
</tbody>
</table>
<p>The following tokens will also be replaced with values:</p>
<table border="1" class="docutils">
<colgroup>
<col width="24%" />
<col width="76%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Token</th>
<th class="head">Replaced with</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">{DATADIR}</span></code></td>
<td>The directory where Pappy&#8217;s data files are stored</td>
</tr>
</tbody>
</table>
<p>See the default <code class="docutils literal"><span class="pre">config.json</span></code> for examples.</p>
</div>
<div class="section" id="generating-pappy-s-ca-cert">
<h2>Generating Pappy&#8217;s CA Cert<a class="headerlink" href="#generating-pappy-s-ca-cert" title="Permalink to this headline"></a></h2>
<p>In order to intercept and modify requests to sites that use HTTPS, you
have to generate and install CA certs to your browser. You can do this
by running the <code class="docutils literal"><span class="pre">gencerts</span></code> command in Pappy. By default, certs are
stored <code class="docutils literal"><span class="pre">~/.pappy/certs</span></code>. This is also the default location that Pappy
will look for certificates (unless you specify otherwise in
<code class="docutils literal"><span class="pre">config.json</span></code>.) In addition, you can give the <code class="docutils literal"><span class="pre">gencerts</span></code> command an
argument to have it put the generated certs in a different directory.</p>
<table border="1" class="docutils">
<colgroup>
<col width="13%" />
<col width="87%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">gencerts</span> <span class="pre">[/path/to/put/certs/in]</span></code></td>
<td>Generate a CA cert that can be added to your browser to let Pappy decrypt HTTPS traffic. Also generates the private key for that cert in the same directory. If no path is given, the certs will be placed in the default certificate location. Overwrites any existing certs.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="browsing-recorded-requests-responses">
<h2>Browsing Recorded Requests/Responses<a class="headerlink" href="#browsing-recorded-requests-responses" title="Permalink to this headline"></a></h2>
<p>The following commands can be used to view requests and responses</p>
<table border="1" class="docutils">
<colgroup>
<col width="4%" />
<col width="7%" />
<col width="89%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">ls</span> <span class="pre">[a|&lt;num&gt;</span></code>]</td>
<td>list, ls</td>
<td>List requests that are in the current context (see Context section). Has information like the host, target path, and status code. With no arguments, it will print the 25 most recent requests in the current context. If you pass &#8216;a&#8217; or &#8216;all&#8217; as an argument, it will print all the requests in the current context. If you pass a number &#8220;n&#8221; as an argument, it will print the n most recent requests in the current context.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">sm</span></code></td>
<td>sm, site_map</td>
<td>Print a tree showing the site map. It will display all requests in the current context that did not have a 404 response.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">viq</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td>view_request_info, viq</td>
<td>View additional information about requests. Includes the target port, if SSL was used, applied tags, and other information.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">vfq</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td>view_full_request, vfq</td>
<td>[V]iew [F]ull Re[Q]uest, prints the full request including headers and data.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">vhq</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td>view_request_headers, vhq</td>
<td>[V]iew [H]eaders of a Re[Q]uest. Prints just the headers of a request.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">vfs</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td>view_full_response, vfs</td>
<td>[V]iew [F]ull Re[S]ponse, prints the full response associated with a request including headers and data.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">vhs</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td>view_response_headers, vhs</td>
<td>[V]iew [H]eaders of a Re[S]ponse. Prints just the headers of a response associated with a request.</td>
</tr>
</tbody>
</table>
<p>The table shown by <code class="docutils literal"><span class="pre">ls</span></code> will have the following columns:</p>
<table border="1" class="docutils">
<colgroup>
<col width="5%" />
<col width="95%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Label</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>ID</td>
<td>The request ID of that request. Used to identify the request for other commands.</td>
</tr>
<tr class="row-odd"><td>Method</td>
<td>The method(/http verb) for the request</td>
</tr>
<tr class="row-even"><td>Host</td>
<td>The host that the request was sent to</td>
</tr>
<tr class="row-odd"><td>Path</td>
<td>The path of the request</td>
</tr>
<tr class="row-even"><td>S-Code</td>
<td>The status code of the response</td>
</tr>
<tr class="row-odd"><td>Req Len</td>
<td>The length of the data submitted</td>
</tr>
<tr class="row-even"><td>Rsp Len</td>
<td>The length of the data returned in the response</td>
</tr>
<tr class="row-odd"><td>Time</td>
<td>The time in seconds it took to complete the request</td>
</tr>
<tr class="row-even"><td>Mngl</td>
<td>If the request or response were mangled with the interceptor. If the request was mangled, the column will show &#8216;q&#8217;. If the response was mangled, the column will show &#8216;s&#8217;. If both were mangled, it will show &#8216;q/s&#8217;.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="tags">
<h2>Tags<a class="headerlink" href="#tags" title="Permalink to this headline"></a></h2>
<p>You can apply tags to a request and use filters to view specific tags.
The following commands can be used to apply and remove tags to requests:</p>
<table border="1" class="docutils">
<colgroup>
<col width="18%" />
<col width="7%" />
<col width="74%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">tag</span> <span class="pre">&lt;tag&gt;</span> <span class="pre">[id(s)]</span></code></td>
<td>tag</td>
<td>Apply a tag to the given requests. If no IDs are given, the tag will be applied to all in-context requests.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">untag</span> <span class="pre">&lt;tag&gt;</span> <span class="pre">[id(s)]</span></code></td>
<td>untag</td>
<td>Remove a tag from the given ids. If no IDs are given, the tag is removed from every in-context request.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">clrtag</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td>clrtag</td>
<td>Removes all tags from the given ids.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="request-ids">
<h2>Request IDs<a class="headerlink" href="#request-ids" title="Permalink to this headline"></a></h2>
<p>Request IDs are how you identify a request and every command that
involves specifying a request will take one or more request IDs. You can
see it when you run <code class="docutils literal"><span class="pre">ls</span></code>. In addition, you can prepend an ID with
prefixes to get requests or responses associated with the request (for
example if you modified the request or its response with the
interceptor, you can get the unmangled versions.) Here are the valid
prefixes:</p>
<table border="1" class="docutils">
<colgroup>
<col width="4%" />
<col width="96%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Prefix</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">u</span></code></td>
<td>If the request was mangled, prefixing the ID with <code class="docutils literal"><span class="pre">u</span></code> will result in the unmangled version of the request. The resulting request will not have an associated response because it was never submitted to the server.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">s</span></code></td>
<td>If the response was mangled, prefixing the request ID <code class="docutils literal"><span class="pre">s</span></code> will result in the same request but its associated response will be the unmangled version.</td>
</tr>
</tbody>
</table>
<p>I know it sounds kind of unintuitive. Here are some example commands
that will hopefully make things clearer. Suppose request 1 had its
request mangled, and request 2 had its response mangled.</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">vfq</span> <span class="pre">1</span></code> Prints the mangled version of request 1</li>
<li><code class="docutils literal"><span class="pre">vfq</span> <span class="pre">u1</span></code> Prints the unmangled version of request 1</li>
<li><code class="docutils literal"><span class="pre">rp</span> <span class="pre">u1</span></code> Open the repeater with the unmangled version of request 1</li>
<li><code class="docutils literal"><span class="pre">vfs</span> <span class="pre">u1</span></code> Throws an error because the unmangled version was never
submitted</li>
<li><code class="docutils literal"><span class="pre">vfs</span> <span class="pre">s1</span></code> Throws an error because the response for request 1 was
never mangled</li>
<li><code class="docutils literal"><span class="pre">vfs</span> <span class="pre">2</span></code> Prints the mangled response of request 2</li>
<li><code class="docutils literal"><span class="pre">vfs</span> <span class="pre">s2</span></code> Prints the unmangled response of request 2</li>
<li><code class="docutils literal"><span class="pre">vfq</span> <span class="pre">u2</span></code> Throws an error because request 2&#8217;s request was never
mangled</li>
<li><code class="docutils literal"><span class="pre">vfs</span> <span class="pre">u2</span></code> Throws an error because request 2&#8217;s request was never
mangled</li>
</ul>
<div class="section" id="passing-multiple-request-ids-to-a-command">
<h3>Passing Multiple Request IDs to a Command<a class="headerlink" href="#passing-multiple-request-ids-to-a-command" title="Permalink to this headline"></a></h3>
<p>Some arguments can take multiple IDs for an argument. To pass multiple
IDs to a command, separate the IDs with commas <strong>(no spaces!)</strong>. A few
examples:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">viq</span> <span class="pre">1,2,u3</span></code> View information about requests 1, 2, and the
unmangled version of 3</li>
<li><code class="docutils literal"><span class="pre">gma</span> <span class="pre">foo</span> <span class="pre">4,5,6</span></code> Generate a macro with definitions for requests 4,
5, and 6</li>
</ul>
</div>
</div>
<div class="section" id="context">
<h2>Context<a class="headerlink" href="#context" title="Permalink to this headline"></a></h2>
<p>The context is a set of filters that define which requests are
considered &#8220;active&#8221;. Only requests in the current context are displayed
with <code class="docutils literal"><span class="pre">ls</span></code>. By default, the context includes every single request that
passes through the proxy. You can limit down the current context by
applying filters. Filters apply rules such as &#8220;the response code must
equal 500&#8221; or &#8220;the host must contain google.com&#8221;. Once you apply one or
more filters, only requests/responses which pass every active filter
will be a part of the current context.</p>
<table border="1" class="docutils">
<colgroup>
<col width="13%" />
<col width="11%" />
<col width="76%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">f</span> <span class="pre">&lt;filter</span> <span class="pre">string&gt;</span></code></td>
<td>filter, fl, f</td>
<td>Add a filter that limits which requests are included in the current context. See the Filter String section for how to create a filter string</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">fc</span></code></td>
<td>filter_clear, fc</td>
<td>Clears the filters and resets the context to contain all requests and responses. Ignores scope</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">fu</span></code></td>
<td>filter_up, fu</td>
<td>Removes the most recently applied filter</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">fls</span></code></td>
<td>filter_list, fls</td>
<td>Print the filters that make up the current context</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">filter_prune</span></code></td>
<td>filter_prune</td>
<td>Delete all the requests that aren&#8217;t in the current context from the data file</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="filter-strings">
<h2>Filter Strings<a class="headerlink" href="#filter-strings" title="Permalink to this headline"></a></h2>
<p>Filter strings define a condition that a request/response pair must pass
to be part of the context. Most filter strings have the following
format:</p>
<div class="highlight-python"><div class="highlight"><pre>&lt;field&gt; &lt;comparer&gt; &lt;value&gt;
</pre></div>
</div>
<p>Where <code class="docutils literal"><span class="pre">&lt;field&gt;</span></code> is some part of the request/response, <code class="docutils literal"><span class="pre">&lt;comparer&gt;</span></code>
is some comparison to <code class="docutils literal"><span class="pre">&lt;value&gt;</span></code>. For example, if you wanted a filter
that only matches requests to <code class="docutils literal"><span class="pre">target.org</span></code>, you could use the
following filter string:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">host</span> <span class="ow">is</span> <span class="n">target</span><span class="o">.</span><span class="n">org</span>
<span class="n">field</span> <span class="o">=</span> <span class="s">&quot;host&quot;</span>
<span class="n">comparer</span> <span class="o">=</span> <span class="s">&quot;is&quot;</span>
<span class="n">value</span> <span class="o">=</span> <span class="s">&quot;target.org&quot;</span>
</pre></div>
</div>
<p>Also <strong>if you prefix a comparer with &#8216;n&#8217; it turns it into a negation.</strong>
Using the previous example, the following will match any request except
for ones where the host contains <code class="docutils literal"><span class="pre">target.org</span></code>:</p>
<div class="highlight-python"><div class="highlight"><pre>host nis target.org
field = &quot;host&quot;
comparer = &quot;nis&quot;
value = &quot;target.org&quot;
</pre></div>
</div>
<p>For fields that are a list of key/value pairs (headers, get params, post
params, and cookies) you can use the following format:</p>
<div class="highlight-python"><div class="highlight"><pre>&lt;field&gt; &lt;comparer1&gt; &lt;value1&gt;[ &lt;comparer2&gt; &lt;value2&gt;]
</pre></div>
</div>
<p>This is a little more complicated. If you don&#8217;t give comparer2/value2,
the filter will pass any pair where the key or the value matches
comparer1 and value1. If you do give comparer2/value2, the key must
match comparer1/value1 and the value must match comparer2/value2 For
example:</p>
<div class="highlight-python"><div class="highlight"><pre>Filter A:
cookie contains Session
Filter B:
cookie contains Session contains 456
Filter C:
cookie ncontains Ultra
Cookie: SuperSession=abc123
Matches A and C but not B
Cookie: UltraSession=abc123456
Matches both A and B but not C
</pre></div>
</div>
<div class="section" id="list-of-fields">
<h3>List of fields<a class="headerlink" href="#list-of-fields" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils">
<colgroup>
<col width="10%" />
<col width="23%" />
<col width="58%" />
<col width="9%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field Name</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
<th class="head">Format</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>all</td>
<td>all</td>
<td>The entire request represented as one string</td>
<td>String</td>
</tr>
<tr class="row-odd"><td>host</td>
<td>host, domain, hs, dm</td>
<td>The target host (ie www.target.com)</td>
<td>String</td>
</tr>
<tr class="row-even"><td>path</td>
<td>path, pt</td>
<td>The path of the url (ie /path/to/secrets.php)</td>
<td>String</td>
</tr>
<tr class="row-odd"><td>body</td>
<td>body, data, bd, dt</td>
<td>The body (data section) of either the request or the response</td>
<td>String</td>
</tr>
<tr class="row-even"><td>verb</td>
<td>verb, vb</td>
<td>The HTTP verb of the request (ie GET, POST)</td>
<td>String</td>
</tr>
<tr class="row-odd"><td>param</td>
<td>param, pm</td>
<td>Either the get or post parameters</td>
<td>Key/Value</td>
</tr>
<tr class="row-even"><td>header</td>
<td>header, hd</td>
<td>An HTTP header (ie User-Agent, Basic-Authorization) in the request or response</td>
<td>Key/Value</td>
</tr>
<tr class="row-odd"><td>rawheaders</td>
<td>rawheaders, rh</td>
<td>The entire header section (as one string) of either the head or the response</td>
<td>String</td>
</tr>
<tr class="row-even"><td>sentcookie</td>
<td>sentcookie, sck</td>
<td>A cookie sent in a request</td>
<td>Key/Value</td>
</tr>
<tr class="row-odd"><td>setcookie</td>
<td>setcookie, stck</td>
<td>A cookie set by a response</td>
<td>Key/Value</td>
</tr>
<tr class="row-even"><td>statuscode</td>
<td>statuscode, sc, responsecode</td>
<td>The response code of the response</td>
<td>Numeric</td>
</tr>
<tr class="row-odd"><td>tag</td>
<td>tag</td>
<td>Any of the tags applied to the request</td>
<td>String</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="list-of-comparers">
<h3>List of comparers<a class="headerlink" href="#list-of-comparers" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils">
<colgroup>
<col width="14%" />
<col width="19%" />
<col width="67%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Field Name</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>is</td>
<td>is</td>
<td>Exact string match</td>
</tr>
<tr class="row-odd"><td>contains</td>
<td>contains, ct</td>
<td>A contain B is true if B is a substring of A</td>
</tr>
<tr class="row-even"><td>containsr</td>
<td>containsr, ctr</td>
<td>A containr B is true if A matches regexp B</td>
</tr>
<tr class="row-odd"><td>exists</td>
<td>exists, ex</td>
<td>A exists B if A is not an empty string (likely buggy)</td>
</tr>
<tr class="row-even"><td>Leq</td>
<td>Leq</td>
<td>A Leq B if A&#8217;s length equals B (B must be a number)</td>
</tr>
<tr class="row-odd"><td>Lgt</td>
<td>Lgt</td>
<td>A Lgt B if A&#8217;s length is greater than B (B must be a number )</td>
</tr>
<tr class="row-even"><td>Llt</td>
<td>Llt</td>
<td>A Llt B if A&#8217;s length is less than B (B must be a number)</td>
</tr>
<tr class="row-odd"><td>eq</td>
<td>eq</td>
<td>A eq B if A = B (A and B must be a number)</td>
</tr>
<tr class="row-even"><td>gt</td>
<td>gt</td>
<td>A gt B if A &gt; B (A and B must be a number)</td>
</tr>
<tr class="row-odd"><td>lt</td>
<td>lt</td>
<td>A lt B if A &lt; B (A and B must be a number)</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="special-form-filters">
<h3>Special form filters<a class="headerlink" href="#special-form-filters" title="Permalink to this headline"></a></h3>
<p>A few filters don&#8217;t conform to the field, comparer, value format. You
can still negate these.</p>
<table border="1" class="docutils">
<colgroup>
<col width="8%" />
<col width="13%" />
<col width="78%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Format</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>before</td>
<td>before, bf, b4</td>
<td>Filters out any request that is not before the given request. Filters out any request without a time.</td>
</tr>
<tr class="row-odd"><td>after</td>
<td>after, af</td>
<td>Filters out any request that is not before the given request. Filters out any request without a time.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="scope">
<h2>Scope<a class="headerlink" href="#scope" title="Permalink to this headline"></a></h2>
<p>Scope is a set of rules to define whether Pappy should mess with a
request. You define the scope by setting the context to what you want
the scope to be and running <code class="docutils literal"><span class="pre">scope_save</span></code>. The scope is saved in the
data file and is automatically restored when using the same project
directory.</p>
<p>Any requests which don&#8217;t match all the filters in the scope will be
passed straight to the browser and will not be caught by the interceptor
or recorded in the data file. This is useful to make sure you don&#8217;t
accidentally do something like log in to your email through the proxy
and have your plaintext username/password stored.</p>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="27%" />
<col width="53%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">scope_save</span></code></td>
<td><code class="docutils literal"><span class="pre">scope_save</span></code></td>
<td>Set the current context to be the scope</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">sr</span></code></td>
<td><code class="docutils literal"><span class="pre">scope_reset</span></code>, <code class="docutils literal"><span class="pre">sr</span></code></td>
<td>Set the current context to the scope</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">scope_delete</span></code></td>
<td><code class="docutils literal"><span class="pre">scope_delete</span></code></td>
<td>Clear the scope (everything&#8217;s in scope!)</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">scope_list</span></code></td>
<td><code class="docutils literal"><span class="pre">scope_list</span></code>, <code class="docutils literal"><span class="pre">sls</span></code></td>
<td>List all the filters that are applied to the scope</td>
</tr>
</tbody>
</table>
<div class="section" id="built-in-filters">
<h3>Built-In Filters<a class="headerlink" href="#built-in-filters" title="Permalink to this headline"></a></h3>
<p>Pappy also includes some built in filters that you can apply. These are
things that you may want to filter by but may be too tedius to type out.
The <code class="docutils literal"><span class="pre">fbi</span></code> command also supports tab completion.</p>
<table border="1" class="docutils">
<colgroup>
<col width="25%" />
<col width="75%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Filter</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">not_image</span></code></td>
<td>Matches anything that isn&#8217;t an image.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">not_jscss</span></code></td>
<td>Matches anything that isn&#8217;t JavaScript or CSS.</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="31%" />
<col width="50%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">fbi</span> <span class="pre">&lt;filter&gt;</span></code></td>
<td><code class="docutils literal"><span class="pre">builtin_filter</span></code>, <code class="docutils literal"><span class="pre">fbi</span></code></td>
<td>Apply a built-in filter to the current context</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="interceptor">
<h2>Interceptor<a class="headerlink" href="#interceptor" title="Permalink to this headline"></a></h2>
<p>This feature is like Burp&#8217;s proxy with &#8220;Intercept Mode&#8221; turned on,
except it&#8217;s not turned on unless you explicitly turn it on. When the
proxy gets a request while in intercept mode, it lets you edit it before
forwarding it to the server. In addition, it can stop responses from the
server and let you edit them before they get forwarded to the browser.
When you run the command, you can pass <code class="docutils literal"><span class="pre">req</span></code> and/or <code class="docutils literal"><span class="pre">rsp</span></code> as
arguments to say whether you would like to intercept requests and/or
responses. Only in-scope requests/responses will be intercepted (see
Scope section).</p>
<p>The interceptor will use your EDITOR variable to decide which editor to
edit the request/response with. If no editor variable is set, it will
default to <code class="docutils literal"><span class="pre">vi</span></code>.</p>
<p>To forward a request, edit it, save the file, then quit.</p>
<table border="1" class="docutils">
<colgroup>
<col width="8%" />
<col width="10%" />
<col width="82%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">ic</span> <span class="pre">&lt;req,rsp&gt;+</span></code></td>
<td><code class="docutils literal"><span class="pre">intercept</span></code>, <code class="docutils literal"><span class="pre">ic</span></code></td>
<td>Begins interception mode. Press enter to leave interception mode and return to the command prompt. Pass in <code class="docutils literal"><span class="pre">request</span></code> to intercept requests, <code class="docutils literal"><span class="pre">response</span></code> to intercept responses, or both to intercept both.</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre>Intercept both requests and responses:
&gt; ic requests responses
&gt; ic req rsp
Intercept just requests:
&gt; ic requests
&gt; ic req
Intercept just responses:
&gt; ic responses
&gt; ic rsp
Be totally useless:
&gt; ic
</pre></div>
</div>
<p>To drop a request, delete everything, save and quit.</p>
</div>
<div class="section" id="repeater">
<h2>Repeater<a class="headerlink" href="#repeater" title="Permalink to this headline"></a></h2>
<p>This feature is like Burp&#8217;s repeater (yes, really). You choose a request
and Pappy will open vim in a split window with your request on the left
and the original response on the right. You can make changes to the
request and then run &#8221;:RepeaterSubmitBuffer&#8221; to submit the modified
request. The response will be displayed on the right. This command is
bound to <code class="docutils literal"><span class="pre">&lt;leader&gt;f</span></code> by default, but you can bind it to something else
too in your vimrc (I think, dunno if vim will complain if the function
undefined which it will be for regular files). This command will submit
whatever buffer your cursor is in, so make sure it&#8217;s in the request
buffer.</p>
<p>When you&#8217;re done with repeater, run &#8221;:qa!&#8221; to avoid having to save
changes to nonexistent files.</p>
<table border="1" class="docutils">
<colgroup>
<col width="19%" />
<col width="21%" />
<col width="60%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">rp</span> <span class="pre">&lt;id&gt;</span></code></td>
<td>repeater, rp</td>
<td>Open the specified request in the repeater</td>
</tr>
</tbody>
</table>
<table border="1" class="docutils">
<colgroup>
<col width="20%" />
<col width="10%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Vim Command</th>
<th class="head">Keybinding</th>
<th class="head">Action</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">RepeaterSubmitBuffer</span></code></td>
<td>f</td>
<td>Submit the current buffer, split the windows vertically, and show the result in the right window</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="macros">
<h2>Macros<a class="headerlink" href="#macros" title="Permalink to this headline"></a></h2>
<p>Macros are Pappy&#8217;s version of Burp&#8217;s intruder. You can use macros to
make automated requests through the proxy and save them to the data
file. A macro file is any python script file in the current directory
that is in the form <code class="docutils literal"><span class="pre">macro_&lt;name&gt;.py</span></code>. An example project directory
with macros would be:</p>
<div class="highlight-python"><div class="highlight"><pre>$ ls -l
-rw-r--r-- 1 scaryhacker wheel 150 Nov 26 11:17 config.json
-rw------- 1 scaryhacker wheel 2639872 Nov 26 17:18 data.db
-rw-r--r-- 1 scaryhacker wheel 471 Nov 26 18:42 macro_blank.py
-rw-r--r-- 1 scaryhacker wheel 264 Nov 26 18:49 macro_hackthensa.py
-rw-r--r-- 1 scaryhacker wheel 1261 Nov 26 18:37 macro_testgen.py
-rw-r--r-- 1 scaryhacker wheel 241 Nov 26 17:18 macro_test.py
</pre></div>
</div>
<p>In this case we have a <code class="docutils literal"><span class="pre">blank</span></code>, <code class="docutils literal"><span class="pre">hackthensa</span></code>, <code class="docutils literal"><span class="pre">testgen</span></code>, and
<code class="docutils literal"><span class="pre">test</span></code> macro. A macro script is any python script that defines a
<code class="docutils literal"><span class="pre">run_macro(args)</span></code> function and a <code class="docutils literal"><span class="pre">MACRO_NAME</span></code> variable. For example,
a simple macro would be:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">### macro_print.py</span>
<span class="n">MACRO_NAME</span> <span class="o">=</span> <span class="s">&#39;Print Macro&#39;</span>
<span class="k">def</span> <span class="nf">run_macro</span><span class="p">(</span><span class="n">args</span><span class="p">):</span>
<span class="k">if</span> <span class="n">args</span><span class="p">:</span>
<span class="k">print</span> <span class="s">&quot;Hello, </span><span class="si">%s</span><span class="s">!&quot;</span> <span class="o">%</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">print</span> <span class="s">&quot;Hello, Pappy!&quot;</span>
</pre></div>
</div>
<p>You can place this macro in your project directory then load and run it
from Pappy. When a macro is run, arguments are passed from the command
line. Arguments are separated the same way as they are on the command
line, so if you want to use spaces in your argument, you have to put
quotes around it.</p>
<div class="highlight-python"><div class="highlight"><pre>$ pappy
Proxy is listening on port 8000
pappy&gt; lma
Loaded &quot;&lt;Macro Test Macro (tm/test)&gt;&quot;
Loaded &quot;&lt;Macro Macro 6494496 (testgen)&gt;&quot;
Loaded &quot;&lt;Macro Print Macro (print)&gt;&quot;
Loaded &quot;&lt;Macro Hack the NSA (htnsa/hackthensa)&gt;&quot;
Loaded &quot;&lt;Macro Macro 62449408 (blank)&gt;&quot;
pappy&gt; rma print
Hello, Pappy!
pappy&gt; rma print NSA
Hello, NSA!
pappy&gt; rma print Idiot Slayer
Hello, Idiot!
pappy&gt; rma print &quot;Idiot Slayer&quot;
Hello, Idiot Slayer!
</pre></div>
</div>
<p>You&#8217;ll need to run <code class="docutils literal"><span class="pre">lma</span></code> every time you make a change to the macro in
order to reload it. In addition, any code outside of the <code class="docutils literal"><span class="pre">run_macro</span></code>
function will be run when it the macro gets loaded.</p>
<div class="section" id="generating-macros-from-requests">
<h3>Generating Macros From Requests<a class="headerlink" href="#generating-macros-from-requests" title="Permalink to this headline"></a></h3>
<p>You can also generate macros that have Pappy <code class="docutils literal"><span class="pre">Request</span></code> objects created
with the same information as requests you&#8217;ve already made. For example:</p>
<div class="highlight-python"><div class="highlight"><pre>$ pappy
Proxy is listening on port 8000
pappy&gt; ls
ID Verb Host Path S-Code Req Len Rsp Len Time Mngl
5 GET vitaly.sexy /esr1.jpg 200 OK 0 17653 -- --
4 GET vitaly.sexy /netscape.gif 200 OK 0 1135 -- --
3 GET vitaly.sexy /construction.gif 200 OK 0 28366 -- --
2 GET vitaly.sexy /vitaly2.jpg 200 OK 0 2034003 -- --
1 GET vitaly.sexy / 200 OK 0 1201 -- --
pappy&gt; gma sexy 1
Wrote script to macro_sexy.py
pappy&gt; quit
$ cat macro_sexy.py
from pappyproxy.http import Request, get_request, post_request
MACRO_NAME = &#39;Macro 94664581&#39;
SHORT_NAME = &#39;&#39;
###########
## Requests
req0 = Request((
&#39;GET / HTTP/1.1\r\n&#39;
&#39;Host: vitaly.sexy\r\n&#39;
&#39;User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0\r\n&#39;
&#39;Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n&#39;
&#39;Accept-Language: en-US,en;q=0.5\r\n&#39;
&#39;Accept-Encoding: gzip, deflate\r\n&#39;
&#39;Connection: keep-alive\r\n&#39;
&#39;Pragma: no-cache\r\n&#39;
&#39;Cache-Control: no-cache\r\n&#39;
&#39;\r\n&#39;
))
def run_macro(args):
# Example:
# req = req0.copy() # Copy req0
# req.submit() # Submit the request to get a response
# print req.response.raw_headers # print the response headers
# req.save() # save the request to the data file
# or copy req0 into a loop and use string substitution to automate requests
pass
</pre></div>
</div>
<p>If you enter in a value for <code class="docutils literal"><span class="pre">SHORT_NAME</span></code>, you can use it as a shortcut
to run that macro. So if in a macro you set <code class="docutils literal"><span class="pre">SHORT_NAME='tm'</span></code> you can
run it by running <code class="docutils literal"><span class="pre">pappy&gt;</span> <span class="pre">rma</span> <span class="pre">tm</span></code>.</p>
<table border="1" class="docutils">
<colgroup>
<col width="14%" />
<col width="16%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">lma</span> <span class="pre">[dir]</span></code></td>
<td><code class="docutils literal"><span class="pre">load_macros</span></code>, <code class="docutils literal"><span class="pre">lma</span></code></td>
<td>Load macros from a directory. If <code class="docutils literal"><span class="pre">dir</span></code> is not given, use the current directory (the project directory)</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">rma</span> <span class="pre">&lt;macro</span> <span class="pre">name&gt;</span></code></td>
<td><code class="docutils literal"><span class="pre">run_macro</span></code>, <code class="docutils literal"><span class="pre">rma</span></code></td>
<td>Run a macro with the given name. You can use the shortname, filename, or long name.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">gma</span> <span class="pre">&lt;name&gt;</span> <span class="pre">[id(s)]</span></code></td>
<td><code class="docutils literal"><span class="pre">generate_macro</span></code>, <code class="docutils literal"><span class="pre">gma</span></code></td>
<td>Generate a macro with the given name. If request IDs are given, the macro will contain request objects that contain each request.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">rpy</span> <span class="pre">&lt;id(s)&gt;</span></code></td>
<td><code class="docutils literal"><span class="pre">rpy</span></code></td>
<td>Print the Python object definitions for each of the given ids</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="request-objects">
<h3>Request Objects<a class="headerlink" href="#request-objects" title="Permalink to this headline"></a></h3>
<p>The main method of interacting with the proxy is through <code class="docutils literal"><span class="pre">Request</span></code>
objects. You can submit a request with <code class="docutils literal"><span class="pre">req.sumbit()</span></code> and save it to
the data file with <code class="docutils literal"><span class="pre">req.save()</span></code>. The objects also have attributes
which can be used to modify the request in a high-level way. You can see
the <a class="reference external" href="https://roglew.github.io/pappy-proxy/pappyproxy.html#module-pappyproxy.http">full
documentation</a>
for more details on using these objects.</p>
<p>Dict-like objects are represented with a custom class called a
<code class="docutils literal"><span class="pre">RepeatableDict</span></code>. Again, look at the docs for details. For the most
part, you can interact with it like a normal dictionary, but don&#8217;t be
surprised if it&#8217;s missing some methods you would expect.</p>
<p>Here is a quick list of attributes that you can use with <code class="docutils literal"><span class="pre">Request</span></code>
objects:</p>
<table border="1" class="docutils">
<colgroup>
<col width="11%" />
<col width="8%" />
<col width="11%" />
<col width="70%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Attribute</th>
<th class="head">Settable?</th>
<th class="head">Data Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>cookies</td>
<td>Yes</td>
<td>RepeatableDict</td>
<td>Cookies sent in the request</td>
</tr>
<tr class="row-odd"><td>fragment</td>
<td>Yes</td>
<td>String</td>
<td>The url fragment (The text after the #)</td>
</tr>
<tr class="row-even"><td>full_path</td>
<td>No</td>
<td>String</td>
<td>The path including url params and the fragment</td>
</tr>
<tr class="row-odd"><td>full_request</td>
<td>No</td>
<td>String</td>
<td>The full request including headers and data</td>
</tr>
<tr class="row-even"><td>headers</td>
<td>Yes</td>
<td>RepeatableDict</td>
<td>The headers of the request</td>
</tr>
<tr class="row-odd"><td>host</td>
<td>Yes</td>
<td>String</td>
<td>The host that the request is sent to</td>
</tr>
<tr class="row-even"><td>is_ssl</td>
<td>Yes</td>
<td>Bool</td>
<td>Whether the request is/was sent over SSL</td>
</tr>
<tr class="row-odd"><td>path</td>
<td>Yes</td>
<td>String</td>
<td>The document path (ie www.a.com/this/is/the/path)</td>
</tr>
<tr class="row-even"><td>port</td>
<td>Yes</td>
<td>Integer</td>
<td>The port the request is/was sent to</td>
</tr>
<tr class="row-odd"><td>post_params</td>
<td>Yes</td>
<td>RepeatableDict</td>
<td>Post parameters</td>
</tr>
<tr class="row-even"><td>raw_data</td>
<td>Yes</td>
<td>String</td>
<td>The data part of the request</td>
</tr>
<tr class="row-odd"><td>raw_headers</td>
<td>No</td>
<td>String</td>
<td>The text of the headers section of the request</td>
</tr>
<tr class="row-even"><td>reqid</td>
<td>Yes</td>
<td>Integer</td>
<td>The ID of the request. If set when save() is called, it replaces the request with the same id in the database</td>
</tr>
<tr class="row-odd"><td>response</td>
<td>Yes</td>
<td>Response</td>
<td>The associated response for the request</td>
</tr>
<tr class="row-even"><td>rsptime</td>
<td>No</td>
<td>Datetime Delta</td>
<td>The time it took to complete the request. Set when submit() is called</td>
</tr>
<tr class="row-odd"><td>status_line</td>
<td>Yes</td>
<td>String</td>
<td>The status line of the request (ie &#8216;GET / HTTP/1.1&#8217;)</td>
</tr>
<tr class="row-even"><td>time_end</td>
<td>Yes</td>
<td>Datetime</td>
<td>The time when the request was completed</td>
</tr>
<tr class="row-odd"><td>time_start</td>
<td>Yes</td>
<td>Datetime</td>
<td>The time when the request was started</td>
</tr>
<tr class="row-even"><td>unmangled</td>
<td>Yes</td>
<td>Request</td>
<td>If the request was mangled, the unmangled version of the request</td>
</tr>
<tr class="row-odd"><td>url</td>
<td>Yes</td>
<td>String</td>
<td>The URL of the request (ie &#8216;<a class="reference external" href="https://www.google.com">https://www.google.com</a>&#8216;)</td>
</tr>
<tr class="row-even"><td>url_params</td>
<td>Yes</td>
<td>RepeatableDict</td>
<td>The URL parameters of the request</td>
</tr>
<tr class="row-odd"><td>verb</td>
<td>Yes</td>
<td>String</td>
<td>The verb used for the request (ie GET, POST, PATCH, HEAD, etc). Doesn&#8217;t have to be a valid verb.</td>
</tr>
<tr class="row-even"><td>version</td>
<td>Yes</td>
<td>String</td>
<td>The version part of the status line (ie &#8216;HTTP/1.1&#8217;)</td>
</tr>
</tbody>
</table>
<p>Request methods:</p>
<table border="1" class="docutils">
<colgroup>
<col width="9%" />
<col width="91%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Function</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>submit()</td>
<td>Submit the request through the proxy. Does not save the request to the data file</td>
</tr>
<tr class="row-odd"><td>save()</td>
<td>Save the request, its unmangled version, its associated response, and the unmangled version of the response to the database</td>
</tr>
</tbody>
</table>
<p>And here is a quick list of attributes that you can use with
<code class="docutils literal"><span class="pre">Response</span></code> objects:</p>
<table border="1" class="docutils">
<colgroup>
<col width="8%" />
<col width="6%" />
<col width="8%" />
<col width="78%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Attribute</th>
<th class="head">Settable?</th>
<th class="head">Data Type</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>cookies</td>
<td>Yes</td>
<td>RepeatableDict</td>
<td>Cookies set by the response</td>
</tr>
<tr class="row-odd"><td>headers</td>
<td>Yes</td>
<td>RepeatableDict</td>
<td>The headers of the response</td>
</tr>
<tr class="row-even"><td>response_code</td>
<td>Yes</td>
<td>Integer</td>
<td>The response code of the response</td>
</tr>
<tr class="row-odd"><td>response_text</td>
<td>Yes</td>
<td>String</td>
<td>The text associated with the response code (ie OK, NOT FOUND)</td>
</tr>
<tr class="row-even"><td>rspid</td>
<td>Yes</td>
<td>Integer</td>
<td>The response id of the response. If this is the same as another response in the database, calling save() on the associated request will replace that response in the database</td>
</tr>
<tr class="row-odd"><td>unmangled</td>
<td>Yes</td>
<td>Response</td>
<td>If the response was mangled, this will refer to the unmangled version of the response. Otherwise it is None</td>
</tr>
<tr class="row-even"><td>version</td>
<td>Yes</td>
<td>String</td>
<td>The version part of the status line of the response (ie &#8216;HTTP/1.1&#8217;)</td>
</tr>
<tr class="row-odd"><td>raw_headers</td>
<td>No</td>
<td>String</td>
<td>A text version of the headers of the response</td>
</tr>
<tr class="row-even"><td>status_line</td>
<td>Yes</td>
<td>String</td>
<td>The status line of the response</td>
</tr>
<tr class="row-odd"><td>raw_data</td>
<td>Yes</td>
<td>String</td>
<td>The data portion of the response</td>
</tr>
<tr class="row-even"><td>full_response</td>
<td>No</td>
<td>String</td>
<td>The full text version of the response including headers and data</td>
</tr>
</tbody>
</table>
<p>Like I said, these interfaces are prone to change and will probably
crash when you use them. If you get a traceback, send me an email so I
can fix it.</p>
</div>
<div class="section" id="useful-functions">
<h3>Useful Functions<a class="headerlink" href="#useful-functions" title="Permalink to this headline"></a></h3>
<p>There are also a few functions which could be useful for creating
requests in macros. It&#8217;s worth pointing out that <code class="docutils literal"><span class="pre">request_by_id</span></code> is
useful for passing request objects as arguments. For example, here is a
macro that lets you resubmit a request with the Google Bot user agent:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## macro_googlebot.py</span>
<span class="kn">from</span> <span class="nn">pappyproxy.http</span> <span class="kn">import</span> <span class="n">Request</span><span class="p">,</span> <span class="n">get_request</span><span class="p">,</span> <span class="n">post_request</span><span class="p">,</span> <span class="n">request_by_id</span>
<span class="kn">from</span> <span class="nn">pappyproxy.context</span> <span class="kn">import</span> <span class="n">set_tag</span>
<span class="kn">from</span> <span class="nn">pappyproxy.iter</span> <span class="kn">import</span> <span class="o">*</span>
<span class="n">MACRO_NAME</span> <span class="o">=</span> <span class="s">&#39;Submit as Google&#39;</span>
<span class="n">SHORT_NAME</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
<span class="k">def</span> <span class="nf">run_macro</span><span class="p">(</span><span class="n">args</span><span class="p">):</span>
<span class="n">req</span> <span class="o">=</span> <span class="n">request_by_id</span><span class="p">(</span><span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="n">req</span><span class="o">.</span><span class="n">headers</span><span class="p">[</span><span class="s">&#39;User-Agent&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&quot;Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)&quot;</span>
<span class="n">req</span><span class="o">.</span><span class="n">submit</span><span class="p">()</span>
<span class="n">req</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
</pre></div>
</div>
<table border="1" class="docutils">
<colgroup>
<col width="34%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Function</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>get_request(url, url_params={})</td>
<td>Returns a Request object that contains a GET request to the given url with the given url params</td>
</tr>
<tr class="row-odd"><td>post_request(url, post_params={}, url_params={})</td>
<td>Returns a Request object that contains a POST request to the given url with the given url and post params</td>
</tr>
<tr class="row-even"><td>request_by_id(reqid)</td>
<td>Get a request object from its id.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="intercepting-macros">
<h2>Intercepting Macros<a class="headerlink" href="#intercepting-macros" title="Permalink to this headline"></a></h2>
<p>Intercepting macros let you mangle requests as they pass through the
proxy. Similarly to normal macros, an intercepting macro is any python
script with an &#8220;int&#8221; prefix. For example, <code class="docutils literal"><span class="pre">int_name.py</span></code> would be a
valid intercepting macro name. They are also loaded with the <code class="docutils literal"><span class="pre">lma</span></code>
command. An intercepting macro can define two functions:
<code class="docutils literal"><span class="pre">mangle_request</span></code> or <code class="docutils literal"><span class="pre">mangle_response</span></code>. Both requests only take a
<code class="docutils literal"><span class="pre">Request</span></code> object as a parameter. <code class="docutils literal"><span class="pre">mangle_request</span></code> returns either a
new, modified Request object to change it, or it can return the original
object to not mangle it. The <code class="docutils literal"><span class="pre">mange_response</span></code> must return a
<code class="docutils literal"><span class="pre">Response</span></code> (not request!) object. The request passed in to
<code class="docutils literal"><span class="pre">mangle_response</span></code> will have an associated response with it. If you
want to modify the response, copy <code class="docutils literal"><span class="pre">request.response</span></code>, make
modifications, then return it. If you would like to pass it through
untouched, just return <code class="docutils literal"><span class="pre">request.response</span></code>.</p>
<p>Note, that due to twisted funkyness, <em>you cannot save requests from
intercepting macros</em>. Technically you <strong>can</strong>, but to do that you&#8217;ll
have to define <code class="docutils literal"><span class="pre">async_mangle_request</span></code> (or response) instead of
<code class="docutils literal"><span class="pre">mangle_request</span></code> (or response) then use <code class="docutils literal"><span class="pre">Request.async_deep_save</span></code>
which generates a deferred, then generate a deferred from
<code class="docutils literal"><span class="pre">async_mangle_requests</span></code> (inline callbacks work too). If you&#8217;ve never
used twisted before, please don&#8217;t try. Twisted is hard. Plus the mangled
request will be saved before it is submitted anyways.</p>
<p>Confusing? Here are some example intercepting macros:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## int_cloud2butt.py</span>
<span class="kn">import</span> <span class="nn">string</span>
<span class="n">MACRO_NAME</span> <span class="o">=</span> <span class="s">&#39;Cloud to Butt&#39;</span>
<span class="k">def</span> <span class="nf">mangle_response</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">response</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
<span class="n">r</span><span class="o">.</span><span class="n">raw_data</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">raw_data</span><span class="p">,</span> <span class="s">&#39;cloud&#39;</span><span class="p">,</span> <span class="s">&#39;butt&#39;</span><span class="p">)</span>
<span class="n">r</span><span class="o">.</span><span class="n">raw_data</span> <span class="o">=</span> <span class="n">string</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">r</span><span class="o">.</span><span class="n">raw_data</span><span class="p">,</span> <span class="s">&#39;Cloud&#39;</span><span class="p">,</span> <span class="s">&#39;Butt&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">r</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## int_donothing.py</span>
<span class="kn">import</span> <span class="nn">string</span>
<span class="n">MACRO_NAME</span> <span class="o">=</span> <span class="s">&#39;Do Nothing&#39;</span>
<span class="k">def</span> <span class="nf">mangle_request</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">return</span> <span class="n">request</span>
<span class="k">def</span> <span class="nf">mangle_response</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">response</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## int_adminplz.py</span>
<span class="kn">from</span> <span class="nn">base64</span> <span class="kn">import</span> <span class="n">base64encode</span> <span class="k">as</span> <span class="n">b64e</span>
<span class="n">MACRO_NAME</span> <span class="o">=</span> <span class="s">&#39;Admin Session&#39;</span>
<span class="k">def</span> <span class="nf">mangle_request</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="n">r</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>
<span class="n">r</span><span class="o">.</span><span class="n">headers</span><span class="p">[</span><span class="s">&#39;Authorization&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;Basic </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">b64e</span><span class="p">(</span><span class="s">&#39;Admin:Password123&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">r</span>
</pre></div>
</div>
<p>In addition, you can use an <code class="docutils literal"><span class="pre">init(args)</span></code> function to get arguments
from the command line. If no arguments are passed, args will be an empty
list. Here is an example macro that does a search and replace:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## int_replace.py</span>
<span class="n">MACRO_NAME</span> <span class="o">=</span> <span class="s">&#39;Find and Replace&#39;</span>
<span class="n">SHORT_NAME</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
<span class="n">runargs</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="n">args</span><span class="p">):</span>
<span class="k">global</span> <span class="n">runargs</span>
<span class="n">runargs</span> <span class="o">=</span> <span class="n">args</span>
<span class="k">def</span> <span class="nf">mangle_request</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">global</span> <span class="n">runargs</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">runargs</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">request</span>
<span class="n">request</span><span class="o">.</span><span class="n">body</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">body</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">runargs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">runargs</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="k">return</span> <span class="n">request</span>
<span class="k">def</span> <span class="nf">mangle_response</span><span class="p">(</span><span class="n">request</span><span class="p">):</span>
<span class="k">global</span> <span class="n">runargs</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">runargs</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">response</span>
<span class="n">request</span><span class="o">.</span><span class="n">response</span><span class="o">.</span><span class="n">body</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">response</span><span class="o">.</span><span class="n">body</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="n">runargs</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">runargs</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
<span class="k">return</span> <span class="n">request</span><span class="o">.</span><span class="n">response</span>
</pre></div>
</div>
<p>You can use this macro to do any search and replace that you want. For
example, if you wanted to replace &#8220;Google&#8221; with &#8220;Skynet&#8221;, you can run
the macro like this:</p>
<div class="highlight-python"><div class="highlight"><pre>pappy&gt; lma
Loaded &quot;&lt;InterceptingMacro Find and Replace (replace)&gt;&quot;
pappy&gt; rim replace Google Skynet
&quot;Find and Replace&quot; started
pappy&gt;
</pre></div>
</div>
<p>Now every site that you visit will be a little bit more accurate.</p>
<div class="section" id="enabling-disabling-intercepting-macros">
<h3>Enabling/Disabling Intercepting Macros<a class="headerlink" href="#enabling-disabling-intercepting-macros" title="Permalink to this headline"></a></h3>
<p>You can use the following commands to start/stop intercepting macros</p>
<table border="1" class="docutils">
<colgroup>
<col width="16%" />
<col width="18%" />
<col width="66%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">lma</span> <span class="pre">[dir]</span></code></td>
<td><code class="docutils literal"><span class="pre">load_macros</span></code>, <code class="docutils literal"><span class="pre">lma</span></code></td>
<td>Load macros from a directory. If <code class="docutils literal"><span class="pre">dir</span></code> is not given, use the current directory (the project directory)</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">rim</span> <span class="pre">&lt;macro</span> <span class="pre">name&gt;</span></code></td>
<td><code class="docutils literal"><span class="pre">run_int_macro</span></code>, <code class="docutils literal"><span class="pre">rim</span></code></td>
<td>Run an intercepting macro. Similarly to normal macros you can use the name, short name, or file name of the macro.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">sim</span> <span class="pre">&lt;macro</span> <span class="pre">name&gt;</span> <span class="pre">[args]</span></code></td>
<td><code class="docutils literal"><span class="pre">stop_int_macro</span></code>, <code class="docutils literal"><span class="pre">sim</span></code></td>
<td>Stop an intercepting macro. If arguments are given, they will be passed to the macro&#8217;s <code class="docutils literal"><span class="pre">init(args)</span></code> function if it exists.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">lim</span></code></td>
<td><code class="docutils literal"><span class="pre">list_int_macros</span></code>, <code class="docutils literal"><span class="pre">lsim</span></code></td>
<td>List all enabled/disabled intercepting macros</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">gima</span> <span class="pre">&lt;name&gt;</span></code></td>
<td><code class="docutils literal"><span class="pre">generate_int_macro</span></code>, <code class="docutils literal"><span class="pre">gima</span></code></td>
<td>Generate an intercepting macro with the given name.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="logging">
<h2>Logging<a class="headerlink" href="#logging" title="Permalink to this headline"></a></h2>
<p>You can watch in real-time what requests are going through the proxy.
Verbosisty defaults to 1 which just states when connections are
made/lost and some information on what is happening. If verbosity is set
to 3, it includes all the data which is sent through the proxy and
processed. It will print the raw response from the server, what it
decodes it to, etc. Even if you don&#8217;t run this command, all the
information is stored in the dubug directory (the directory is cleared
every start though!)</p>
<table border="1" class="docutils">
<colgroup>
<col width="9%" />
<col width="91%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">log</span> <span class="pre">[verbosity]</span></code></td>
<td>View the log at the given verbosity. Default verbosity is 1 which just shows connections being made/lost and some other info, verbosity 3 shows full requests/responses as they pass through and are processed by the proxy</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="additional-commands-and-features">
<h2>Additional Commands and Features<a class="headerlink" href="#additional-commands-and-features" title="Permalink to this headline"></a></h2>
<p>This is a list of other random stuff you can do that isn&#8217;t categorized
under anything else. These are mostly commands that I found that I
needed while doing a test and just added. They likely don&#8217;t do a ton of
error checking.</p>
<table border="1" class="docutils">
<colgroup>
<col width="19%" />
<col width="10%" />
<col width="71%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Command</th>
<th class="head">Aliases</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">dump_response</span> <span class="pre">&lt;reqid&gt;</span> <span class="pre">[filename]</span></code></td>
<td><code class="docutils literal"><span class="pre">dump_response</span></code></td>
<td>Dumps the data from the response to the given filename (useful for images, .swf, etc). If no filename is given, it uses the name given in the path.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">export</span> <span class="pre">&lt;req|rsp&gt;</span> <span class="pre">&lt;reqid&gt;</span></code></td>
<td><code class="docutils literal"><span class="pre">export</span></code></td>
<td>Writes either the full request or response to a file in the current directory.</td>
</tr>
</tbody>
</table>
<div class="section" id="response-streaming">
<h3>Response streaming<a class="headerlink" href="#response-streaming" title="Permalink to this headline"></a></h3>
<p>If you don&#8217;t have any intercepting macros running, Pappy will forward
data to the browser as it gets it. However, if you&#8217;re trying to mangle
messages/responses, Pappy will need to download the entire message
first.</p>
</div>
</div>
<div class="section" id="plugins">
<h2>Plugins<a class="headerlink" href="#plugins" title="Permalink to this headline"></a></h2>
<p>Note that this section is a very quick overview of plugins. For a full
description of how to write them, please see <a class="reference external" href="https://roglew.github.io/pappy-proxy/pappyplugins.html">the official
docs</a>.</p>
<p>It is also possible to write plugins which are reusable across projects.
Plugins are simply Python scripts located in <code class="docutils literal"><span class="pre">~/.pappy/plugins</span></code>.
Plugins are able to create new console commands and maintain state
throughout a Pappy session. They can access the same API as macros, but
the plugin system is designed to allow you to create general purpose
commands as compared to macros which are meant to be project-specific
scripts. Still, it may not be a bad idea to try building a macro to do
something in a quick and dirty way before writing a plugin since plugins
are more complicated to write.</p>
<p>A simple hello world plugin could be something like:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">## hello.py</span>
<span class="kn">import</span> <span class="nn">shlex</span>
<span class="k">def</span> <span class="nf">hello_world</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
<span class="k">if</span> <span class="n">line</span><span class="p">:</span>
<span class="n">args</span> <span class="o">=</span> <span class="n">shlex</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="k">print</span> <span class="s">&#39;Hello, </span><span class="si">%s</span><span class="s">!&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">args</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">print</span> <span class="s">&quot;Hello, world!&quot;</span>
<span class="c">###############</span>
<span class="c">## Plugin hooks</span>
<span class="k">def</span> <span class="nf">load_cmds</span><span class="p">(</span><span class="n">cmd</span><span class="p">):</span>
<span class="n">cmd</span><span class="o">.</span><span class="n">set_cmds</span><span class="p">({</span>
<span class="s">&#39;hello&#39;</span><span class="p">:</span> <span class="p">(</span><span class="n">hello_world</span><span class="p">,</span> <span class="bp">None</span><span class="p">),</span>
<span class="p">})</span>
<span class="n">cmd</span><span class="o">.</span><span class="n">add_aliases</span><span class="p">([</span>
<span class="p">(</span><span class="s">&#39;hello&#39;</span><span class="p">,</span> <span class="s">&#39;hlo&#39;</span><span class="p">),</span>
<span class="p">(</span><span class="s">&#39;hello&#39;</span><span class="p">,</span> <span class="s">&#39;ho&#39;</span><span class="p">),</span>
<span class="p">])</span>
</pre></div>
</div>
<p>You can also create commands which support autocomplete:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">shlex</span>
<span class="n">_AUTOCOMPLETE_NAMES</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;alice&#39;</span><span class="p">,</span> <span class="s">&#39;allie&#39;</span><span class="p">,</span> <span class="s">&#39;sarah&#39;</span><span class="p">,</span> <span class="s">&#39;mallory&#39;</span><span class="p">,</span> <span class="s">&#39;slagathor&#39;</span><span class="p">]</span>
<span class="k">def</span> <span class="nf">hello_world</span><span class="p">(</span><span class="n">line</span><span class="p">):</span>
<span class="k">if</span> <span class="n">line</span><span class="p">:</span>
<span class="n">args</span> <span class="o">=</span> <span class="n">shlex</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="k">print</span> <span class="s">&#39;Hello, </span><span class="si">%s</span><span class="s">!&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;, &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">args</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">print</span> <span class="s">&quot;Hello, world!&quot;</span>
<span class="k">def</span> <span class="nf">complete_hello_world</span><span class="p">(</span><span class="n">text</span><span class="p">,</span> <span class="n">line</span><span class="p">,</span> <span class="n">begidx</span><span class="p">,</span> <span class="n">endidx</span><span class="p">):</span>
<span class="k">return</span> <span class="p">[</span><span class="n">n</span> <span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">_AUTOCOMPLETE_NAMES</span> <span class="k">if</span> <span class="n">n</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">text</span><span class="p">)]</span>
<span class="c">###############</span>
<span class="c">## Plugin hooks</span>
<span class="k">def</span> <span class="nf">load_cmds</span><span class="p">(</span><span class="n">cmd</span><span class="p">):</span>
<span class="n">cmd</span><span class="o">.</span><span class="n">set_cmds</span><span class="p">({</span>
<span class="s">&#39;hello&#39;</span><span class="p">:</span> <span class="p">(</span><span class="n">hello_world</span><span class="p">,</span> <span class="n">complete_hello_world</span><span class="p">),</span>
<span class="p">})</span>
<span class="n">cmd</span><span class="o">.</span><span class="n">add_aliases</span><span class="p">([</span>
<span class="p">(</span><span class="s">&#39;hello&#39;</span><span class="p">,</span> <span class="s">&#39;hlo&#39;</span><span class="p">),</span>
<span class="p">])</span>
</pre></div>
</div>
<p>Then when you run Pappy you can use the <code class="docutils literal"><span class="pre">hello</span></code> command:</p>
<div class="highlight-python"><div class="highlight"><pre>$ pappy -l
Temporary datafile is /tmp/tmpBOXyJ3
Proxy is listening on port 8000
pappy&gt; ho
Hello, world!
pappy&gt; ho foo bar baz
Hello, foo, bar, baz!
pappy&gt; ho foo bar &quot;baz lihtyur&quot;
Hello, foo, bar, baz lihtyur!
pappy&gt;
</pre></div>
</div>
<div class="section" id="should-i-write-a-plugin-or-a-macro">
<h3>Should I Write a Plugin or a Macro?<a class="headerlink" href="#should-i-write-a-plugin-or-a-macro" title="Permalink to this headline"></a></h3>
<p>A lot of the time, you can get away with writing a macro. However, you
may consider writing a plugin if:</p>
<ul class="simple">
<li>You find yourself copying one macro to multiple projects</li>
<li>You want to write a general tool that can be applied to any website</li>
<li>You need to maintain state during the Pappy session</li>
</ul>
<p>My guess is that if you need one quick thing for a project, you&#8217;re
better off writing a macro first and seeing if you end up using it in
future projects. Then if you find yourself needing it a lot, write a
plugin for it. You may also consider keeping a <code class="docutils literal"><span class="pre">mine.py</span></code> plugin where
you can write out commands that you use regularly but may not be worth
creating a dedicated plugin for.</p>
</div>
</div>
<div class="section" id="faq">
<h2>FAQ<a class="headerlink" href="#faq" title="Permalink to this headline"></a></h2>
<div class="section" id="i-still-like-burp-but-pappy-looks-interesting-can-i-use-both">
<h3>I still like Burp, but Pappy looks interesting, can I use both?<a class="headerlink" href="#i-still-like-burp-but-pappy-looks-interesting-can-i-use-both" title="Permalink to this headline"></a></h3>
<p>Yes! If you don&#8217;t want to go completely over to Pappy yet, you can
configure Burp to use Pappy as an upstream proxy server. That way,
traffic will go through both Burp and Pappy and you can use whichever
you want to do your testing.</p>
<p>How to have Burp forward traffic through Pappy:</p>
<ol class="arabic simple">
<li>Open Burp</li>
<li>Go to <code class="docutils literal"><span class="pre">Options</span> <span class="pre">-&gt;</span> <span class="pre">Connections</span> <span class="pre">-&gt;</span> <span class="pre">Upstream</span> <span class="pre">Proxy</span> <span class="pre">Servers</span></code></li>
<li>Click <code class="docutils literal"><span class="pre">Add</span></code></li>
<li>Leave <code class="docutils literal"><span class="pre">Destination</span> <span class="pre">Host</span></code> blank, but put <code class="docutils literal"><span class="pre">127.0.0.1</span></code> in
<code class="docutils literal"><span class="pre">Proxy</span> <span class="pre">Host</span></code> and <code class="docutils literal"><span class="pre">8000</span></code> into <code class="docutils literal"><span class="pre">Port</span></code> (assuming you&#8217;re using the
default listener)</li>
<li>Configure your browser to use Burp as a proxy</li>
</ol>
</div>
<div class="section" id="why-does-my-request-have-an-id-of">
<h3>Why does my request have an id of <code class="docutils literal"><span class="pre">--</span></code>?!?!<a class="headerlink" href="#why-does-my-request-have-an-id-of" title="Permalink to this headline"></a></h3>
<p>You can&#8217;t do anything with a request/response until it is decoded and
saved to disk. In between the time when a request is decoded and when
it&#8217;s saved to disk, it will have an ID of <code class="docutils literal"><span class="pre">--</span></code>. So just wait a little
bit and it will get an ID you can use.</p>
</div>
</div>
<div class="section" id="changelog">
<h2>Changelog<a class="headerlink" href="#changelog" title="Permalink to this headline"></a></h2>
<p>The boring part of the readme</p>
<ul class="simple">
<li>0.2.0<ul>
<li>Lots of refactoring</li>
<li>Plugins</li>
<li>Bugfixes probably</li>
<li>Change prompt to make Pappy look more professional (but it will
always be pappy time in your heart, I promise)</li>
<li>Create changelog</li>
<li>Add response streaming if no intercepting macros are active</li>
</ul>
</li>
<li>0.1.1<ul>
<li>Start using sane versioning system</li>
<li>Did proxy things</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">The Pappy Proxy</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#contributing">Contributing</a></li>
</ul>
</li>
<li><a class="reference internal" href="#how-to-use-it">How to Use It</a><ul>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#quickstart">Quickstart</a></li>
<li><a class="reference internal" href="#lite-mode">Lite Mode</a></li>
<li><a class="reference internal" href="#adding-the-ca-cert-to-your-browser">Adding The CA Cert to Your Browser</a><ul>
<li><a class="reference internal" href="#firefox">Firefox</a></li>
<li><a class="reference internal" href="#chrome">Chrome</a></li>
<li><a class="reference internal" href="#safari">Safari</a></li>
<li><a class="reference internal" href="#internet-explorer">Internet Explorer</a></li>
</ul>
</li>
<li><a class="reference internal" href="#configuration">Configuration</a></li>
<li><a class="reference internal" href="#generating-pappy-s-ca-cert">Generating Pappy&#8217;s CA Cert</a></li>
<li><a class="reference internal" href="#browsing-recorded-requests-responses">Browsing Recorded Requests/Responses</a></li>
<li><a class="reference internal" href="#tags">Tags</a></li>
<li><a class="reference internal" href="#request-ids">Request IDs</a><ul>
<li><a class="reference internal" href="#passing-multiple-request-ids-to-a-command">Passing Multiple Request IDs to a Command</a></li>
</ul>
</li>
<li><a class="reference internal" href="#context">Context</a></li>
<li><a class="reference internal" href="#filter-strings">Filter Strings</a><ul>
<li><a class="reference internal" href="#list-of-fields">List of fields</a></li>
<li><a class="reference internal" href="#list-of-comparers">List of comparers</a></li>
<li><a class="reference internal" href="#special-form-filters">Special form filters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#scope">Scope</a><ul>
<li><a class="reference internal" href="#built-in-filters">Built-In Filters</a></li>
</ul>
</li>
<li><a class="reference internal" href="#interceptor">Interceptor</a></li>
<li><a class="reference internal" href="#repeater">Repeater</a></li>
<li><a class="reference internal" href="#macros">Macros</a><ul>
<li><a class="reference internal" href="#generating-macros-from-requests">Generating Macros From Requests</a></li>
<li><a class="reference internal" href="#request-objects">Request Objects</a></li>
<li><a class="reference internal" href="#useful-functions">Useful Functions</a></li>
</ul>
</li>
<li><a class="reference internal" href="#intercepting-macros">Intercepting Macros</a><ul>
<li><a class="reference internal" href="#enabling-disabling-intercepting-macros">Enabling/Disabling Intercepting Macros</a></li>
</ul>
</li>
<li><a class="reference internal" href="#logging">Logging</a></li>
<li><a class="reference internal" href="#additional-commands-and-features">Additional Commands and Features</a><ul>
<li><a class="reference internal" href="#response-streaming">Response streaming</a></li>
</ul>
</li>
<li><a class="reference internal" href="#plugins">Plugins</a><ul>
<li><a class="reference internal" href="#should-i-write-a-plugin-or-a-macro">Should I Write a Plugin or a Macro?</a></li>
</ul>
</li>
<li><a class="reference internal" href="#faq">FAQ</a><ul>
<li><a class="reference internal" href="#i-still-like-burp-but-pappy-looks-interesting-can-i-use-both">I still like Burp, but Pappy looks interesting, can I use both?</a></li>
<li><a class="reference internal" href="#why-does-my-request-have-an-id-of">Why does my request have an id of <code class="docutils literal"><span class="pre">--</span></code>?!?!</a></li>
</ul>
</li>
<li><a class="reference internal" href="#changelog">Changelog</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Welcome to Pappy Proxy&#8217;s documentation!</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="tutorial.html"
title="next chapter">The Pappy Proxy Tutorial</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/overview.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="tutorial.html" title="The Pappy Proxy Tutorial"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to Pappy Proxy’s documentation!"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Pappy Proxy 0.2.0 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&copy; Copyright 2015, Rob Glew.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.3.
</div>
</body>
</html>