Jax*_*Jax 13 c# sniffing packet-sniffers
我想知道如何拦截某个应用程序发送的数据包,然后检查这些数据包包含的内容.我需要一些建议做什么,因为我从来没有做过这样的事情,我想自己学习.
Har*_*aid 19
Pcap.Net是用C++/CLI和C#编写的WinPcap的.NET包装器.它具有几乎所有WinPcap功能,并包含一个数据包解释框架.
SharpPcap是一个基于着名的pcap/WinPcap库的.NET环境的跨平台数据包捕获框架.它提供了一个API,用于使用任何.NET语言(如C#和VB.NET)捕获,注入,分析和构建数据包.
它用于网络故障排除,分析,软件和通信协议开发以及教育.而且我认为它是迄今为止我使用过的最通用的数据包嗅探器.
Fiddler是一个Web调试代理,它记录您的计算机和Internet之间的所有HTTP(S)流量.Fiddler允许您检查流量,设置断点,并"输入"传入或传出的数据.Fiddler包含一个功能强大的基于事件的脚本子系统,可以使用任何.NET语言进行扩展.最近Fiddler被Telerik超越.但它仍然是免费的AFAIK.
c#嗅探器套接字创建的一些示例.
mainSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw,
ProtocolType.IP);
// Bind the socket to the selected IP address
mainSocket.Bind(newIPEndPoint(IPAddress.Parse(cmbInterfaces.Text),0));
// Set the socket options
mainSocket.SetSocketOption(SocketOptionLevel.IP, //Applies only to IP packets
SocketOptionName.HeaderIncluded, //Set the include header
true); //option to true
byte[] byTrue = newbyte[4]{1, 0, 0, 0};
byte[] byOut = newbyte[4];
//Socket.IOControl is analogous to the WSAIoctl method of Winsock 2
mainSocket.IOControl(IOControlCode.ReceiveAll, //SIO_RCVALL of Winsock
byTrue, byOut);
//Start receiving the packets asynchronously
mainSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,
newAsyncCallback(OnReceive), null);
Run Code Online (Sandbox Code Playgroud)