如何将mitmproxy连接到我控制之外的另一个代理?

时间:2014-03-06 09:14:29

标签: python proxy mitmproxy libmproxy

该过程将是浏览器向MITMproxy发送请求,然后生成发送到不受我们控制的目标代理服务器的请求。代理服务器将向MITMproxy发送响应,然后该响应将该响应转发给浏览器。

我将如何做到这一点?

4 个答案:

答案 0 :(得分:5)

您可以使用-F标志进行mitmproxy,它会将代理请求转发到上游服务器。看看这里的文档:

http://mitmproxy.org/doc/features/forwardproxy.html

答案 1 :(得分:1)

通过以下内容,我能够实现您的要求。您需要启用上游模式和上游身份验证(如果您的代理有一些用户名/密码):

Dim LastCell As Range: Set LastCell = Destination.Offset(9, 12).End(xlDown) 'Last cell of
'the amort schedule, should be 0 or close to it at end of term. Destination is a named cell,
'I'm getting better at avoiding ActiveCell!

Dim PV1 As Double: PV1 = Destination.Offset(0, 12) '2440754.76
Dim PV2 As Double: PV2 = Destination.Offset(1, 12) '2400379.97 This is the value in my 
'current scenario that I need, but it may not always be the case
Dim PV3 As Double: PV3 = Destination.Offset(2, 12) '2429942.76

Dim UseCalc As Range: Set UseCalc = Destination.Offset(9, 12) 'First cell of the amort schedule

Do Until (LastCell.Value >= -1 And LastCell.Value <= 1)
    UseCalc = PV1
    UseCalc = PV2 'When it gets to this point, I can see the value in LastCell
    'becomes 1.0000000000001839362E-02 which SHOULD trip the between -1 and 1 threshold,
    'but I'm sure something in the variables I'm setting are going wacky
    UseCalc = PV3
Loop

然后您可以使用简单的mitmproxy --mode upstream:https://HOSTNAME:PORT --upstream-auth USER:PASSWORD 来检查它是否正常工作:

curl

这会将您的请求转发到curl -x http://localhost:8080 -k https://api.ipify.org/ ,后者会将其转发到您的其他代理。

希望有帮助!

答案 2 :(得分:0)

如果您不想从脚本执行此操作,可以使用server.config中的get_upstream_server更改上游服务器,请参阅[mitmproxy config](https://github.com/mitmproxy/mitmproxy/blob/42d4a2fae96b8b4ba35d3a88e20f278d79a0ccc6/libmproxy/proxy.py)。例如:

self.server.config.get_upstream_server = proxy.ConstUpstreamServerResolver(cmdline.parser_server_spec("http://upstreamserver:port"))

答案 3 :(得分:0)

我认为这是-U选项:

command-line    -U http://hostname[:port]

来源:spread syntax