Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intercepting and manipulating HTTP POST Request

I have a privacy issue with a web-app that I use. It runs a flash script that is grabbing a screen capture and then submitting it to a server at a specific interval. I have successfully intercepted the HTTP POST request but I wish to manipulate this to return a blank image.

I've figured out how to capture the HTTP request in Firebug and I can capture/break on the event in Fiddler. Fiddler even allows me to submit a modified POST command (but I can only figure out how to do this manually and the web-app breaks if it doesn't receive this POST in time.) Is there a tool or script that I can use to modify this post request in the browser? I don't see Greasemonkey working since the HTTP request is being generated by an SWF file.

like image 436
spazzed Avatar asked Sep 03 '26 06:09

spazzed


1 Answers

Fiddler has also a script language that allows to automate modification certain requests or responses.

The fiddler script is saved by default in Fiddler2\Scripts\CustomRules.js inside your my documents directory.

A simple script would like this:

static function OnBeforeResponse(oSession: Session) {

    if ((oSession.hostname == "example.org") && (oSession.PathAndQuery=="/path/myServlet")) {
      oSession.utilDecodeResponse();
      var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
      oBody = oBody.replace("text to be replaced", "replaced text");
      oSession.utilSetResponseBody(oBody);

      //Prevent caching of response
      oSession.oResponse.headers.Remove("ETag");
      oSession.oResponse.headers.Remove("Last-Modified");
      oSession.oResponse["Cache-Control"] = "nocache";
    }
}

For further samples visit http://www.fiddler2.com/fiddler/dev/scriptsamples.asp

like image 71
Robert Avatar answered Sep 07 '26 13:09

Robert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!