This wiki has been migrated to https://gitlab.com/wireshark/wireshark/-/wikis/home and is now deprecated. Please use that site instead.

Lua

For more information about Lua refer to [http://www.lua.org Lua's main site], there you can find its [http://www.lua.org/manual/5.0/manual.html Reference Manual] and a [http://www.lua.org/pilhttp://www.lua.org/pil book] that describes the language.

Lua in Ethereal

Lua can be used to write [:Lua/Dissectors: dissectors], post-dissectors and [:Lua/Taps: taps].

Although it's possible to write [:Lua/Dissectors: dissectors] in Lua, ethereal dissectors are written in C, as C is several times faster than Lua. Lua is ok for prototyping dissectors, during Reverse Engineering you can use your time for finding out how things work instead of compiling and debugging your C dissector.

Post-dissectors are dissectors meant to run after every other dissector has run. They can add items the dissection tree so they can be used to create your own extensions to the filtering mechanism.

[:Lua/Taps: Taps] are used to collect information after the packet has been dissected.

Getting Started

Lua is an optional module in ethereal 0.10.15(???) so it won't be installed by default. If you want to use it make sure you install it.

To check if it is installed go to Help->About Ethereal go to the Plugins tab and look for it.

To test if it works write a simple Lua script like:

-- hello.lua
-- Lua's implementation of D. Ritchie's hello world program.

    print("hello world!")

run tethereal -X lua_script:test.lua from the command prompt and tou should see something like:

$ tethereal -X lua_script:hello.lua
hello world!
Capturing on en0
1   0.000000 111.123.234.55 -> 111.123.234.255 NBNS Name query NB XXX.COM<00>

if you can read "hello world!" in the first line after you run tethereal Lua is up and runing.

Classes

Examples

Discussion

This page is a good start. However, some things remain unclear:

That's what it is, a start... I think it's soon to complete as things are changing as I go ahead.