This is a migrated thread and some comments may be shown as answers.

FiddlerScript CustomRules Hexdecimal Search

1 Answer 181 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 21 Jul 2016, 06:32 PM

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?

1 Answer, 1 is accepted

Sort by
0
john
Top achievements
Rank 1
answered on 21 Jul 2016, 06:47 PM

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());

Tags
Fiddler Classic
Asked by
john
Top achievements
Rank 1
Answers by
john
Top achievements
Rank 1
Share this question
or