私は手動で(16進ダンプを見て)それを行う方法を知っています。どうすれば同じものを自動的に入手できますか? APIを使用する必要がありますか?私はwiresharkとMicrosoftネットワークモニタの両方を持っています。パケットのHTTPヘッダー長を調べる方法は?
答えて
これは、このスクリーンショットのように、あなたはそれのためにフィルタリングすることができ、パケットツリーにHTTPヘッダフィールドを追加しLua dissectorで簡単に達成することができます:
コピー本の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ヘッダーの長さが表示されない。私はWindowsで作業しています。 – Bruce
@ブルース:** 1。**どのバージョンのWiresharkを実行していますか? ** 2。**メニュー "Tools"に行くと、サブメニュー "Lua"が表示されますか?そうでない場合、Luaは無効になります(標準インストールではデフォルトで有効)。 ** 3。** HTTPヘッダー長フィールドは、パケットにHTTPヘッダーが含まれている場合にのみ、パケット記述に追加されます。それを確認しましたか? –
@ Bruce:btw、Windows XP SP3のWireshark 1.4.6でこのスクリプトをテストしました。 –
残念ながら、カスタム列を作成することはできますが、その列に必要なデータは現在HTTPプロトコルデコーダによって生成されていません。もちろん、これにはまだ慣れていない他のツールがあるかもしれませんが、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
そしてここプロトコルによって公開されていますフィールドを追加する方法を説明したビデオだ:
あり、いくつかの良いリソースは、例えば、Wiresharkのプラグインを作成することにしていますデコーダをカスタム列として使用する場合:
http://www.youtube.com/watch?v=XpUNXDkfkQg
問題は、HTTPプロトコルデコーダを再実装したくないということです。私はどうなるのか
はのためのソースコードを見つけることであるHTTPデコーダを内蔵し、ちょうどhttp.content_length
既存のようにのようなhttp.header_length
を新しいフィールドを追加することを見て:
私は見ていませんコードでは、私はこれを追加するのはかなり簡単なことだと思います。 Wiresharkチームにパッチを提出すれば、次のリリースで新しいフィールドを追加することになるでしょう。
私は「チャンク」転送エンコードのために行われたHTTPパケットの再構成で何とかinterferreチェーン内の前の解剖器具を呼び出すこの方法ということがわかりました。つまり、あなたのレスポンスに 'Transfer-Encoding:chunked'ヘッダーがある場合、元のHTTPディセクタはデータを再構築しようとします。そのようなhttp_wrapperでフックすると、再アセンブリは失敗します。
たとえば、これによりhttp統計も失敗します。統計/ HTTP /パケットカウンターはあなたに6リクエストと4レスポンスを与えるでしょう=)
'register_postdissector' API呼び出しや再アセンブリのテストでこのような種類の '付加価値'ロジックは注意深く。
user568493によって投稿されたコードは私にとってはまったく機能しませんでした。したがって、それをポストディセクターに変更しました。また、正しくバイト数を数えていませんでした。 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)
- 1. Rの文字列の長さを調べる方法は?
- 2. SharpPcapでHTTPパケットをキャプチャする方法
- 3. postgres関数のvarcharパラメータの長さを調べる方法
- 4. JTableの各列のヘッダーを調べる
- 5. GeventでJoinableQueueの長さを調べる
- 6. デバッガでNSStringの長さを調べる
- 7. Rails:サーバーがクライアントに配信するHTTPレスポンスのサイズを調べる方法は?
- 8. HTTPヘッダーを取得する方法
- 9. 各テーブル行を調べる方法は?
- 10. 構造体を「調べる」方法は?
- 11. JavaのAndroidでhttpパケットを追跡する方法
- 12. WeblogicレスポンスのHTTPヘッダーの設定方法
- 13. iOSパケットの長さ
- 14. AudioQueueキューに入れられたデータの再生長を調べる方法
- 15. PHP + PDO/MySQL:VARCHARフィールドの長さを自動的に調べる方法
- 16. すべてのDjango応答にHTTPヘッダーを追加する方法
- 17. WebブラウザでHTTPステータスコードを調べる
- 18. HTTPリクエストでhttp cookie(ヘッダー)を設定する方法
- 19. httpヘッダーの最初の行を解析する方法は?
- 20. シリアルポートの使用方法を調べる
- 21. System.Runtime.Caching.ObjectCache内のキャッシュポリシーを調べる方法
- 22. URL http://www.test.com/abc.pdfがファイルかディレクトリかどうか調べる方法は?
- 23. 変数でhttpヘッダーの応答値を取る方法は?
- 24. nginxで非標準のHTTPヘッダーを取得する方法は?
- 25. HTTPヘッダーのUTF8ファイル名をエンコードする方法は? (Python、Django)
- 26. PHP Raw HTTPパケットを送信する方法
- 27. 呼び出し方法とクラス名を調べる方法は?
- 28. RobotFrameworkとJython:パフォーマンスを調べる方法
- 29. どのチェンジリストをコピーするのかを調べる方法は?
- 30. パケットをキャプチャする方法
あなたは、アプリケーションから、「自動的に」とは何を意味するのですか?キャプチャのどの部分がHTTPヘッダーなどであるかを調べるだけであれば、Wiresharkは自動的にパケットを解析します。任意のHTTPデータパケットを検索し、右クリックして「Follow TCP Stream」を選択すると、ヘッダーが明瞭に読み取れるHTTPトラフィックが表示されます。 –
@Tim:HTTPヘッダー長をバイトで知りたい私はHTTPの会話を見ることができますが、どのように私はHTTPヘッダーの長さを列として言うことができますか? – Bruce
私はあなたが "列として"を意味するか分からない。基本的には、HTTPリクエストの始めから最初の二重改行( '\ n \ n'または' \ r \ n \ r \ n')までTCPストリームを検索する必要があります。見つかったインデックスは、ヘッダーの長さです。これをWiresharkに表示するには、プラグインなどを開発する必要があります。あなたがテーブルや何かを処理するためにデータをダンプするのであれば、説明したように長さを計算する必要があります。 –