|
| 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 and client processes owned by a Microsoft Entra tenant. |
| 4 | +ms.service: entra-id |
| 5 | +ms.topic: how-to |
| 6 | +ms.date: 04/01/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 and client processes owned by a Microsoft Entra tenant. |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +Before filtering, ensure that Fiddler is configured to capture traffic for all processes. At the bottom left corner of the Fiddler window, you can select **All processes** to change the selection. |
| 17 | + |
| 18 | +## Filter traffic using Fiddler's built-in filter feature |
| 19 | + |
| 20 | +To filter traffic using Fiddler's built-in filter feature, follow these steps: |
| 21 | + |
| 22 | +1. Open Fiddler and navigate to the right panel. |
| 23 | +2. Select the **Filters** tab, then check the **Use filters** box. |
| 24 | +3. Under the **Hosts** section, select **Show only the following Hosts**. |
| 25 | +4. Enter the host name list you want to filter on, separated by semicolons, for example, `localhost;login.microsoftonline.com;graph.microsoft.com`. |
| 26 | + |
| 27 | + > [!NOTE] |
| 28 | + > This text box will display a yellow background while editing the list, indicating unsaved changes. |
| 29 | +5. Select the **Actions** button to save the list. The background color will change to white, confirming the list is saved. |
| 30 | + |
| 31 | +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. |
| 32 | + |
| 33 | +## Filter traffic using JavaScript code in the OnBeforeRequest function |
| 34 | + |
| 35 | +> [!NOTE] |
| 36 | +> This option is used especially for browser-based applications. |
| 37 | +
|
| 38 | +1. In Fiddler, go to **Rules** > **Customize Rules…**. |
| 39 | +2. Locate the **OnBeforeRequest** function in the script editor. |
| 40 | +3. Insert the following JavaScript code at the beginning of the function: |
| 41 | + |
| 42 | + ```javascript |
| 43 | + // begin filter |
| 44 | + |
| 45 | + // set this to false to disable filter and true to enable filter |
| 46 | + var filterOn = true; |
| 47 | + |
| 48 | + if (filterOn) |
| 49 | + { |
| 50 | + // hide all requests by default |
| 51 | + oSession["ui-hide"] = "true"; |
| 52 | + |
| 53 | + // list of domain names to filter on |
| 54 | + var host = ["localhost", "login.microsoftonline.com", "graph.microsoft.com"]; |
| 55 | + |
| 56 | + // list of processes to filter on |
| 57 | + var processlist = ["chrome", "microsoftedgecp", "iisexpress", "powershell"]; |
| 58 | + |
| 59 | + for (var j = 0; j < processlist.length; j++) |
| 60 | + { |
| 61 | + if (oSession.LocalProcess.Contains(processlist[j])) |
| 62 | + { |
| 63 | + for (var i = 0; i < host.length; i++) |
| 64 | + { |
| 65 | + if (oSession.HostnameIs(host[i])) |
| 66 | + { |
| 67 | + oSession["ui-hide"] = null; |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + // end filter |
| 75 | + ``` |
| 76 | + |
| 77 | + Here are explanations for some variables in the JavaScript code: |
| 78 | + |
| 79 | + - `filterOn`: Set it to `true` to enable the filter and `false` to disable it. |
| 80 | + - `host`: Contains the list of domain names to filter on. |
| 81 | + - `processlist`: Contains the list of process names to filter on. |
| 82 | + |
| 83 | +4. Save the changes to the script file. |
| 84 | + |
| 85 | +## References |
| 86 | + |
| 87 | +- [Modifying a Request or Response](http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse) |
| 88 | +- [FiddlerScript Cookbook](http://fiddlerbook.com/Fiddler/dev/ScriptSamples.asp) |
| 89 | +- [Understanding FiddlerScript](https://www.telerik.com/blogs/understanding-fiddlerscript) |
| 90 | + |
| 91 | +[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)] |
0 commit comments