netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PacketScript: packet mangling using the Lua scripting language
@ 2010-09-20 20:04 André Graf
  2010-09-20 22:13 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: André Graf @ 2010-09-20 20:04 UTC (permalink / raw)
  To: netfilter-devel

Hello

As a part of my master thesis I developed PacketScript - a Netfilter
extension, which enables to extend Netfilter with Lua scripts. The Lua
scripts are loaded with iptables and provide an easy way to deal with
network packets. Here a short example:

# iptables -A INPUT -p tcp -j LUA --script /path/to/my/script.lua

and the /path/to/my/script.lua can contain a Lua function similar to
the following: (Lua uses -- for comments)

-- called by the Netfilter callback function, gets a 'raw' packet
function process_packet(raw)
    -- apply the Ethernet dissector
    ethernet = raw:data(packet_ethernet)

    -- apply the IP dissector
    ip = ethernet:data(packet_ip)

    -- dissect IP source address
    src = ip:saddr()
    if src:get() == "192.168.1.1" then
        -- rewrite IP source address
        src:set("10.0.0.123")
        -- accept packet
        return NF_ACCEPT
    end
    -- drop packet
    return NF_DROP
end

PacketScript was not build with a specific network protocol or
protocol layer in mind, so it offers a simple framework to extend it
with other protocols. The current version provides rudimentary support
for Ethernet, IP, ICMP, UDP, TCP, TFTP, and HTTP. For my thesis I also
developed the possibility to access the Linux workqueue interface
using Lua.

At the moment I am cleaning up the code and write the user
documentation. But, before I put too much extra effort into it I would
really like to know your opinion. Thank you!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-20 22:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-20 20:04 PacketScript: packet mangling using the Lua scripting language André Graf
2010-09-20 22:13 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).