私はそれを手動で行う方法を知っています(16進ダンプを見ることによって)。同じものを自動的に取得するにはどうすればよいですか?APIを使用する必要がありますか?私はwiresharkとMicrosoftネットワークモニターの両方を持っています。
4 に答える
これは、次のスクリーンショットに示すように、HTTPヘッダーフィールドをパケットツリーに追加してフィルター処理できるLuaディセクタを使用するだけで実現できます。

このLuaスクリプトをプラグインディレクトリ(たとえば${WIRESHARK_HOME}/plugins/1.4.6/http_extra.lua)にコピーし、Wiresharkを再起動します(すでに実行されている場合)。
do
local http_wrapper_proto = Proto("http_extra", "Extra analysis of the HTTP protocol");
http_wrapper_proto.fields.hdr_len = ProtoField.uint32("http.hdr_len", "Header length (bytes)")
-- HTTP frames that contain a header usually include the HTTP
-- request method or HTTP response code, so declare those here
-- so we can check for them later in the dissector.
local f_req_meth = Field.new("http.request.method")
local f_resp_code = Field.new("http.response.code")
local original_http_dissector
function http_wrapper_proto.dissector(tvbuffer, pinfo, treeitem)
-- We've replaced the original http dissector in the dissector table,
-- but we still want the original to run, especially because we need
-- to read its data. Let's wrap the call in a pcall in order to catch
-- any unhandled exceptions. We'll ignore those errors.
pcall(
function()
original_http_dissector:call(tvbuffer, pinfo, treeitem)
end
)
-- if the request method or response code is present,
-- the header must be in this frame
if f_req_meth() or f_resp_code() then
-- find the position of the header terminator (two new lines),
-- which indicates the length of the HTTP header, and then add
-- the field to the tree (allowing us to filter for it)
local hdr_str = tvbuffer():string()
local hdr_len = string.find(hdr_str, "\r\n\r\n") or string.find(hdr_str, "\n\n\n\n")
if hdr_len ~= nil then
treeitem:add(http_wrapper_proto.fields.hdr_len, hdr_len):set_generated()
end
end
end
local tcp_dissector_table = DissectorTable.get("tcp.port")
original_http_dissector = tcp_dissector_table:get_dissector(80) -- save the original dissector so we can still get to it
tcp_dissector_table:add(80, http_wrapper_proto) -- and take its place in the dissector table
end
残念ながら、カスタム列を作成することはできますが、その列に必要なデータは現在HTTPプロトコルデコーダーによって生成されていません。もちろん、今日これを実行できる、私がよく知らない他のツールがあるかもしれませんが、Wiresharkに関する限り、その機能を追加する必要があります。
Wiresharkプラグインの作成に関する優れたリソースがいくつかあります。例:
http://simeonpilgrim.com/blog/2008/04/29/how-to-build-a-wireshark-plug-in/
http://www.wireshark.org/docs/wsdg_html_chunked/ChDissectAdd.html
http://www.codeproject.com/KB/IP/custom_dissector.aspx
また、プロトコルデコーダーによって公開されるフィールドをカスタム列として追加する方法を説明するビデオを次に示します。
http://www.youtube.com/watch?v=XpUNXDkfkQg
重要なのは、HTTPプロトコルデコーダーを再実装したくないということです。
私がすることは、組み込みのHTTPデコーダーのソースコードを見つけてhttp.header_length、既存のような新しいフィールドを追加することを検討することhttp.content_lengthです。

私はコードを見ていませんが、これは非常に簡単に追加できると思います。Wiresharkチームにパッチを送信すると、次のリリースに新しいフィールドも含まれる可能性があります。
user568493によって投稿されたコードは私にはまったく機能しなかったので、iv'eはそれをポストディセクタに変更しました。また、バイト数を正しくカウントしていませんでした。また、IPバイトとイーサネットバイトもカウントしていました。
これは私のバージョンで、1.8.2で動作します。
local http_wrapper_proto = Proto("http_extra", "Extra analysis of the HTTP protocol");
http_wrapper_proto.fields.hdr_len = ProtoField.uint32("http.hdr_len", "HTTP Header length (bytes)")
-- HTTP frames that contain a header usually include the HTTP
-- request method or HTTP response code, so declare those here
-- so we can check for them later in the dissector.
local f_req_meth = Field.new("http.request.method")
local f_resp_code = Field.new("http.response.code")
local original_http_dissector
function http_wrapper_proto.dissector(tvbuffer, pinfo, treeitem)
-- if the request method or response code is present,
-- the header must be in this frame
if f_req_meth() or f_resp_code() then
local start_offset = 0
local end_offset = 0
-- find the position of the header terminator (two new lines),
-- which indicates the length of the HTTP header, and then add
-- the field to the tree (allowing us to filter for it)
local hdr_str = tvbuffer():string()
if f_req_meth() then
start_offset = string.find(hdr_str, "GET")
end_offset = string.find(hdr_str, "\r\n\r\n")
end
if f_resp_code() then
start_offset = string.find(hdr_str, "HTTP")
end_offset = string.find(hdr_str, "\r\n\r\n")
end
local hdr_len = end_offset - start_offset + 4
-- 4 Bytes because the \r\n\r\n are not part of the HTTP Payload, hence should be counted in the header length.
if hdr_len ~= nil then
treeitem:add(http_wrapper_proto.fields.hdr_len, hdr_len):set_generated()
end
end
end
register_postdissector(http_wrapper_proto)
チェーン内の以前のディセクタを呼び出すこの方法は、「チャンク」転送エンコーディングに対して行われるHTTPパケットの再構築を何らかの形で妨害することがわかりました。つまり、応答に「Transfer-Encoding:chunked」ヘッダーがある場合、元のHTTPディセクタはデータを再アセンブルしようとし、そのようなhttp_wrapperでデータをフックすると、再アセンブルは失敗します。
たとえば、これによりhttp統計も失敗します。Statistics / HTTP / Packet Counterは、たとえば6つの要求と4つの応答を提供しますが、そうではありません=)
このような種類の「付加価値」ディセクタを「register_postdissector」API呼び出しでインストールするか、ロジックを慎重に再構築するためのテストを行う必要があります。