Ruby MITM proxy

假如想象 提交于 2019-12-22 18:02:44

问题


I'm searching for some examples on how to write a proxy in Ruby that supports HTTPS. I have a simple proxy implemented with Webricks HTTPProxyServer, but I noticed, that HTTPS traffic is just tunneling (as it should ;) ). But I want to record the content with VCR (regarding my question here VCRProxy: Record PhantomJS ajax calls with VCR inside Capybara) and as long the content is only tunnled through, VCR can't record it.

So I was thinking of writing the proxy as a man-in-the-middle, generate SSL certificates on the fly (I don't care about certificate errors, its just for testing), and then I would be able to record the content / playback it later.

So if somebody has a good ressource from how to start, or a tutorial or a gist, please let me know.

PS: I have already seen this questions, but they don't provide any further stuff (and it need to be in ruby):

  • Man in the Middle (MITM) proxy with HTTPS support
  • How do I write a simple HTTPS proxy server in Ruby?
  • Help with HTTP Intercepting Proxy in Ruby?

回答1:


An old question, but for the sake of completeness here goes another answer.

I've implemented a HTTP/HTTPS interception proxy in Ruby, the project is hosted in github.

The project is new, so it's not (yet) as mature as Python's mitmproxy, but it supports HTTPS with certificates generation on-the-fly.




回答2:


There's an excellent MITM proxy in Python aptly named mitmproxy. The netlib library by the author does the tricks and mitmproxy uses it.

The codebase isn't large and it shouldn't be hard to go through it given that you know Ruby.



来源:https://stackoverflow.com/questions/13476639/ruby-mitm-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!