Lua语言在Wireshark中使用(转)

时间:2023-03-08 16:42:43
Lua语言在Wireshark中使用(转)

1.       检查Wireshark的版本是否支持Lua

打开Wireshark,点击“HelpàAbout Wireshark”菜单,查看弹出的对话框,如果有“with Lua 5.1”表示支持Lua语言扩展,如果有“without Lua”表示不支持Lua扩展。

Lua语言在Wireshark中使用(转)

2.       启用LUA

在全局配置文件中启用LUA的方法是从init.lua文件中删除disable_lua这一行。该文件可以通过点击“HelpàAbout Wireshark”,在弹出的对话框中找到“FoldersàGlobal configuration”,获得init.lua的位置为C:/Program Files/Wireshark,打开该文件夹可以发现init.lua文件。

-- Lua is disabled by default, comment out the following line to enable Lua support.

--disable_lua = true; do return end;

-- If set and we are running with special privileges this setting

-- tells whether scripts other than this one are to be run.

run_user_scripts_when_superuser = false

缺省情况下Lua是不启用的,前面增加“--”注释掉这一行启用LUA。

3.       创建测试脚本

创建一个Hello World的LUA测试脚本来检查Lua是否启用。

-- hello.lua

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

print ("Hello world!")

4.       测试hello.lua脚本

可以通过tshark命令来进行测试,进入到wireshark的安装目录中执行下面的命令。

# cd c:\Program Files\Wireshark

# tshark -x lua_script:hello.lua

C:\Program Files\Wireshark>tshark -X lua_script:hello.lua

Hello world!

Capturing on Intel(R) 82567LM Gigabit Network Connection

接下来您可以使用Lua语言来为Wireshark增加协议的解码器。

http://blog.csdn.net/fan_hai_ping/article/details/6703468