[英]Bypass proxy and capture webpage data from server using HTTP GET request using mitmproxy in Python
我需要使用mitmproxy繞過代理,並使用GET請求捕獲Web數據。 我正在使用Windows 7和python 2.7和mitmproxy python
我嘗試了以下代碼:
#!/usr/bin/env python
"""
This example shows how to build a proxy based on mitmproxy's Flow
primitives.
Note that request and response messages are not automatically replied to,
so we need to implement handlers to do this.
"""
import sys,os
import os
import cStringIO
import threading
import thread
import exceptions
import gc
from libmproxy import proxy, flow
from libmproxy.proxy import config
from libmproxy.proxy import server
from libmproxy.proxy.server import ProxyServer
from libmproxy.platform.windows import TransparentProxy
class MyMaster(flow.FlowMaster):
def run(self):
try:
flow.FlowMaster.run(self)
except KeyboardInterrupt:
self.shutdown()
def responseheaders(context, flow):
ct = flow.response.headers["Content-Type"]
if ct and len(ct) > 0 and ct[0].startswith("application/"):
flow.stream = True
print "streaming"
def handle_request(self, r):
print r
f = flow.FlowMaster.handle_request(self, r)
if f:
def run():
r.reply()
return f
threading.Thread(target=run).start()
else:
return null
def handle_response(self, r):
f = flow.FlowMaster.handle_response(self, r)
if f:
def run():
r.reply()
return f
threading.Thread(target=run).start()
else:
return null
config = proxy.config.ProxyConfig(
#ca_file=os.path.expanduser("~\.mitmproxy\mitmproxy-ca.pem")
confdir=os.path.realpath('.\\conf')#, mode="transparent"
)
gc.enable()
gc.set_threshold(250, 10, 10)
print gc.get_threshold()
state = flow.State()
server = ProxyServer(config, 8080)
#server = TransparentProxy()
m = MyMaster(server, state)
TransparentProxy().setup()
#proxifier = TransparentProxy()
#proxifier.start()
print "got here"
m.run();
但是出現了一些錯誤:
confdir=os.path.realpath(r'C:\Users\rnive\Documents\certificates') ``#,mode="transparent"
TypeError: __init__() got an unexpected keyword argument 'confdir'
有關糾正此錯誤的任何幫助。 通過雙擊mitmproxy-ca-cert.p12文件導入mitmproxy CA,並將mitm.it加載到chrome瀏覽器中,得到的內容如下:
如果您看到此消息,則表明流量未通過mitmproxy。
關於如何配置和糾正TypeError的任何幫助!
在瀏覽器中檢查代理設置。 錯誤消息“ ...流量未通過mitmproxy”應該消失。 在Firefox中,轉到選項|高級|網絡|設置。 另請參閱此處 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.