FiddlerScript CustomRules Hexdecimal Search

2 posts, 0 answers
  1. john
    john avatar
    2 posts
    Member since:
    Jul 2016

    Posted 21 Jul Link to this post

    I need help figuring out how I can search for hexdecimal values in the body of a POST request, and then replace it using hex values.

    My issue is that the POST data is using hex values that don't translate well to strings, like 0x01, 0xC9 etc

     

    Here is what I have to replace strings that can be pasted in ASCII and it works well

     

    if (oSession.HTTPMethodIs("POST") && (oSession.utilFindInRequest("Search This", true) > -1))
    {
        oSession.utilReplaceInRequest("Search This", "Replace With");
    }

     

    I need to be able to search and replace raw hex values or somehow convert a set of hex values in string format, such as "0xC9 0xC8" or "C9 C8" etc to ASCII or similar and then search / replace.

     

    Any Idea's?

  2. john
    john avatar
    2 posts
    Member since:
    Jul 2016

    Posted 21 Jul in reply to john Link to this post

    This works fine in c# mind you, but not JScript.NET

    string hexValues = "C9 01 10 01";
    string[] hexValuesSplit = hexValues.Split(' ');
    List<char> list = new List<char>();
    foreach (String hex in hexValuesSplit)
    {
        // Convert the number expressed in base-16 to an integer.
        int value = Convert.ToInt32(hex, 16);
        // Get the character corresponding to the integral value.
        string stringValue = Char.ConvertFromUtf32(value);
        char charValue = (char)value;
        list.Add(charValue);
             
    }
    string complete = string.Join("", list.ToArray());

Back to Top