欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

使用Lua编写whireshark插件

发布时间:2025/3/21 编程问答 56 豆豆
生活随笔 收集整理的这篇文章主要介绍了 使用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() thenlocal 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!") endlocal 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);endnew_dialog("Dialog Test",dialog_func,"A Person","Eyes","Hair") endregister_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

总结

以上是生活随笔为你收集整理的使用Lua编写whireshark插件的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。