Seeking help on how to dump flows and start mitmproxy all from a script
See original GitHub issueSteps to reproduce the problem:
Not an issue. I am failing to understand how i can start the proxy from a script, and then write any flows on a file. Here is my script so far. Script is a put together form various script ideas by googling around. didnt want to create an issue, but couldnt really get in help on twitter/slack/irc etc. I understand this is simper to do using subprocess, but i am not trying to use subprocess
import os
import sys
from mitmproxy import http
# from mitmproxy.master import Master
import mitmproxy.master as master
from mitmproxy.addons import core
from mitmproxy.proxy import ProxyConfig, ProxyServer
from mitmproxy.options import Options
from mitmproxy import io, http
class Writer(master.Master, http.HTTPFlow):
def __init__(self, options, server, file_path):
master.Master.__init__(self, options)
self.server = server
self.file_path = file_path
self.f = open(self.file_path, 'wb+')
self.w = io.FlowWriter(self.f)
def run(self):
try:
master.Master.run(self)
except KeyboardInterrupt:
self.shutdown()
sys.exit(0)
def writestuff(self):
flo = http.HTTPFlow
print(flo)
self.w.add(flo)
def start_proxy(port, file_path):
options = Options(
listen_port=port,
)
config = ProxyConfig(
options=options,
)
server = ProxyServer(config)
# print(dir(http.HTTPFlow))
m = Writer(options, server, file_path)
m.addons.add(core.Core())
m.run()
m.writestuff()
start_proxy(8080, '/tmp/dumptest')
System information
Mitmproxy: 4.0.4 Python: 3.7.0 OpenSSL: OpenSSL 1.1.0h 27 Mar 2018 Platform: Darwin-16.7.0-x86_64-i386-64bit
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Examples - mitmproxy docs
Enable response streaming for all HTTP flows. ... This script demonstrates how to generate a mitmproxy dump file, as it would also be...
Read more >Mitmproxy how to launch from script, and save dumps to file
Issue is, this creates an error AttributeError: No such option: body_size_limit which seems to be mitigated with master.addons.add(core.Core) ...
Read more >Mitmproxy Cheat Sheet & Quick Reference - QuickRef.ME
mitmproxy is a free and open source interactive HTTPS proxy. This is a quick reference cheat sheet to the mitmproxy.
Read more >Inline Scripts - Introduction — mitmproxy 0.18 documentation
mitmproxy has a powerful scripting API that allows you to modify flows on-the-fly or rewrite previously saved flows locally. All events that deal...
Read more >Mitmproxy Cheat Sheet - stut-it Martin Stut
When starting to use Mitmproxy (see also my blog post about setting it ... d, delete flow ... w, save all flows matching...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This worked for me: (remove
mode='transparent'
, if you dont want to run mitmproxy in transparent mode)Another alternative without subprocess, but probably not what you want:
Using this way, it works. Cool~~~