我尝试用 C# 编写嗅探器,并在 Google 中找到了本教程。我添加到类 TCPHeader
string wiad = Encoding.UTF8.GetString(byTCPData);
if (wiad.Contains("|"))
MessageBox.Show(wiad);
查看收到的消息,但我只能看到发送的数据包。我应该如何修改它以查看接收到的数据?
我尝试用 C# 编写嗅探器,并在 Google 中找到了本教程。我添加到类 TCPHeader
string wiad = Encoding.UTF8.GetString(byTCPData);
if (wiad.Contains("|"))
MessageBox.Show(wiad);
查看收到的消息,但我只能看到发送的数据包。我应该如何修改它以查看接收到的数据?
你可以实现一个基于 fiddler 核心库的嗅探器,我认为这是更好的选择。谢谢
FiddlerCore - 适用于您的 .NET 应用程序的 Fiddler 代理引擎 www.fiddler2.com/core/
我遇到了同样的问题,最后发现是 Windows 防火墙阻止了你嗅探传入的包。关闭windows防火墙后,它会工作。Win10中可以在控制面板中关闭,或者
netsh advfirewall set allprofiles state off
像这样使用命令或者使用c#代码
public static void TurnOffFireWall()
{
// Have only been tested in Win10
Process proc = new Process();
string top = "netsh.exe";
proc.StartInfo.Arguments = "advfirewall set allprofiles state off";
proc.StartInfo.FileName = top;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.WaitForExit();
}
请注意,我只在win10上测试过,在其他系统下,命令可能会有点不同。