Class: PWN::Plugins::MitmProxy::Server
- Inherits:
-
WEBrick::HTTPProxyServer
- Object
- WEBrick::HTTPProxyServer
- PWN::Plugins::MitmProxy::Server
- Defined in:
- lib/pwn/plugins/mitm_proxy.rb
Overview
WEBrick owns socket parsing, framing, concurrency and CONNECT transport.
Instance Method Summary collapse
Instance Method Details
#proxy_service(req, res) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pwn/plugins/mitm_proxy.rb', line 23 def proxy_service(req, res) entry = MitmProxy.exchange(proxy: @config[:PWNSession], request: { method: req.request_method, url: req.request_uri.to_s, headers: req.header.transform_values { |v| v.join(', ') }, body: req.body.to_s }) res.status = entry[:response][:status] entry[:response][:headers].each do |h| if h[:name] == 'set-cookie' res. << h[:value] else res[h[:name]] = h[:value] end end content = entry[:response][:content] res.body = content[:encoding] == 'base64' ? Base64.strict_decode64(content[:text]) : content[:text] rescue StandardError => e res.status = 502 res.body = "#{e.class}: #{e.message}" end |