Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AVTokyo 2020 Phishing Kit Analysis Workshop

ninoseki
October 31, 2020
1.1k

AVTokyo 2020 Phishing Kit Analysis Workshop

ninoseki

October 31, 2020
Tweet

Transcript

  1. Agenda 1. What is phishing kit? 2. What is cloaking?

    3. What is PHP obfuscation? 4. How to collect phishing kits? 5. What is YARA?
  2. Requirements and Preparations • Software requirements: ◦ PHP ◦ Git

    ◦ YARA ◦ IDE or editor ◦ Docker • Preparations: ◦ $ git clone https://github.com/dubstard/phishing_kits.git ▪ ワークショップで分析するサンプル ◦ $ git clone https://github.com/zerofox-oss/phishpond.git ◦ $ cd phishpond & docker-compose build ▪ 動的解析で使用するツール
  3. What is Phishing Kit? • Kit: ◦ 道具一式、用具一式、道具箱、組立用部品一式、装具、装備、服装 • Phishing

    kit: ◦ 攻撃者がphishing webサイトを構築するために使うスクリプト及び HTML/CSS等の一式 ◦ Open directoryやその他の手法で手に入ることがある (source: https://docs.apwg.org/ecrimeresearch/2018/5349207.pdf)
  4. Why Analyzing Phishing Kit? • どのようにクレデンシャルが盗まれるのか? ◦ 盗み取られたクレデンシャルの確認や、 abuse対応が可能になる •

    どのような防御策(クローキング )をとっているのか? ◦ クローキング対策が可能になる • 攻撃者 or 開発者は誰か? ◦ 然るべき機関(法執行機関、ナショナル CSIRT)と連携できるかも
  5. Ex. Static Analysis • login.zip を展開してください • Questions: ◦ ターゲットにされているブランドは

    ? ◦ 攻撃者のアドレスは ? ◦ 開発者の名前は? • 5分前に終わったら他のサンプルもチェックしてみましょう (5 minutes)
  6. Ex. Dynamic Analysis • Phishpond: ◦ Phishing kit 分析用の Docker

    環境 ◦ 機能: ▪ HTTPトラフィックのプロキシ (mitmproxy) • ⚠ 使う前にInterceptの設定をしておきましょう ▪ mail 呼び出しの記録 (PHP デフォルトの mail function をフッキング) • ⚠ mail function 以外の手段でメールが送信されたフックされないので注意 • PHPMailer 等のライブラリを使っている場合はフックされないかも
  7. Ex. Dynamic Analysis • login.zip を展開してください • Commands: ◦ $

    mv login /path/to/phishpond/www/ ◦ $ cd /path/to/phishpond/ ◦ $ docker-compose up -d • Phishpond: ◦ http://localhost/welcome.php ▪ ➡ Sandbox ◦ http://localhost:8080 ▪ ➡ mitmproxy (5 minutes)
  8. Ex. Dynamic Analysis • http://localhost:8080 をブラウザで開いてください • Options > Edit

    Options に遷移してください • ~q を Intercept に設定してください ◦ ~q を設定すると、mitmproxy はすべてのリクエストをインターセプトします
  9. Ex. Dynamic Analysis • Tips: ◦ mitmproxy で Request の

    中身を確認するときは、 View で適切なフォーマット (url-encoded)を設定 してください
  10. What is Cloaking? • Cloak: ◦ ~にマント[外套]を着せる ◦ 〔一面を〕覆う[包み込む]、覆い隠す ◦

    ~をクローキング[不可視状態に]する • Cloaking (in today’s context): ◦ Phishing kitのアクセス妨害機能のこと
  11. Ex. Analyze Cloaking Techniques • account.zip を展開してください • Questions: ◦

    どのようなクローキング手法が使われている ? ◦ “babushka”ってなに? (5 minutes)
  12. If you want to know more... • CrawlPhish: Large-scale Analysis

    of Client-side Cloaking Techniques in Phishing (2020) ◦ http://www.public.asu.edu/~pzhang57/papers/crawlphish.pdf • 動的解析を利用したフィッシングサイトのアクセス妨害機能の実態解明 (2019) ◦ https://ipsj.ixsq.nii.ac.jp/ej/?action=pages_view_main&active_action=repository_view_main_ite m_detail&item_id=204261&item_no=1&page_id=13&block_id=8 • World-wide cloaking phishing websites detection (2017) ◦ https://lib.dr.iastate.edu/cgi/viewcontent.cgi?article=7372&context=etd
  13. Ex. Deobfuscate PHP Code • 汎用的な deobfuscate ツール: ◦ https://gchq.github.io/CyberChef/

    ◦ お好きなプログラミング言語 . • PHP 専用の deobfuscate ツール: ◦ http://ddecode.com/phpdecoder/ ▪ ⚠ アップロードしたものは全てパブリックに公開される ◦ https://www.unphp.net/ ▪ ⚠ 同上 ◦ https://github.com/simon816/PHPDeobfuscator ◦ https://github.com/bediger4000/reverse-php-malware
  14. Ex. Deobfuscate PHP Code • https://github.com/simon816/PHPDeobfuscator ◦ eval, base64, file-system

    virtualization など ◦ Install: ▪ $ git clone https://github.com/simon816/PHPDeobfuscator.git ▪ $ cd PHPDeobfuscator ▪ $ composer install ▪ $ php index.php • https://github.com/bediger4000/reverse-php-malware ◦ eval, base64, $GLOBALS など ◦ Install: ▪ $ git clone https://github.com/bediger4000/reverse-php-malware.git ▪ $ cd reverse-php-malware ▪ $ composer install ▪ $ ./revphp
  15. Ex. Deobfuscate PHP Code • 16Shop-AMZ-V19.zip を展開し、auth.php を開いてください • Q.

    難読化される前のコードは? ◦ ⚠ まずはツールを使わずにチャレンジしてみてください ◦ ツールを使って完全自動では解けないかも • ys.zip を展開し、index.php を開いてください • Q. 難読化される前のコードは? (15 minutes)
  16. OSS Tools to Collect Phishing Kits • https://github.com/t4d/StalkPhish (⭐ 212)

    ◦ The Phishing kits stalker, harvesting phishing kits for investigations. • https://github.com/ninoseki/miteru (⭐ 117) ◦ An experimental phishing kit detection tool • https://github.com/duo-labs/phish-collect (⭐ 101) ◦ Python script to hunt phishing kits • https://github.com/marcoramilli/PhishingKitTracker (⭐ 87) ◦ Let's track phishing kits to give to research community raw material to study ! • https://github.com/swimlane/trawl (⭐ 21) ◦ A utility to trawl phishing domains and attempt to identify phishing kits as well as other malicious activity
  17. What is YARA? • YARAとは: ◦ The pattern matching swiss

    knife for malware researchers (and everyone else) ◦ YARAは超強力な Grep みたいなもの
  18. Basics of YARA Rule • Conditions: ◦ ($a or $b)

    and ($c or $d) ◦ 2 of ($a,$b,$c) ◦ 1 of them ◦ all of them • Quantifiers (数量詞): ◦ * : Match 0 or more times ◦ + : Match 1 or more times ◦ ? : Match 0 or 1 times ◦ {n} : Match exactly n times ◦ {n,} : Match at least n times ◦ {,m} : Match at most m times ◦ {n,m} : Match n to m times
  19. Basics of YARA Rule • CLI usage: ◦ $ yara

    rule.yar /tmp/test.txt ▪ /tmp/test.txt を rule.yar ルールでスキャン ◦ $ yara rule.yar -r /tmp ▪ /tmp 配下のファイルを rule.yar でスキャン
  20. Basics of YARA Rule • CLI usage: ◦ $ yara

    apple.yar -r /path/to/phishing_kits
  21. Tips • IDE プラグイン: ◦ VS Code: ▪ https://marketplace.visualstudio.com/items?itemName=infosec-intern.yara ◦

    Vim: ▪ https://github.com/s3rvac/vim-syntax-yara • アーカイブファイルの中身をスキャンしたい場合: ◦ 予めファイルを展開しておく ◦ Yextend を使う ▪ https://github.com/BayshoreNetworks/yextend
  22. Ex. Write YARA Rules • Questions: ◦ Phishing kitをブランドごと(Apple, Amazon,

    etc.)に分類するYARAルールは? ◦ Phishing kitを種類ごと(16shop, xBanana, etc.)に分類するYARAルールは? (20 minutes)
  23. If you want to know more... • YARA docs: ◦

    https://yara.readthedocs.io/en/stable/ • Awesome YARA: ◦ https://github.com/InQuest/awesome-yara