Fiddler

http://fiddlerbook.com/fiddler/dev/scriptsamples.asp
http://docs.telerik.com/fiddler/Generate-Traffic/Tasks/ReplayAutoresponder
http://fiddler2.com/r/?SYNTAXVIEWINSTALL
using .NET Fiddler plugins was a lot better than FiddlerScript
When the user mouseover an icon, Fiddler should display a tool tip explaining the meaning of the icon.

How can we capture localhost traffic?

On Windows, traffic for localhost does not go through the network (TCP/IP) stack. To capture local traffic, we need to force it through the network stack by using your host's IP address (or assign your host a name using its IP address). Instead of using http://localhost or http://127.0.0.1, use your machine name. For example, instead of using http://localhost:8081/mytestpage.aspx, use http://machinename:8081/mytestpage.aspx, or use:

How can we cause Fiddler to returns a different file?

I need to investigate an issue on an environment where I did not have direct access to the file so I could not make change to the file. I download the file to my local environment, reformat it, make necessary change, and instruct Fiddler so that whenever a request is made to the original URL, Fiddler will return my locally modified file. To do this, in Fiddler:

1. Find the request that you want to tamper
2. Click on AutoResponder
3. Check the checkbox "Enable automatic responses"
4. In the middle section, if there were any previous rules, click on those rule, and hit the delete key
5. Click on "Add Rule"
6. At the bottom, in the "Rule Editor" section, click the bottom dropdown, and select "Find a file …"
7. Select the appropriate file you want to return

Remove all previous requests from Fiddler. Refresh the page, and you see that Fiddler returns the locally modified file.

How can we capture traffic from another machine?

1. Go to Fiddler Options -> Connections
2. Note the port number in the Fiddler listens on port: box. The default port is 8888.
3. Select the Allow remote computers to connect check box
4. On the other machine, set the proxy settings to the machine name of the Fiddler server at port 8888. Open Internet Explorer > Options > Internet Options > Connections > LAN Settings. Click the check box by Use a proxy server for your LAN. Type the address and port number for the Fiddler machine. See Capture Traffic from Another Machine

How can we chain fiddler to an upstream proxy?

If you are in an environment where you do not have direct connection to the Internet (there is a corporate proxy between your computer and the Internet), you may need to do this.

1. Close Fiddler.
2. Open Internet Explorer > Options > Internet Options > Connections > LAN Settings.
3. Click the check box by Use a proxy server for your LAN.
4. Type the address and port number for the upstream proxy.
5. Restart Fiddler. Note that Fiddler currently does not support upstream proxy configuration scripts that are accessed using the FILE:// protocol, only those accessed using the HTTP or HTTPS protocols.

How can we configure Java application to use Fiddler?

Add the following options to the command line:

[[code]]
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 -Djavax.net.ssl.trustStore=C:\Dev\Java\jre\lib\security\cacerts -Djavax.net.ssl.trustStorePassword=changeit
[[/code]]

-DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888
-DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888


If we need to capture HTTPS traffic, we need to export the Fiddler Root Certificate and import it into our Java keystore, and we need to add the following arguments to the above screen:

-Djavax.net.ssl.trustStore="path\to\keystore\FiddlerKeystore"
-Djavax.net.ssl.trustStorePassword=yourpassword

-Djavax.net.ssl.trustStore=C:\Dev\Java\jre\lib\security\cacerts -Djavax.net.ssl.trustStorePassword=changeit


See the below links for the exact steps:

How can we configure PHP / curl to use Fiddler?

To configure a PHP/cURL application to send web traffic to Fiddler, add this line of code before the application sends requests, where $ch is the handle returned by curl_init(): curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');


Or add option to command line:

curl --proxy 127.0.0.1:8888


How can we configure Perl to use Fiddler?

use HTTP::Request::Common;
use LWP::UserAgent;
use Time::HiRes qw/usleep/;

$ua = LWP::UserAgent->new;$ua->proxy(['http', 'https'], 'http://127.0.0.1:8888/');

my $cnt = 0; my$successCnt = 0;
my $failureCnt = 0; open (MYFILE, 'FirstPass.txt'); open (OUTFILE, '>>UnableToAuthenticate.txt'); <MYFILE>; while (<MYFILE>) { chomp;$cnt = $cnt + 1;$line = $_; if (! testAuthentication($line)) {
print OUTFILE $line, "\n";$failureCnt = $failureCnt + 1; } else {$successCnt = $successCnt + 1; } } close (MYFILE); close (OUTFILE); print "Success:$successCnt, Failure: $failureCnt, Total:$cnt\n";

sub testAuthentication {
my ($line) = @_; my$loginID, $lastName,$firstName, $dn; ($loginID, $lastName,$firstName, $dn) = split /\|/,$line;
$loginID =$loginID . '@sjhc.com';
print "$loginID\n$dn\n----\n";

my $response =$ua->request(POST 'some URL', [param1=> value1, param2=> value2]);
if ($response->is_success) {$body = $response->decoded_content; if ($body =~ /LDAP Authentication Failure/) {
return 0;
} elsif ($body =~ /Unknown Error/) { return 0; } elsif ($body !~ /MyCQIBody/) {
print \$body, "\n";
exit;
} else {
return 1;
}
} else {
return 0;
}
usleep(100);
}


How can we replay a Fiddler capture in a browser?

How can we log a message to the Fiddler log from inside the CustomRules.js file?

While working with the CustomRules.js file, we can log a message to the Fiddler's log file using:

FiddlerObject.log("PathAndQuery:" + oSession.PathAndQuery);


How can we look at the Fiddler log?

On the top right hand side, there is a tab named "Log". On this tab, you can see all the log messages, not just the selected request.

In what ways can we customize Fiddler?

We can:

1. add custom columns to the Fiddler UI
2. modify requests or responses
3. test application performance
4. do a variety of other custom tasks

How can we change or add rules to fiddler?

To add rules to Fiddler's JScript.NET CustomRules.js, do the following:

1. Click Rules > Customize Rules…. This will create the CustomRules.js in your home directory and open it in a text editor for editing.
2. Enter FiddlerScript code inside the appropriate function. If we need to alter the request, add your code to the OnBeforeRequest function. If you need to alter the response, add your code to the OnBeforeResponse function.
3. Save the file.

Fiddler will automatically reload the rules.

The OnBeforeRequest is called before each request, and OnBeforeResponse is called before each response. It is not possible to access the response objects inside OnBeforeRequest as they have not yet been created. It is possible to use objects from the request inside OnBeforeResponse, however, any changes you make to those objects will not be seen by the server, as it has already received the request.

How can we change the response header?

Add to OnBeforeResponse:

if (oSession.responseCode == 302) {
oSession.oResponse["Location"] = oSession.oResponse["Location"].replace(/QMISRxV2QA01/, '...');
}


How can we change the response body?

Add to OnBeforeResponse:

var bodystr=oSession.GetResponseBodyAsString();
bodystr = bodystr.replace(/QMISRxV2QA01/, '...');
oSession.utilSetResponseBody(bodystr);


How can we intercept HTTPS requests to a certain server and route it to non-HTTPS on another server?

Add the following:

if (oSession.HTTPMethodIs("CONNECT") && (oSession.hostname == "www.companyname.com")) {
oSession["x-replywithtunnel"] = "FakeTunnel";
return;
}

if (oSession.hostname == "www.companyname.com") {
oSession.fullUrl = "http://192.168.41.155:7001" +  oSession.PathAndQuery;
}


to the OnBeforeRequest method in your CustomRules.js file.

How can we restore the default rules?

1. Delete the C:\Users\kdoan\My Documents\Fiddler2\Scripts\CustomRules.js
2. Restart Fiddler
page revision: 48, last edited: 15 Sep 2017 19:05
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License