|
| 1 | +--- |
| 2 | +title: Filter Fiddler Traffic Using Domain Names and Client Processes |
| 3 | +description: Introduces how to filter traffic that's captured by Fiddler using domain/host names owned by Microsoft Entra and client processes. |
| 4 | +ms.service: entra-id |
| 5 | +ms.topic: how-to |
| 6 | +ms.date: 04/08/2025 |
| 7 | +ms.reviewer: bachoang, v-weizhu |
| 8 | +ms.custom: sap:Enterprise Applications |
| 9 | +--- |
| 10 | +# Filter Fiddler traffic using domain names and client processes |
| 11 | + |
| 12 | +This article explains how to filter traffic that's captured by Fiddler using domain/host names owned by Microsoft Entra and client processes. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +Before filtering, ensure that Fiddler is configured to capture traffic for all processes. In the lower-left corner of the Fiddler window, you can select **All processes** to change the selection. |
| 17 | + |
| 18 | + :::image type="content" source="media/filter-fiddler-traffic-using-domain-name-client-process/all-processes.png" alt-text="Screenshot that shows the 'All processes' button."::: |
| 19 | + |
| 20 | +## Filter traffic using Fiddler's built-in filter feature |
| 21 | + |
| 22 | +To filter traffic using Fiddler's built-in filter feature, follow these steps: |
| 23 | + |
| 24 | +1. Open Fiddler and navigate to the right panel. |
| 25 | +2. Select the **Filters** tab, and then select the **Use Filters** checkbox. |
| 26 | +3. Under the **Hosts** section, select **Show only the following Hosts**. |
| 27 | +4. In the text box, enter the host name list you want to filter on, separated by semicolons, for example, `localhost;login.microsoftonline.com;graph.microsoft.com`. |
| 28 | + |
| 29 | + > [!NOTE] |
| 30 | + > This text box will display a yellow background while editing the list, indicating unsaved changes. |
| 31 | +5. Select the **Actions** button to save the list. The background color will change to white, confirming the list is saved. |
| 32 | + |
| 33 | + :::image type="content" source="media/filter-fiddler-traffic-using-domain-name-client-process/show-only-the-following-hosts.png" alt-text="Screenshot that shows how to filter traffic based on host names."::: |
| 34 | + |
| 35 | +Under the **Client Process** section, you can also select a specific process to filter on. This is particularly useful for filtering a standalone application. It might be less effective for capturing browser traffic because multiple processes with the same name can make it difficult to identify the correct one. |
| 36 | + |
| 37 | +## Filter traffic using JavaScript code in the OnBeforeRequest function |
| 38 | + |
| 39 | +> [!NOTE] |
| 40 | +> This option is used especially for browser-based applications. |
| 41 | +
|
| 42 | +1. In Fiddler, go to **Rules** > **Customize Rules**. This action will open the **CustomRules.js** file in the FiddlerScript editor. |
| 43 | +2. Locate the **OnBeforeRequest** function in the FiddlerScript editor. |
| 44 | +3. Insert the following JavaScript code at the beginning of the function: |
| 45 | + |
| 46 | + ```javascript |
| 47 | + // begin filter |
| 48 | + |
| 49 | + // set this to false to disable filter and true to enable filter |
| 50 | + var filterOn = true; |
| 51 | + |
| 52 | + if (filterOn) |
| 53 | + { |
| 54 | + // hide all requests by default |
| 55 | + oSession["ui-hide"] = "true"; |
| 56 | + |
| 57 | + // list of domain names to filter on |
| 58 | + var host = ["localhost", "login.microsoftonline.com", "graph.microsoft.com"]; |
| 59 | + |
| 60 | + // list of processes to filter on |
| 61 | + var processlist = ["chrome", "microsoftedgecp", "iisexpress", "powershell"]; |
| 62 | + |
| 63 | + for (var j = 0; j < processlist.length; j++) |
| 64 | + { |
| 65 | + if (oSession.LocalProcess.Contains(processlist[j])) |
| 66 | + { |
| 67 | + for (var i = 0; i < host.length; i++) |
| 68 | + { |
| 69 | + if (oSession.HostnameIs(host[i])) |
| 70 | + { |
| 71 | + oSession["ui-hide"] = null; |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + // end filter |
| 79 | + ``` |
| 80 | + |
| 81 | + :::image type="content" source="media/filter-fiddler-traffic-using-domain-name-client-process/add-javascript-code-onbeforerequest-function.png" alt-text="Screenshot that shows the JavaScript code added in the OnBeforeRequest function." lightbox="media/filter-fiddler-traffic-using-domain-name-client-process/add-javascript-code-onbeforerequest-function.png"::: |
| 82 | + |
| 83 | + Here are the explanations of some variables in the JavaScript code: |
| 84 | + |
| 85 | + - `filterOn`: Set it to `true` to enable the filter and `false` to disable it. |
| 86 | + - `host`: Contains the list of domain names to filter on. |
| 87 | + - `processlist`: Contains the list of process names to filter on. |
| 88 | + |
| 89 | +4. Save the changes to the **CustomRules.js** file. |
| 90 | + |
| 91 | +## References |
| 92 | + |
| 93 | +- [Modifying a Request or Response](http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse) |
| 94 | +- [FiddlerScript Cookbook](http://fiddlerbook.com/Fiddler/dev/ScriptSamples.asp) |
| 95 | +- [Understanding FiddlerScript](https://www.telerik.com/blogs/understanding-fiddlerscript) |
| 96 | + |
| 97 | +[!INCLUDE [Azure Help Support](../../../includes/third-party-disclaimer.md)] |
| 98 | +[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)] |
0 commit comments