我正在尝试使用lua在Wireshark的HTTP协议中分离字符串数据,但我没有成功找到字符串的结尾,这是我目前拥有的
HTTP_protocol = Proto("ourHTTP", "HTTPProtocol")
first =ProtoField.string("HTTP_protocol.first", "first", base.ASCII)
second =ProtoField.string("HTTP_protocol.second", "second", base.ASCII)
HTTP_protocol.fields = {first}
function HTTP_protocol.dissector(buffer, pinfo, tree)
length = buffer:len()
if length ==0 then return end
pinfo.cols.protocol = HTTP_protocol.name
local subtree = tree:add(HTTP_protocol, buffer(), "HTTPProtocol data ")
local string_length
for i = 0, length - 1, 1 do
if (buffer(i,1):uint() == '\r') then
string_length = i - 0
break
end
end
subtree:add(first, buffer(0,string_length))
end
porttable = DissectorTable.get("tcp.port")
porttable:add(80, HTTP_protocol)
我尝试搜索“ \ r”,“ \ 0”和“ \ n”,但是无论如何我仍然将所有输入的字符串作为一个输入。我在做错什么吗?