2017-03-09 13 views
4

I 많은 HTTP 트랜잭션을 보유하고있는 매우 큰 PCAP을 분석합니다. 그 중 일부는 저에게 흥미 롭습니다. 근본적으로 필터와 일치하는 모든 패킷을 쿼리하기 위해 Lua 스크립트와 함께 tshark을 사용하고 있습니다.청취자와 함께 TCP 스트림 번호를 얻는 방법은 무엇입니까?

tshark -X lua_script:filter.lua -r some.pcap -q 

지금까지는 그렇게 좋았습니다. 그러나, 나는 특별히 Wireshark 내부에서 tcp.stream이라는 이름으로가는 패킷의 TCP 스트림 번호의 가치를 찾고있다. 아무도 그걸 인쇄하려면 filter.lua을 변경해야한다고 말할 수 있습니까?

-- filter.lua 
do 
    local function init_listener() 
     local tap = Listener.new("http","http contains someKeyValue && tcp.port eq 1234") 
     function tap.reset() 
     end 
     function tap.packet(pinfo,tvb,ip) 
      print("Found my packet ... now what?") 
     end 
     function tap.draw() 
     end 
    end 
    init_listener() 
end 

pinfo, tvbip이 unforthcoming입니다 무엇에 대한 설명서를 참조하십시오.

답변

9

Field을 통해 TCP 스트림 번호에 액세스 할 수 있습니다.

local tcp_stream = Field.new("tcp.stream").value 

Field의 값은 현재 패킷에 대한 값이다. 매번 새로운 Field을 만들 필요가 없습니다. 이렇게하면 Field을 상수로 만들고 현재 패킷의 TCP 스트림 번호를 반환하는 함수를 만들 수 있습니다. Field 값을 호출하여 FieldInfo 값을 얻을 수도 있습니다. 여기에는 유용한 정보가 추가로 포함될 수 있습니다.

-- filter.lua 
do 
    local function init_listener() 
     local get_tcp_stream = Field.new("tcp.stream") 
     local tap = Listener.new("http","http contains someKeyValue && tcp.port eq 1234") 
     function tap.reset() 
     end 
     function tap.packet(pinfo,tvb,ip) 
      print(tostring(get_tcp_stream())) 
     end 
     function tap.draw() 
     end 
    end 
    init_listener() 
end 

https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Field.html#lua_class_Field

:

당신은 같이 할 수 filter.lua을 원하는