Dan*_*Dan 5 python python-3.x mitmproxy
我最终将我的Python版本从2.7升级到3.6.1,并且还将我mitmproxy从旧的和好的v0.16升级到最新的版本.
我曾经使用libmproxy过这种语法来操纵通过代理转移的请求:
from netlib.http import decoded
from libmproxy import controller, proxy
from libmproxy.proxy.server import ProxyServer
class StickyMaster(controller.Master):
def __init__(self, server):
controller.Master.__init__(self, server)
self.stickyhosts = {}
def run(self):
try:
return controller.Master.run(self)
except KeyboardInterrupt:
self.shutdown()
def handle_request(self, flow):
flow.reply()
def handle_response(self, flow):
with decoded(flow.response):
<DO SOMETHING>
flow.reply()
config = proxy.ProxyConfig(port=8081)
server = ProxyServer(config)
m = StickyMaster(server)
m.run()
Run Code Online (Sandbox Code Playgroud)
我知道在新版本中语法完全不同,我找不到相关文档,并举例说明如何做到这一点.
任何人都可以与我分享一个基本代码的例子,比如我上面写的最新版本?
我们已弃用“libmproxy 子类化”方法,并采用更灵活的插件实现。事实上,mitmproxy 的大部分核心功能本身都是作为插件实现的。所以简短的答案是:写一个插件!
我们在http://docs.mitmproxy.org/en/stable/scripting/overview.html提供了插件开发的介绍。对于代码示例,您还应该查看https://github.com/mitmproxy/mitmproxy/tree/master/examples/simple。
| 归档时间: |
|
| 查看次数: |
1300 次 |
| 最近记录: |