Giter VIP home page Giter VIP logo

Comments (2)

cjneasbi avatar cjneasbi commented on May 21, 2024 1

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.

cortesi avatar cortesi commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.