Comments (2)
This is definitely possible but not from the command line. You'll have to write a script that hooks into the request or response callback functions. For example, say you wanted to replace the entire response for every response going to the proxy client. You could write a response call back such as:
def response(context, fl):
flread = flow.FlowReader(open('/tmp/response.flow', 'r'))
flstream = flread.stream()
flreplace = flstream.next()
fl.response._load_state(flreplace.response._get_state())
This will replace the entire state of the response with pre-recorded flow for every response. If you want to just override the content you can replace fl.response.content with some predetermed content. The only caveat is that the pre-recorded flow must be in the tnetstring format used by mitmproxy. You can either record the flow with mitmproxy or if you have a pcap file you can use mitmextract to extract and convert the flow.
Hope this helps.
from mitmproxy.
cjneasbi's solution is the right way for now. Down the track, we may add some utility feature to make this easier, but I'm closing this issue for now.
from mitmproxy.
Related Issues (20)
- ignore_hosts and allow_hosts not working as documented HOT 2
- Is there any way to decode this code? HOT 1
- BYPASSING SSL pinning by fake hashes
- https://archive.is doesn't load through mitmproxy, hangs when waiting for server response HOT 5
- Intercepting "Automation Vault" HOT 3
- mitmproxy saves failed CONNECT request URLs to HAR files incorrectly HOT 6
- install fails with github version of cpython and pip HOT 4
- mitmproxy: 10.2: WireGuard Mode Does Not Receive Connections HOT 2
- Google Summer of Code 2024 HOT 2
- Binary doesn't run on Mac M1 (silicon) HOT 2
- When using the mitmproxy proxy to intercept streaming traffic, the live video is not being displayed. For example, when capturing live broadcasts from Douyin (TikTok).
- Loop with websites using cloudflare HOT 5
- Provide Linux Arm64 binaries HOT 3
- Constant exceptions in callback StreamReaderProtocol.connection_made... at asyncio.streams.py when using transparent mode HOT 8
- `Couldn't parse: falling back to Raw` for empty JSON array HOT 4
- AttributeError: 'ClientPlayback' object has no attribute 'options' HOT 2
- Mitmdump: invalid mode specification HOT 3
- QUIC Connection Migration HOT 3
- mitmproxy crashed error after application connects to a websocket
- mitmdump can't handle example.com? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mitmproxy.