dotpcap / sharppcap

Official repository - Fully managed, cross platform (Windows, Mac, Linux) .NET library for capturing packets
1.3k stars 267 forks source link

IP Spoofing #269

Open FirstBlood12 opened 3 years ago

FirstBlood12 commented 3 years ago

I want to test how much users my website can handle. so I want to know how can I do IP Spoofing using SharpPcap in C#. I made a client in C# for my website so how can I spoof the source IP so I can test how much users can my website handle?

        `static WebSocket test;`
        `test = new WebSocket("ws://example.com:8080");`
        `test.OnClose += OnClose;`
        `test.OnOpen += OnOpen;`
        `test.OnMessage += OnMessage;`
        `test.Compression = CompressionMethod.Deflate;`
        `test.Connect();`
chmorgan commented 3 years ago

This should be entirely possible to do and I think with sharppcap either using the libpcap or the WinDivert driver. If you can see how it works with those libraries directly you can apply the same approach with sharppcap. I don't know specifically how to do that but someone else may comment here with more info.

FirstBlood12 commented 3 years ago

@chmorgan you coded SharpPcap and I think you should know how can I do IP Spoofing using SharpPcap, for example I generate random IP in C# and I replace source IP of socket with the random generated IP and I sent the socket to the website and I do this for each connection to my website so each connection will come from different IP. So how I could do this? Can you provide me a example code of doing this?

chmorgan commented 3 years ago

@FirstBlood12 you expect me to know how to implement IP spoofing just because I developed the library? I'm aware of what IP spoofing is but I've yet to implement it. It would be more than a little presumptuous of me to think that I could just guess at how to do it and know as much as you might about the subject.

On the SharpPcap side you can call LibPcapLiveDevice.SendPacket() to send a raw packet.

On the PacketDotNet side you can create an IP packet like https://github.com/chmorgan/packetnet/blob/master/Examples/ConstructingPackets/Main.cs

once you created your packet on the PacketDotNet side you'd turn around and send it via SendPacket() like:

myLiveDevice.SendPacket(myPacket.Bytes);

FirstBlood12 commented 3 years ago

@chmorgan I want to spoof source IP for websockets not for packets because I am using websocket-sharp, So how I would do IP Address Spoofing for websockets using SharpPcap?