다음과 같은 방식으로 작동하는 클라이언트 서버 프로토콜이 있습니다.
클라이언트가 서버 ID가있는 udp 브로드 캐스트를 고정 포트로 보냅니다.
서버는 데이터 그램을 수신하고 서버가 자신의 ID와 일치하면 클라이언트에게 청취중인 포트를 보냅니다.
그런 다음 클라이언트는 해당 포트에 대해 tcp 연결을 엽니 다.
나는이 일을 위해 루아에 Wireshark 해부학자를 쓰고 있는데, 동적으로 TCP 연결을위한 포트를 설정해야한다. (서버가 청취하는 마녀 포트를 미리 모른다.)lua에 wireshark 해부기를 작성하고 동적 포트에 설정하기
-- declare our protocol
myproto_udp_proto = Proto("myproto_UDP","myproto UDP Protocol")
myproto_tcp_proto = Proto("myproto_TCP","myproto TCP Protocol")
-- create a function to dissect it
function myproto_tcp_proto.dissector(buffer,pinfo,tree)
pinfo.cols.protocol = "myproto TCP"
local subtree = tree:add(myproto_tcp_proto,buffer(),"myproto TCP Protocol Data")
if buffer(0,2):uint() == 0xF00D then
subtree:add(buffer(0,2),"Magic(F00D)")
else
subtree:add(buffer(0,2),"Bad Magic")
end
end
function myproto_udp_proto.dissector(buffer,pinfo,tree)
pinfo.cols.protocol = "myproto UDP"
local subtree = tree:add(myproto_udp_proto,buffer(),"myproto UDP Protocol Data")
if buffer(0,2):uint() == 0xF00D then
subtree:add(buffer(0,2),"Magic(F00D)")
local command;
local port = -1;
if buffer(2,1):uint() == 01 then
command = "Searching for server"
elseif buffer(2,1):uint() == 02 then
command = "I'm server"
port = buffer(7,2):uint()
else
command = "unknown";
end
subtree:add(buffer(2,1),command)
subtree:add(buffer(3,4),"Server id: " .. buffer(3,4):uint())
if port ~= -1 then
subtree:add(buffer(7,2),"Server listening port: " .. buffer(7,2):uint())
subtree:add(buffer(9,4),"check bytes")
myproto_tcp_init(port)
end
else
subtree:add(buffer(0,2),"Bad Magic")
end
end
-- load the udp.port table
udp_table = DissectorTable.get("udp.port")
-- register our protocol to handle udp port 1338
udp_table:add(1338,myproto_udp_proto)
function myproto_tcp_init(port)
-- load the tcp.port table
tcp_table = DissectorTable.get("tcp.port")
-- register our protocol to handle tcp port !DYNAMIC!
tcp_table:add(port,myproto_tcp_proto)
end
나는 무엇을 누락 :
나는 그런 뭔가를 시도?
미리 감사드립니다.
포트 값의 엔디안을 확인 했습니까? – harper
"내가 무엇을 놓치고 있습니까?" 오류 메시지 또는 작동하지 않는 것에 대한 설명은 어떻습니까? – BMitch