Search code examples
.netvb.netiisuser-agentinfragistics

Server side spoof of user agent


Is it possible to spoof / force the user agent string on the server side in .NET? Either through code or some mechanism in IIS?

I realize this is unorthodox, but it is a temporary solution to allow Window 10 workstations to use a legacy application until it's updated or replaced.

I should add that this is running in IIS 6. IIS is version 7


Solution

  • You could try to use the IIS URL rewrite module to implement your requirement:

    For that first, you need to install the URL rewrite module.

    https://www.iis.net/downloads/microsoft/url-rewrite

    Next, click the View Server Variables link from the Actions pane on the right. From here we need to add HTTP_USER_AGENT into the list of Allowed Server Variables by clicking Add in the Actions pane.

    enter image description here

    enter image description here

    When this step is complete, click the Back to Rules button from the Actions pane then press Add Rules(s). Select Blank rule under the Inbound rules section (the first selection on the top left) and enter/choose the following values:

    Name: This rule can be named anything you wish for it to be named

    Match URL:

    Requested URL: Matches the Pattern

    Using: Regular Expressions

    Pattern: .*

    Conditions:

    Logical grouping: Match All

    Click Add Condition and then enter the following data:

    Condition input: {HTTP_USER_AGENT}

    Check if input string: Matches the Pattern

    Pattern: .Trident/([7-9]|0[1-9]\d+).(rv:1[1-9]).

    enter image description here

    Server Variables:

    Click Add and then enter the following data:

    Server variable name: HTTP_USER_AGENT

    Value: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)

    Replace the existing value: Checked

    enter image description here

    Action Action type: None

    After following these steps, press Apply in the Actions pane.

    Note: you could use the your own value in condition pattern and server variable value.