Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > afa0e7c59554a6ec33ced1a95f14102d > files > 236

mitmproxy-0.9.2-4.mga4.noarch.rpm

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta  content="text/html; charset=utf-8" http-equiv="Content-Type"/>


<link  href="../01-bootstrap.min.css" type="text/css" rel="StyleSheet"/>
<link  href="../02-docstyle.css" type="text/css" rel="StyleSheet"/>
<link  href="../syntax.css" type="text/css" rel="StyleSheet"/>
<title>mitmproxy 0.9 - Client playback: a 30 second example</title></head><body><div class="navbar navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>
      <a class="brand" href="../index.html">mitmproxy 0.9 docs</a>
      </div><!--/.nav-collapse -->
    </div>
  </div>
</div>

<div class="container">
  <div class="row">
    <div class="span3">
      <div class="well sidebar-nav">
        <ul class="nav nav-list">
            <li><a href="../index.html">Introduction</a></li>
            <li><a href="../install.html">Installation</a></li>
            <li><a href="../howmitmproxy.html">How mitmproxy works</a></li>

            <li class="nav-header">Tools</li>
                <li><a href="../mitmproxy.html">mitmproxy</a></li>
                <li><a href="../mitmdump.html">mitmdump</a></li>

            <li class="nav-header">Features</li>
                <li><a href="../features/anticache.html">Anticache</a></li>
                <li><a href="../features/clientreplay.html">Client-side replay</a></li>
                <li><a href="../features/filters.html">Filter expressions</a></li>
                <li><a href="../features/proxyauth.html">Proxy Authentication</a></li>
                <li><a href="../features/replacements.html">Replacements</a></li>
                <li><a href="../features/serverreplay.html">Server-side replay</a></li>
                <li><a href="../features/setheaders.html">Set Headers</a></li>
                <li><a href="../features/sticky.html">Sticky cookies and auth</a></li>
                <li><a href="../features/reverseproxy.html">Reverse proxy mode</a></li>
                <li><a href="../features/upstreamcerts.html">Upstream Certs</a></li>

            <li class="nav-header">Installing Certificates</li>
                <li><a href="../ssl.html">Overview</a></li>
                <li><a href="../certinstall/firefox.html">Firefox</a></li>
                <li><a href="../certinstall/osx.html">OSX</a></li>
                <li><a href="../certinstall/windows7.html">Windows 7</a></li>
                <li><a href="../certinstall/ios.html">IOS</a></li>
                <li><a href="../certinstall/ios-simulator.html">IOS Simulator</a></li>
                <li><a href="../certinstall/android.html">Android</a></li>

            <li class="nav-header">Transparent Proxying</li>
                <li><a href="../transparent.html">Overview</a></li>
                <li><a href="../transparent/linux.html">Linux</a></li>
                <li><a href="../transparent/osx.html">OSX</a></li>

             <li class="nav-header">Tutorials</li>
                <li class="active"><a href="30second.html">Client playback: a 30 second example</a></li>
                <li><a href="gamecenter.html">Setting highscores on Apple's GameCenter</a></li>

            <li class="nav-header">Scripting mitmproxy</li>
                <li><a href="../scripting/inlinescripts.html">Inline Scripts</a></li>
                <li><a href="../scripting/libmproxy.html">libmproxy</a></li>

            <li class="nav-header">Hacking</li>
                <li><a href="../dev/testing.html">Testing</a></li>

        </ul>
      </div>
    </div>

    <div class="span9">
        <div class="page-header">
        <h1>Client playback: a 30 second example</h1>
        </div>
        <p>My local cafe is serviced by a rickety and unreliable wireless network,
generously sponsored with ratepayers' money by our city council. After
connecting, you  are redirected to an SSL-protected page that prompts you for a
username and password. Once you've entered your details, you are free to enjoy
the intermittent dropouts, treacle-like speeds and incorrectly configured
transparent proxy. </p>

<p>I tend to automate this kind of thing at the first opportunity, on the theory
that time spent now will be more than made up in the long run. In this case, I
might use <a href="http://getfirebug.com/">Firebug</a> to ferret out the form post
parameters and target URL, then fire up an editor to write a little script
using Python's <a href="http://docs.python.org/library/urllib.html">urllib</a> to simulate
a submission. That's a lot of futzing about. With mitmproxy we can do the job
in literally 30 seconds, without having to worry about any of the details.
Here's how.</p>

<h2>1. Run mitmdump to record our HTTP conversation to a file.</h2>

<pre class="terminal">
> mitmdump -w wireless-login
</pre>

<h2>2. Point your browser at the mitmdump instance.</h2>

<p>I use a tiny Firefox addon called <a href="https://addons.mozilla.org/en-us/firefox/addon/toggle-proxy-51740/">Toggle
Proxy</a> to
switch quickly to and from mitmproxy. I'm assuming you've already <a href="http://mitmproxy.org/doc/ssl.html">configured
your browser with mitmproxy's SSL certificate
authority</a>.</p>

<h2>3. Log in as usual.</h2>

<p>And that's it! You now have a serialized version of the login process in the
file wireless-login, and you can replay it at any time like this:</p>

<pre class="terminal">
> mitmdump -c wireless-login
</pre>

<h2>Embellishments</h2>

<p>We're really done at this point, but there are a couple of embellishments we
could make if we wanted. I use <a href="http://wicd.sourceforge.net/">wicd</a> to
automatically join wireless networks I frequent, and it lets me specify a
command to run after connecting. I used the client replay command above and
voila! - totally hands-free wireless network startup.</p>

<p>We might also want to prune requests that download CSS, JS, images and so
forth. These add only a few moments to the time it takes to replay, but they're
not really needed and I somehow feel compelled to trim them anyway. So, we fire up
the mitmproxy console tool on our serialized conversation, like so:</p>

<pre class="terminal">
> mitmproxy -r wireless-login
</pre>

<p>We can now go through and manually delete (using the <strong>d</strong> keyboard shortcut)
everything we want to trim. When we're done, we use <strong>w</strong> to save the
conversation back to the file.</p>

    </div>
  </div>

  <hr>

  <footer>
    <p>© mitmproxy project, 2013</p>
  </footer>
</div>
</body></html>