使用Lua编写whireshark插件

    xiaoxiao2023-11-26  224

    whireshark支持Lua、C、C++编写的插件

    在这里,我简单介绍如何使用Lua编写whireshark插件。

    一、插件的存放位置

    whireshark插件分为个人插件和全局插件,在windows平台上,个人插件的存放位置在:

    #%APPDATA%是window下的一个环境变量,通过在cmd窗口输入echo %APPDATA% 即可查看具体的信息 %APPDATA%\Wireshark\plugins

    全局插件存放在:

    #whireshark 的安装目录下的plugins目录下 WIRESHARK\plugins

    以上内容参考:https://www.wireshark.org/docs/wsug_html_chunked/ChPluginFolders.html

    二、编写插件

    使用whireshark编写一个whireshark插件如下(该插件的作用是在wihreshark的工具栏菜单下,增加一个菜单项:Lua Dialog Test),并保存到:%APPDATA%\Wireshark\plugins 目录下面

    if gui_enabled() then local splash = TextWindow.new("Hello!"); splash:set("This time wireshark has been enhanced with a useless feature.\n") splash:append("Go to 'Tools->Lua Dialog Test' and check it out!") end local function dialog_menu() local function dialog_func(person,eyes,hair) local window = TextWindow.new("Person Info"); local message = string.format("Person %s with %s eyes and %s hair.", person, eyes, hair); window:set(message); end new_dialog("Dialog Test",dialog_func,"A Person","Eyes","Hair") end register_menu("Lua Dialog Test",dialog_menu,MENU_TOOLS_UNSORTED)

    三、配置whireshark支持Lua插件

    进入whireshark安装目录,打开init.lua文件,在文件的末尾加上(编写的lua插件的位置):

    dofile("C:\\Users\\lyh\\AppData\\Roaming\\Wireshark\\plugins\\menutest.lua")

    并确保:

    enable_lua = true

    重启whireshark即可看到,在打开工具查看即可看到:

    附录:可以在该地址找到whireshark 的lua插件案例:

    https://wiki.wireshark.org/Lua/Examples

    https://www.wireshark.org/docs/wsdg_html_chunked/wsluarm.html

    最新回复(0)