Skip to content

Commit

Permalink
Start a fuzzing architecture for mitmproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
cortesi committed Oct 26, 2014
1 parent 35075a3 commit efd6fdb
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 9 deletions.
11 changes: 7 additions & 4 deletions libmproxy/dump.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import absolute_import
import sys, os
import sys
import os
import netlib.utils
from . import flow, filt, utils
from .protocol import http

class DumpError(Exception): pass

class DumpError(Exception):
pass


class Options(object):
Expand Down Expand Up @@ -37,6 +40,7 @@ class Options(object):
"replay_ignore_content",
"replay_ignore_params",
]

def __init__(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
Expand Down Expand Up @@ -71,7 +75,7 @@ def __init__(self, server, options, outfile=sys.stdout):
self.anticache = options.anticache
self.anticomp = options.anticomp
self.showhost = options.showhost
self.replay_ignore_params = options.replay_ignore_params
self.replay_ignore_params = options.replay_ignore_params
self.replay_ignore_content = options.replay_ignore_content
self.refresh_server_playback = options.refresh_server_playback

Expand All @@ -88,7 +92,6 @@ def __init__(self, server, options, outfile=sys.stdout):
if options.stickyauth:
self.set_stickyauth(options.stickyauth)


if options.wfile:
path = os.path.expanduser(options.wfile)
try:
Expand Down
2 changes: 1 addition & 1 deletion libmproxy/proxy/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ def handle_sni(self, connection):
# make dang sure it doesn't happen.
except: # pragma: no cover
import traceback
self.log("Error in handle_sni:\r\n" + traceback.format_exc(), "error")
self.log("Error in handle_sni:\r\n" + traceback.format_exc(), "error")
6 changes: 6 additions & 0 deletions test/fuzzing/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

MITMDUMP=../../mitmdump
PATHOD=../../../pathod/pathod
PATHOC=../../../pathod/pathoc
FUZZ_SETTINGS=-remTt 1 -n 0 -I 200,400,405,502

14 changes: 14 additions & 0 deletions test/fuzzing/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

A fuzzing architecture for mitmproxy
====================================

Quick start:

honcho -f ./straight_stream start


Notes:

- Processes are managed using honcho (pip install honcho)
- Paths and common settings live in .env

4 changes: 4 additions & 0 deletions test/fuzzing/client_patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
get:'http://localhost:9999/p/200':ir,"\n"
get:'http://localhost:9999/p/200':ir,"\0"
get:'http://localhost:9999/p/200':ir,@5
get:'http://localhost:9999/p/200':dr
15 changes: 11 additions & 4 deletions test/fuzzing/go_proxy
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
# mitmproxy/mitmdump is running on port 8080 in straight proxy mode.
# pathod is running on port 9999

BASE_HTTP="/Users/aldo/git/public/pathod/pathoc -Tt 1 -eo -I 200,400,405,502 -p 8080 localhost "
BASE="../../../"
BASE_HTTP=$BASE"/pathod/pathoc -Tt 1 -e -I 200,400,405,502 -p 8080 localhost "
BASE_HTTPS=$BASE"/pathod/pathoc -sc localhost:9999 -Tt 1 -eo -I 200,400,404,405,502,800 -p 8080 localhost "

#$BASE_HTTP -n 10000 "get:'http://localhost:9999':ir,@1"
#$BASE_HTTP -n 100 "get:'http://localhost:9999':dr"
#$BASE_HTTP -n 10000 "get:'http://localhost:9999/p/200:ir,@300.0
#$BASE_HTTP -n 10000 "get:'http://localhost:9999/p/200':ir,@300"

#$BASE_HTTP -n 10000 "get:'http://localhost:9999/p/200:ir,@1'"
#$BASE_HTTP -n 100 "get:'http://localhost:9999/p/200:dr'"
#$BASE_HTTP -n 10000 "get:'http://localhost:9999/p/200:ir,@100'"


# Assuming:
# mitmproxy/mitmdump is running on port 8080 in straight proxy mode.
# pathod with SSL enabled is running on port 9999

BASE_HTTPS="/Users/aldo/git/public/pathod/pathoc -sc localhost:9999 -Tt 1 -eo -I 200,400,404,405,502,800 -p 8080 localhost "
$BASE_HTTPS -en 10000 "get:'/p/200:b@10:ir,@1'"
#$BASE_HTTPS -en 10000 "get:'/p/200:b@100:ir,@1'"
#$BASE_HTTPS -en 10000 "get:'/p/200:ir,@1'"

#$BASE_HTTPS -n 100 "get:'/p/200:dr'"
#$BASE_HTTPS -n 10000 "get:'/p/200:ir,@3000'"
#$BASE_HTTPS -n 10000 "get:'/p/200:ir,\"\\n\"'"

9 changes: 9 additions & 0 deletions test/fuzzing/reverse_patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
get:'/p/200':b@10:ir,"\n"
get:'/p/200':b@10:ir,"\r\n"
get:'/p/200':b@10:ir,"\0"
get:'/p/200':b@10:ir,@5
get:'/p/200':b@10:dr

get:'/p/200:b@10:ir,@1'
get:'/p/200:b@10:dr'
get:'/p/200:b@10:ir,@100'
4 changes: 4 additions & 0 deletions test/fuzzing/straight_stream
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

mitmdump: $MITMDUMP -q --stream 1
pathod: $PATHOD -q
pathoc: sleep 2 && $PATHOC $FUZZ_SETTINGS localhost:8080 ./straight_stream_patterns
5 changes: 5 additions & 0 deletions test/fuzzing/straight_stream_patterns
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
get:'http://localhost:9999/p/':s'200:b"foo"':ir,'\n'
get:'http://localhost:9999/p/':s'200:b"foo"':ir,'a'
get:'http://localhost:9999/p/':s'200:b"foo"':ir,'9'
get:'http://localhost:9999/p/':s'200:b"foo"':ir,':'
get:'http://localhost:9999/p/':s'200:b"foo"':ir,'"'

0 comments on commit efd6fdb

Please sign in to comment.