【发布时间】:2017-07-04 20:44:49
【问题描述】:
我在编写 lua 解析器时遇到了字符串问题。我的数据包看起来像:
0000 00 00 00 69 00 10 00 01 00 00 00 ed 00 00 00 0c
0010 bf a6 5f ...
调试时tvb看起来一样
偏移0x10处的字节是0xbf,但在我的解析器函数中我得到了不同的结果,这是我的代码:
local str = buf(0x10):string()
local x = string.byte(str, 1)
变量x应该是0xbf,但它是0xef,其他一些偏移量也是0xef:
local str = buf(0x11):string()
local x = string.byte(str, 1) -- also get 0xef, should be 0xa6
local str = buf(11):string()
local x = string.byte(str, 1) -- also get 0xef, should be 0xed
似乎大值总是会得到 0xef 作为结果,比如 0xa6/0xbf/0xed...
小值是正确的,比如 0x69/0x5f/0x0c...
我正在使用最新的wireshark 2.0,这是一个错误吗?
【问题讨论】:
-
什么是
:string()? -
对不起,我解释得不好,帖子更新了。 :string() 是wireshark内置函数,可以将tvb转换为字符串
-
尝试检查值:
buf(0x10), buf(0x10):string()。