使用Lua编写whireshark插件

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值