Video icon
Video Tutorials
Fiddler Logo Use FiddlerCap to capture SAZ Files which can be emailed to experts for debugging purposes
Try FiddlerCap
The simple traffic capture tool
RSS Icon Get Fiddler! Addons Help & Documentation Developer Info Discuss Contact

 

Note: Prefer to write all of your code in .NET?  Use the IAutoTamper interface instead!

 

Extending FiddlerScript using .NET

Using .NET Assemblies in FiddlerScript, step-by-step

For instance, here's an example of a managed C# addon that tweaks the user-agent string.

1. Close Fiddler.

2. Save the following as UASimulator.cs

using System;

using System.Windows.Forms;

using Fiddler;

namespace FiddlerUtility{

      public class UASimulator {

            string m_sUAString;

            public UASimulator(string s_UAString){

                  m_sUAString = s_UAString;

            }

            public bool OverwriteUA(Session oSession){

                  oSession.oRequest["User-Agent"] = m_sUAString;

                  return true;

            }

      }

}

3. Go to a VS command prompt in the folder where the .CS file is found.

csc /target:library /out:c:\UASim.dll UASimulator.cs /reference:"C:\program files\fiddler2\fiddler.exe"

4. Inside Fiddler, add C:\UASim.dll to the ScriptReferences list in Tools | Fiddler Options.

5. Boot Fiddler.

6. Use Rules | Custom Rules to update your script.

import System;

import System.Windows.Forms;

import Fiddler;

import FiddlerUtility;

class Handlers{

      static var UASim = new UASimulator("Mozilla/12.0");

      static function OnBeforeRequest(oSession:Fiddler.Session){

            UASim.OverwriteUA(oSession);

      }

   static function Main(){

       var today: Date = new Date();      

       FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;

   }

}