使用SharpPcap发送虚假构造的伪IP的UDP数据包
2009-01-04 15:48
561 查看
发送虚假构造的伪IP的UDP数据包。
构造数据包经常出错!!!原因是很多属性没设置好。。我调试了很多次才发送成功!!!
private void SendPacket()
{
string strGateWayIp = "192.168.100.1";
string strSouMac = new Class1().GetMACFromIP("192.168.100.106");//
PcapDeviceList allDevices = SharpPcap.GetAllDevices();
PcapDevice device = allDevices[0];
NetworkDevice device2 = (NetworkDevice)device;
int lLen = EthernetFields_Fields.ETH_HEADER_LEN;
string strGateWayMac = new Class1().GetMACFromIP(strGateWayIp);// zfrong
byte[] bytes = new byte[60];
UDPPacket p = new UDPPacket(lLen, bytes);//
p.EthernetProtocol = EthernetProtocols_Fields.IP;
p.IPVersion = IPVersions_Fields.IPV4;
p.IPProtocol = IPProtocols_Fields.UDP;//
p.TimeToLive = 2;//
p.IPHeaderLength = IPFields_Fields.IP_HEADER_LEN;//
p.Length = 60;//
p.SourceHwAddress = strSouMac;
p.DestinationHwAddress = strGateWayMac;
p.SourceAddress = "201.23.12.88";
p.SourcePort = 12345;
p.DestinationAddress = "192.168.100.106";
p.DestinationPort = 9000;
p.ComputeIPChecksum(true);//
p.ComputeUDPChecksum(true);
int k=0;
while(k<20)
{
device2.PcapOpen(true, 200);
device2.PcapSendPacket(p); k++;
device2.PcapClose();
}
}
构造数据包经常出错!!!原因是很多属性没设置好。。我调试了很多次才发送成功!!!
private void SendPacket()
{
string strGateWayIp = "192.168.100.1";
string strSouMac = new Class1().GetMACFromIP("192.168.100.106");//
PcapDeviceList allDevices = SharpPcap.GetAllDevices();
PcapDevice device = allDevices[0];
NetworkDevice device2 = (NetworkDevice)device;
int lLen = EthernetFields_Fields.ETH_HEADER_LEN;
string strGateWayMac = new Class1().GetMACFromIP(strGateWayIp);// zfrong
byte[] bytes = new byte[60];
UDPPacket p = new UDPPacket(lLen, bytes);//
p.EthernetProtocol = EthernetProtocols_Fields.IP;
p.IPVersion = IPVersions_Fields.IPV4;
p.IPProtocol = IPProtocols_Fields.UDP;//
p.TimeToLive = 2;//
p.IPHeaderLength = IPFields_Fields.IP_HEADER_LEN;//
p.Length = 60;//
p.SourceHwAddress = strSouMac;
p.DestinationHwAddress = strGateWayMac;
p.SourceAddress = "201.23.12.88";
p.SourcePort = 12345;
p.DestinationAddress = "192.168.100.106";
p.DestinationPort = 9000;
p.ComputeIPChecksum(true);//
p.ComputeUDPChecksum(true);
int k=0;
while(k<20)
{
device2.PcapOpen(true, 200);
device2.PcapSendPacket(p); k++;
device2.PcapClose();
}
}
相关文章推荐
- 使用SharpPcap发送虚假构造的伪IP的UDP数据包
- 004.UDP--拼接UDP数据包,构造ip头和udp头通信(使用原始套接字)
- asp.net发送给udp端口,发送数据包,服务端为windows服务侦听.可以不使用Remoting
- Linux下使用RAW SOCKET原始套接字构造UDP原始数据帧广播到局域网,在局域网的另一台计算机上显示UDP发送的信息
- #使用Socks5代理发送UDP数据包
- Android使用wifi通过UDP协议发送广播数据包给PC接收不到问题解决方法
- 定义DNS、IP|UDP结构体,使用libpcap处理数据包
- Linux下使用RAW SOCKET原始套接字构造UDP原始数据帧广播到局域网,在局域网的另一台计算机上显示UDP发送的信息
- 使用rawsocket构造UDP数据包方法
- 使用NetworkStream发送自己构造的http数据包总是读取数据超时
- TCP,UDP发送数据包大小浅析
- 使用ZLG TCP/IP建立多个UDP连接的注意事项
- 使用UDP协议发送和接收数据
- 以太网,IP,TCP,UDP数据包分析
- 使用WinPcap(SharpPcap)实现ARP抓包以实现设备IP搜索功能
- TCP和UDP协议发送数据包的大小方面的知识介绍
- TCP和UDP 协议发送数据包的大小
- 使用vbs获得外网ip并发送到邮箱里
- 使用Winpcap进行IP数据包统计
- 伪造IP发送数据(UDP)