Code Monkey home page Code Monkey logo

Comments (11)

shun159 avatar shun159 commented on September 14, 2024

まず、ワークフローについて。

①パーステストの為のバイナリ解析について

  • pcapファイルを入手(http://wiki.wireshark.org/SampleCaptures になければ、環境作って採取)
  • wiresharkからhex形式でコピー
    • ここで得られるもの

      0000 00 11 22 33 44 55 00 40 d0 a2 bb 4e 08 00 45 00 0010 00 3c 61 bf 00 00 80 01 7d 63 ac 1e 01 64 ac 1e 0020 01 fe 08 00 6b 5b 02 00 e0 00 61 62 63 64 65 66 0030 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 0040 77 61 62 63 64 65 66 67 68 69

  • 16バイトごとに頭についている2バイトのデータを削る。
    • ここで得られるもの

      00 11 22 33 44 55 00 40 d0 a2 bb 4e 08 00 45 00 00 3c 61 bf 00 00 80 01 7d 63 ac 1e 01 64 ac 1e 01 fe 08 00 6b 5b 02 00 e0 00 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 61 62 63 64 65 66 67 68 69

  • 1バイトごとに, 0xを頭に追記し、改行を除く。で、配列にする。
    • ここで得られるもの
[0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x00, 0x40, 0xd0, 0xa2, 0xbb, 0x4e, 0x08, 0x00, 0x45, 0x00
, 0x00, 0x3c, 0x61, 0xbf, 0x00, 0x00, 0x80, 0x01, 0x7d, 0x63, 0xac, 0x1e, 0x01, 0x64, 0xac, 0x1e
, 0x01, 0xfe, 0x08, 0x00, 0x6b, 0x5b, 0x02, 0x00, 0xe0, 0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66
, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76
, 0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69]
  • 各フィールドごとに改行を入れる。
  • xxx_spec.rbに貼付。

後程、生成テスト時のバイナリ評価の際のワークフローをお伝え致します。

from pio.

shun159 avatar shun159 commented on September 14, 2024

生成テスト時のバイナリ評価の際のワークフローとしては、
それほどの手順はないので、あれですが実際に環境を構築して
スイッチに接続した端末側でキャプチャして、内容を確認するくらいです。

で、開発のはじめに必要なデータから最終的な実機環境で得るファイルの
inとoutでのファイルは結局pcapファイルという感じです。

そのため、あくまで私的な意見ですが、
pcapデータ <---->Array(or バイナリ)
で相互に変換できる機能を実装したツールが
必要だと思っています。
で、in/outをpcapにすることで、以下の利点もあるのかと存じます。

  • パース失敗時のデータを視覚的にみれる。
    • もし、パース失敗時のイシュー等が上がった場合でも、開発者側の色々な手間をへらせる。
  • 実機環境での試験をなくせる(いいのかどうか"等"は、相談させてください)

いかがでしょうか。
指摘事項などあればお願いします。

from pio.

sugyo avatar sugyo commented on September 14, 2024

pcapを読み書きするだけなら、下記のような感じでできます。bindataの勉強を兼ねて作成しました
https://gist.github.com/sugyo/8347181

from pio.

shun159 avatar shun159 commented on September 14, 2024

@sugyo
ありがとうございます。
こんなすぐに作っていただけるなんて…
機能的にも満足しています。

テストなどでさっと使えるようになっていれば、
ものすごく助かりますね。
今、#to_binaryや#new周りのテストは事前のバイナリを基にして
やっている場合もあるので、それをこのツールを利用するなどすれば、、
> 各フィールドごとに改行を入れる。
がいらなくなりますので。。。これだけでも無駄な手間が減らせるような気がします。
テストのやり方を変更するということは、今更難しいのでしょうか。

テスト方法まで話が及んでしまい、恐縮ですが、
何卒、宜しくお願い致します。

from pio.

yasuhito avatar yasuhito commented on September 14, 2024

パケットのデータは _spec.rb にベタ書きしてあったほうが分かりやすいと思います。
Array で改行入れるのも、変換ツールがやればいいわけですし。

from pio.

shun159 avatar shun159 commented on September 14, 2024

承知しました。ご教授有難う御座います。

また、こういったテストツールは別のプロジェクト等で管理しますか?
もしくは、pioに追加となりますでしょうか。

どちらがベターかあまりよく知らないのですが、
もし、宜しければご教授頂ければ幸いです。

from pio.

yasuhito avatar yasuhito commented on September 14, 2024

pio に入れちゃいましょう。

from pio.

shun159 avatar shun159 commented on September 14, 2024

承知しました、有難う御座います。

from pio.

shun159 avatar shun159 commented on September 14, 2024

インターフェイスの仕様とかについて、
もし宜しければ、こちらで相談・議論させてください!

宜しくお願いします。

from pio.

yasuhito avatar yasuhito commented on September 14, 2024

c8be00d で pcap -> Array を出力する rake タスクを追加しておきました。

from pio.

shun159 avatar shun159 commented on September 14, 2024

有難う御座います。
承知致しました。

from pio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.