IP address spoofing using SharpPcap on C#

▼魔方 西西 提交于 2019-11-26 21:04:49

问题


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.

I found some example on SharpPcap project, but how can I edit or change the source address field of sending packet?

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( bytes );


回答1:


Try Pcap.Net instead.

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})
                            });


来源:https://stackoverflow.com/questions/2857223/ip-address-spoofing-using-sharppcap-on-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!