Skip to content

Instantly share code, notes, and snippets.

Last active April 18, 2023 21:36
  • Star 29 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Read a mitmproxy dump file and generate a curl command
#!/usr/bin/env python
# Simple script showing how to read a mitmproxy dump file
### UPD: this feature is now avaiable in mitmproxy:
from libmproxy import flow
import json, sys
with open("mitmproxy_dump.txt", "rb") as logfile:
freader = flow.FlowReader(logfile)
for f in
request = f.request
curl = 'curl -X ' + request.method + ' -d \'' + request.content + '\' ' + ' '.join(['-H ' + '"' + header[0] + ': ' + header[1] + '"' for header in request.headers])
curl += " https://" + + request.path
except flow.FlowReadError as v:
print("Flow file corrupted. Stopped loading.")
Copy link

michaelschem commented Jan 5, 2017

I'm trying to get this script installed and I am not sure what I am doing wrong. I get the following error.

Traceback (most recent call last):
File "./", line 8, in <module>
from libmproxy import flow
File "/usr/lib/python2.7/dist-packages/libmproxy/", line 15, in <module>
from netlib.http import CONTENT_MISSING, Headers, http1
ImportError: cannot import name CONTENT_MISSING

I have tried installing netlib with pip

pip install netlib

and by cloning from the git repo and installing

git clone
cd netlib
sudo python install

neither are working. is there something else I need to do to get this script to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment