You could try Netfilter "Divert sockets" or "-j QUEUE" to get a packet into userland, mangle it and send it back through iptables onto the stack. Any penetration testing tools list, like the ones at insecure.org, should show packet mangling tools. Maybe you'll find one there that matches your specs (ettercap scripts, scapy?).
|