Table of Contents
Lua is a powerful light-weight programming language designed for extending applications. Wireshark contains an embedded Lua 5.2 interpreter which can be used to write dissectors, taps, and capture file readers and writers. The interpreter is backwards compatible with Lua 5.1, but does not yet work with Lua 5.3 or greater.
If Lua is enabled, Wireshark will first try to load a file named init.lua
from the global plugins directory.
and then from the user’s
personal plugins directory.
Then all files ending with .lua are loaded from the global plugins
directory. Then all files ending with .lua in the personal Lua plugin’s
directory.
Whether or not Lua scripts are enabled can be controlled via the enable_lua variable. Lua scripts are enabled by default. To disable Lua scripts, set the enable_lua variable to false. Wireshark 2.6 and earlier enabled or disabled Lua scripts using the variable disable_lua (deprecated). If both enable_lua and disable_lua are present, disable_lua is ignored.
Example for init.lua.
-- Set enable_lua to false to disable Lua support. enable_lua = true if not enable_lua then return end -- If false and Wireshark was started as (setuid) root, then the user -- will not be able to execute custom Lua scripts from the personal -- configuration directory, the -Xlua_script command line option or -- the Lua Evaluate menu option in the GUI. -- Note: Not checked on Windows. running_superuser is always false. run_user_scripts_when_superuser = true
The command line option -X lua_script:file.lua can also be used to load specific Lua scripts.
The Lua code is executed after all protocol dissectors are initialized and before reading any file.
Wireshark for Windows uses a modified Lua runtime (lua-unicode) to support Unicode (UTF-8) filesystem paths. This brings consistency with other platforms (for example, Linux and macOS).