LoginSignup
1
0

More than 3 years have passed since last update.

MacOSX Mojave で AFL を使う

Last updated at Posted at 2019-12-20

導入

MacOSX で AFL を試すまでの手順とワナのご紹介です。

AFL(American fuzzing loop)はプログラムにデータのエントリポイントを埋め込むタイプのファザーで、さまざまなファジングフレームワークのエンジンとしても利用されています

参考:

https://github.com/google/oss-fuzz

手順

ソースコードの取得。試した時点では2.52bが降ってきました。展開して、make します。

$ wget http://lcamtuf.coredump.cx/afl.tgz
$ tar -vxzf afl.tgz

$ cd afl-2.5.2b
$ make
...

WARNING: Fuzzing on MacOS X is slow because of the unusually high overhead of
fork() on this OS. Consider using Linux or *BSD. You can also use VirtualBox
(virtualbox.org) to put AFL inside a Linux or *BSD VM.

MacOS は fork() の負荷が高いので、ファジングが凄まじく遅くなるそうです。BSDか、VirtualBox上のBSD環境での実行を検討してくださいとのこと。*ワナ1

次にテスト用のシードファイルを作成します。

$ mkdir test_in
$ echo -n 'hoge' > test_in/hello

いよいよ実行、、しようとすると abort します。

$ ./afl-fuzz -i test_in -o test_out ./a.out

[-] Whoops, your system is configured to forward crash notifications to an
    external crash reporting utility. This will cause issues due to the
    extended delay between the fuzzed binary malfunctioning and this fact
    being relayed to the fuzzer via the standard waitpid() API.

    To avoid having crashes misinterpreted as timeouts, please run the
    following commands:

    SL=/System/Library; PL=com.apple.ReportCrash
    launchctl unload -w ${SL}/LaunchAgents/${PL}.plist
    sudo launchctl unload -w ${SL}/LaunchDaemons/${PL}.Root.plist

MacOSX Mojave 環境ではクラッシュレポートが外部ユーティリティに転送されるため、ファジングエンジンがこれを認識するまでの間にタイムアウトしてしまう、そうです。ので、ファジング実行時にはこれを一時的にオフにする必要があります。書いてある通り following commands を順に打ってOFFにします。*ワナ2

再度実行。

$ ./afl-fuzz -i test_in -o test_out ./a.out

afl.png

無事動作しました、、が、警告のとおり、遅いです。ファジングというかMacの負荷テストみたいになります。

参考

基本的な手順はこちらを参照させていただきました。ありがとうございます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0