【问题标题】:Change Response from HTTP Request sent by a program更改程序发送的 HTTP 请求的响应
【发布时间】:2023-03-11 17:10:01
【问题描述】:

我有一个程序可以激活芯片以获取比赛结果。 (它只是一个硬件)。
当我将芯片与我的电脑连接时,我使用 Fiddler(嗅探程序)观察我电脑的传入和传出流量。

程序发送以下 HTTP 请求:

POST http://example.com/index.php HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Content-Length: 185
Content-Type: application/x-www-form-urlencoded
Host: example.com
Pragma: no-cache
User-Agent: SomeProgram 1.2.3

Data==%0D%0AAjlFNEEw-SOMELONGSECRETKEY-RGAw%3D%3D%0D%0A

我收到以下回复:

<?xml version="1.0" encoding="utf-8"?>
<message type="3" result="1" txid="someid" activationdate="" availablecredits="732" firstname="John" lastname="Doe" email="JohnDoe@outlook.com" phonenumber="00123445" notification_email="1" notification_text="1"/>

是否可以编辑响应,以便在程序检查availablecredits 变量时,他得到值9999 而不是732

我正在使用 Windows 8 笔记本电脑。

【问题讨论】:

    标签: networking http-headers xmlhttprequest fiddler packet-sniffers


    【解决方案1】:

    绝对 - Fiddler 允许您通过 adding rules to FiddlerScript 发送 modify requests and responses。引用 Fiddler 文档:

    要对网络请求和响应进行自定义更改,请使用 FiddlerScript 将规则添加到 Fiddler 的 OnBeforeRequest 或 OnBeforeResponse 函数。哪个功能合适取决于 您的代码使用的对象:在每个之前调用 OnBeforeRequest 请求,并且在每个响应之前调用 OnBeforeResponse

    因此,您所要做的就是在 OnBeforeResponse 中添加用于将 availablecredits 属性值替换为您想要的任何值的逻辑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-08
      • 2011-12-21
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      相关资源
      最近更新 更多