Using fiddler to switch/filter specific text on a live page.

112 views
Skip to first unread message

EvashB

unread,
Apr 3, 2009, 5:34:46 PM4/3/09
to Fiddler
Eric,

I have already written a C# extension that loads in a Excel document
and compares the URL's in the excel document to the URL's fired in
fiddler. So I have a little bit of knowledge of how to tie into the
fiddler session list and what not.

My question is there any way, when a page loads to search through the
pages source text and replace certain lines in it, then continue
loading the page with the updated text? I have read the thread on
"injecting tags to the HTML", and have stalked around the cook book. I
tired to take the code form the injecting tags thread but still wasn't
able to get/find and replace the pages code. Some of the cookbook code
sample seemed to have promise, but none that I used worked for what I
was trying to doing.

After watching the video I realized that I could use the AutoResponder
to do this, but it's of some importance that the page I am looking at
is the current live code with a certain line of text switched. I feel
the answer is a method call that I am missing, in time I am sure I
would stumble on the answer myself I was just wondering if you have
any insight for me moving forward.

If it helps I am currently using a different proxy for filtering the
HTML code (Proxomitron) to accomplish my task. I would like to just
use fiddler for this instead of having 2 proxies running at the same
time.

Thanks in advance,

Evash

EricLaw

unread,
Apr 3, 2009, 6:52:48 PM4/3/09
to Fiddler
Yes, you can easily replace content in pages. What sort of text are
you trying to replace, with what other text? Are you using
FiddlerScript or a C# extension?

EvashB

unread,
Apr 3, 2009, 7:13:20 PM4/3/09
to Fiddler
The extension I currently have is written in c#. I am switching page
groups that exist in JavaScript tag calls. For example :

<body>
...
<script type="text/javascript">someFunction
("addContent","PG=SomeGroup",sizeH,sizeW);</script>
...
</body>

I would like to be able to find "SomeGroup" and swap it with
"SomeOtherGroup"

Evash

EricLaw

unread,
Apr 4, 2009, 10:35:55 PM4/4/09
to Fiddler
Did you try using:

if (oSession.HostnameIs("www.bayden.com") &&
oSession.oResponse.headers.ExistsAndContains("Content-Type","text/
html")){
oSession.utilDecodeResponse();
oSession.utilReplaceInResponse('SomeGroup','SomeOtherGroup');
> > > Evash- Hide quoted text -
>
> - Show quoted text -

EvashB

unread,
Apr 6, 2009, 5:17:12 PM4/6/09
to Fiddler
Thank you Eric!

I did try to use that before, but it didn't work. You confirming that
was the code I needed prompted me to look where i was putting the
code. That is where my error was. I now have it working by putting the
code in the correct method.

public void AutoTamperResponseBefore(Session oSession) {}

The reason I was getting an error is because I was trying to change
the code before I even got the response from the page. /facepalm.

Thanks again Eric for the tool and the help!

Evash
Reply all
Reply to author
Forward
0 new messages