如何在 wireshark 的 Lua 脚本中显示 UTF-8 数据
How to display UTF-8 data in Lua script for wireshark
我一直在尝试用 UTF-8 表示日语解码中的二进制,但仍然没有弄清楚如何正确地进行。这是代码。
vps_proto = Proto("vps", "VPS Packet")
Name_F = ProtoField.string("Name", "Name")
vps_proto.fields = {Name_F}
function RequestAccountPayloadParse(decoded_buf, pinfo, subtree)
local PayloadNameRange = decoded_buf(0, 20)
local PayloadName = PayloadNameRange:string(ENC_UTF_8)
local payloadPacTree = subtree:add(decoded_buf(), pinfo, subtree)
payloadPacTree:set_text("Payload")
payloadPacTree:set_text:add(Name_F, PayloadNameRange, PayloadName)
end
wireshark 中显示的结果不包含正确的日语字符,如下所示,
Payload
Name: 037\...
应该是这样的
Payload
Name: 山田太郎...
你能找出问题所在吗?谢谢。
尝试替换这些行:
Name_F = ProtoField.string("Name", "Name")
local PayloadName = PayloadNameRange:string(ENC_UTF_8)
有了这些:
Name_F = ProtoField.string("vps.Name", "Name", base.UNICODE)
local PayloadName = PayloadNameRange:raw()
另请参阅:
我一直在尝试用 UTF-8 表示日语解码中的二进制,但仍然没有弄清楚如何正确地进行。这是代码。
vps_proto = Proto("vps", "VPS Packet")
Name_F = ProtoField.string("Name", "Name")
vps_proto.fields = {Name_F}
function RequestAccountPayloadParse(decoded_buf, pinfo, subtree)
local PayloadNameRange = decoded_buf(0, 20)
local PayloadName = PayloadNameRange:string(ENC_UTF_8)
local payloadPacTree = subtree:add(decoded_buf(), pinfo, subtree)
payloadPacTree:set_text("Payload")
payloadPacTree:set_text:add(Name_F, PayloadNameRange, PayloadName)
end
wireshark 中显示的结果不包含正确的日语字符,如下所示,
Payload
Name: 037\...
应该是这样的
Payload
Name: 山田太郎...
你能找出问题所在吗?谢谢。
尝试替换这些行:
Name_F = ProtoField.string("Name", "Name")
local PayloadName = PayloadNameRange:string(ENC_UTF_8)
有了这些:
Name_F = ProtoField.string("vps.Name", "Name", base.UNICODE)
local PayloadName = PayloadNameRange:raw()
另请参阅: