fiddler - 通过c#动态解码检查器中的自定义加密体

时间:2017-08-20 12:52:53

标签: fiddler

内容使用CUSTOM加密器加密。 fiddler捕获的内容主体是纯文本的base64编码字符串 enter image description here

应用程序流量:

请求:

base64Encode(customEncryptFromStringTobytes(jsonString) ) -> application -> http server

响应:

customDecryptFrombytesToString(base64Decode(jsonString) ) <- application <- http server

我在c#中有加密/解密类: string EncryptToBase64(string plainText); string DecryptFromBase64(string plainText);

我构建了一个exe来进行转换,我想知道如何通过这个exe动作来制作小提琴解码请求/ respose体

我希望Fiddler在检查器中显示解密内容,并在每次 [重新发布和编辑(E)] 请求时再次加密。

我发现了一些接近但不知道如何调用exe进行解码。 http://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse

更新: 我已经为Fiddler实现了自定义检查器。见下面的答案。

2 个答案:

答案 0 :(得分:0)

添加虚拟标题

Fiddler-Encoding: base64

如果包含任何二进制数据,则使用base64对您的身体进行编码。 Fiddler会在将数据传输到服务器之前解码数据。

取自http://www.fiddlerbook.com/fiddler/help/composer.asp

答案 1 :(得分:0)

我为自定义Inspector创建了一个扩展

完整示例https://github.com/chouex/FiddlerExtensionExample

您将构建一个DLL并将该文件复制到fiddler中的Inspectors and Scripts文件夹中。重启fiddler将加载扩展。

请注意: 我使用pre / post-build脚本来复制dll并在vs project中重新启动fiddler。

自定义检查员: 这个例子只是美化了json的身体。

public class ResponseInspector : Inspector2, IResponseInspector2
{
    TextBox myControl;
    private byte[] m_entityBody;
    private bool m_bDirty;

private bool m_bReadOnly;

public bool bReadOnly
{
    get { return m_bReadOnly; }
    set
    {
        m_bReadOnly = value;
        // TODO: You probably also want to turn your visible control CONFIG.colorDisabledEdit (false) or WHITE (true) here depending on the value being passed in.   
    }
}

public void Clear()
{
    m_entityBody = null;
    m_bDirty = false;
    myControl.Text = "";
}

public ResponseInspector()
{
    // TODO: Add constructor logic here
}

public HTTPResponseHeaders headers
{
    get { return null; // Return null if your control doesn't allow header editing.
    }
    set { }
}

public byte[] body
{
    get { return m_entityBody; }
    set
    {
        // Here's where the action is.  It's time to update the visible display of the text
        m_entityBody = value;

        if (null != m_entityBody)
        {
            var text = System.Text.Encoding.UTF8.GetString(m_entityBody);

                if (!String.IsNullOrEmpty(text) && text.StartsWith("{"))
                {
                    text = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(text), Formatting.Indented);
                }

            myControl.Text = text;
            // TODO: Use correct encoding based on content header.
        }
        else
        {
            myControl.Text = "";
        }

        m_bDirty = false;
        // Note: Be sure to have an OnTextChanged handler for the textbox which sets m_bDirty to true!
    }
}

public bool bDirty
{
    get { return m_bDirty; }
}

public override int GetOrder()
{
    return 0;
}

public override void AddToTab(System.Windows.Forms.TabPage o)
{
    myControl = new TextBox(); // Essentially the TextView class is simply a usercontrol containing a textbox.
    myControl.Height = o.Height;
    myControl.Multiline = true;
    myControl.ScrollBars = ScrollBars.Vertical;
    o.Text = "TextViewExample";
    o.Controls.Add(myControl);
    o.Controls[0].Dock = DockStyle.Fill;
}
}

for Traffic Tamper (不提及问题,但我认为这很有用):

在IAutoTamper2中实现AutoTamperResponseBefore()

此示例只是在每个请求正文中将“xt”中的任何文本替换为“c1”