在C#中使用SharpPcap IP地址欺骗 [英] IP address spoofing using SharpPcap on C#
问题描述
我会用SharpPcap框架,使我的欺骗程序,所以我需要在源地址字段另一个IP地址编辑包我的机器的IP地址。
I will use SharpPcap framework to make my spoofing program, so I need to edit my machine's IP address of the packet with another IP address on the source address field.
我发现SharpPcap项目的一些例子,但我怎么可以编辑或更改发送数据包的源地址字段?
I found some example on SharpPcap project, but how can I edit or change the source address field of sending packet?
下面是示例code发送数据包随机:
Here is the sample code for sending random packets:
byte[] bytes = GetRandomPacket();
private static byte[] GetRandomPacket()
{
byte[] packet = new byte[200];
Random rand = new Random();
rand.NextBytes( packet );
return packet;
}
-
device.SendPacket(字节);
- device.SendPacket( bytes );
推荐答案
尝试 Pcap.Net 来代替。
下面是你如何建立与特定的源地址和目标地址一个简单的IPv4数据包,并在Pcap.Net自定义负载:
Here is how you build a simple IPv4 packet with specific source and destination addresses and a custom payload in Pcap.Net:
Packet packet =
PacketBuilder.Build(DateTime.Now,
new EthernetLayer
{
Source = new MacAddress("11:22:33:44:55:66"),
Destination = new MacAddress("11:22:33:44:55:67"),
},
new IpV4Layer
{
Source = new IpV4Address("1.2.3.4"),
Destination = new IpV4Address("1.2.3.5"),
Ttl = 64,
Identification = 100,
},
new PayloadLayer
{
Data = new Datagram(new byte[] {1, 2, 3, 4})
});
这篇关于在C#中使用SharpPcap IP地址欺骗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!