2

I am using MITM proxy to inject javascript code to traffic passing through the proxy. For now I am checking content-type of header to be text/html, The problem I am facing is that on a single page there are multiple resources which have content-type as text/html so my javascript code is getting injected multiple times to the page.

How can I prevent this ?

Thanks in advance !

bitgeeky
  • 319
  • 1
  • 4
  • 15
  • Actually the question could be more HTTP specific, I know that I can filter content using the regex and inline scripts. But I am particularly interested in knowing what exactly should I look for in the request so that I can prevent this situation. – bitgeeky May 23 '15 at 21:18

1 Answers1

1

MITM proxy supports regex filter expressions to restrict the flows that you interact with. You can filter against specific parts of the request/request, such as the request URL or response headers.

You should set a filter that matches only the resource you want to alter.

For example, ~bs Page \d matches against the response body and ~u http:\/\/mysite\.com\/resource\..+ matches the request URL.

Hit i in the mitmproxy app to enter a filter expression.

See this blog post and the filter expression docs for more detail.

joews
  • 29,767
  • 10
  • 79
  • 91
  • Hey @joews Thanks ! Actually the question could be more HTTP specific, I know that I can filter content using the regex and inline scripts. But I am particularly interested in knowing what exactly should I look for in the request so that I can prevent this situation. Added this to original question as a comment so that its more clear. – bitgeeky May 23 '15 at 21:19