仅更改特定请求 mitmproxy
我有一个想要利用的程序。我已经看到(通过 burp suite),当它打开时,它会向服务器发出请求,并根据服务器的答案,它会执行多项操作。问题是我想编辑这个请求。我想创建一个代理(我已经看到 mitmproxy 可以满足我的需求,但如果您有其他建议,请随时发布),该代理“通过”除我想要的之外的所有 http 请求。对于这个“特殊”请求,它所需要做的就是给出自定义响应。我给你举个例子。该程序向 google.com 发出了 10 个请求,我想让这个请求来回传递,而不是向 example.org 发出一个特殊请求,而 example.org 会用“OK”回答该请求。我想把这个答案改为“错误”。有办法做到这一点吗?我见过类似的东西,但没有见过这样的。你能帮助我吗? PS 我知道如何用 python 编程,所以如果你链接我一篇文章就更好了! 祝你今天过得愉快!
编辑: 我编写了这个在线复制的简单代码,但它似乎不起作用...
from mitmproxy import http
def response(self, flow: http.HTTPFlow) -> None:
if flow.response and flow.response.content:
flow.response.content = flow.response.content.replace(
b"</head>",
b"<style>body {transform: scaleX(-1);}</style></head>"
)
我用 mitmproxy -s main.py 注入它 我做错了什么吗?
I have a program I'd like to exploit. I have seen (through burp suite) that when it opens it does a request to a server and depending on the answer of the server it does multiple things. The thing is that I'd like to edit this request. I'd like to create a proxy (I have seen mitmproxy can fit my needs but if you have other suggestions feel free to post them), that "passtrough" all the http request except for the one I'd like. On this "special" request all it needs to do is give a custom response. I'm making you an example. The program does 10 request to google.com, I'd like to let this request pass back and forth, than it does one special request to example.org and example.org answer this request with "OK". I'd like to change this answer to "Wrong". Is there a way to do this? I have seen something similar but nothing like this. Can you help me?
P.S. I know how to program in python so if you link me an article is more than fine!
Have a nice day!
Edit:
I wrote this simple code i copied online but it doesn't seem to work...
from mitmproxy import http
def response(self, flow: http.HTTPFlow) -> None:
if flow.response and flow.response.content:
flow.response.content = flow.response.content.replace(
b"</head>",
b"<style>body {transform: scaleX(-1);}</style></head>"
)
I inject this with mitmproxy -s main.py
Am i doing something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论