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

AVTokyo 2020 Phishing Kit Analysis Workshop

ninoseki
October 31, 2020
940

AVTokyo 2020 Phishing Kit Analysis Workshop

ninoseki

October 31, 2020
Tweet

Transcript

  1. Phishing Kit Analysis
    Workshop
    AVTokyo 2020 (2020/10/31)
    @ninoseki, @sepi140 and @papa_anniekey

    View Slide

  2. 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?

    View Slide

  3. Before Starting...

    View Slide

  4. 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
    ■ 動的解析で使用するツール

    View Slide

  5. ⚠ Cautions
    ● 本物のphishing kitをサンプルとして使用します
    ● 使用するサンプルは第三者が収集・公開した物で、主催者とは関係がありません
    ● 使用するサンプルを絶対に悪用しないでください
    ● 自己責任での参加をお願いします
    ● 各種トラブルについて、主催者は一切責任を負いません

    View Slide

  6. What is Phishing
    Kit?

    View Slide

  7. What is Phishing Kit?
    ● Kit:
    ○ 道具一式、用具一式、道具箱、組立用部品一式、装具、装備、服装
    ● Phishing kit:
    ○ 攻撃者がphishing webサイトを構築するために使うスクリプト及び HTML/CSS等の一式
    ○ Open directoryやその他の手法で手に入ることがある
    (source: https://docs.apwg.org/ecrimeresearch/2018/5349207.pdf)

    View Slide

  8. What is Phishing Kit?

    View Slide

  9. What is Phishing Kit?

    View Slide

  10. Why Analyzing Phishing Kit?
    ● どのようにクレデンシャルが盗まれるのか?
    ○ 盗み取られたクレデンシャルの確認や、 abuse対応が可能になる
    ● どのような防御策(クローキング )をとっているのか?
    ○ クローキング対策が可能になる
    ● 攻撃者 or 開発者は誰か?
    ○ 然るべき機関(法執行機関、ナショナル CSIRT)と連携できるかも

    View Slide

  11. Ex. Static
    Analysis

    View Slide

  12. Ex. Static Analysis
    ● login.zip を展開してください
    ● Questions:
    ○ ターゲットにされているブランドは ?
    ○ 攻撃者のアドレスは ?
    ○ 開発者の名前は?
    ● 5分前に終わったら他のサンプルもチェックしてみましょう
    (5 minutes)

    View Slide

  13. Ex. Dynamic 
    Analysis

    View Slide

  14. Ex. Dynamic Analysis
    ● Phishpond:
    ○ Phishing kit 分析用の Docker 環境
    ○ 機能:
    ■ HTTPトラフィックのプロキシ (mitmproxy)
    ● ⚠ 使う前にInterceptの設定をしておきましょう
    ■ mail 呼び出しの記録 (PHP デフォルトの mail function をフッキング)
    ● ⚠ mail function 以外の手段でメールが送信されたフックされないので注意
    ● PHPMailer 等のライブラリを使っている場合はフックされないかも

    View Slide

  15. 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)

    View Slide

  16. Ex. Dynamic Analysis
    ● http://localhost:8080 をブラウザで開いてください
    ● Options > Edit Options に遷移してください
    ● ~q を Intercept に設定してください
    ○ ~q を設定すると、mitmproxy はすべてのリクエストをインターセプトします

    View Slide

  17. Ex. Dynamic Analysis
    ● http://localhost/login/login/index.htm をブラウザで開いてください
    ● Questions:
    ○ ターゲットにされているブランドは ?
    ○ 攻撃者のアドレスは ?
    (5 minutes)

    View Slide

  18. Ex. Dynamic Analysis
    ● Tips:
    ○ mitmproxy で Request の 中身を確認するときは、 View で適切なフォーマット (url-encoded)を設定
    してください

    View Slide

  19. What is
    Cloaking?

    View Slide

  20. What is Cloaking?
    ● Cloak:
    ○ ~にマント[外套]を着せる
    ○ 〔一面を〕覆う[包み込む]、覆い隠す
    ○ ~をクローキング[不可視状態に]する
    ● Cloaking (in today’s context):
    ○ Phishing kitのアクセス妨害機能のこと

    View Slide

  21. Ex. Analyze 
    Cloaking 
    Techniques

    View Slide

  22. Ex. Analyze Cloaking Techniques
    ● account.zip を展開してください
    ● Questions:
    ○ どのようなクローキング手法が使われている ?
    ○ “babushka”ってなに?
    (5 minutes)

    View Slide

  23. 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

    View Slide

  24. What is
    Obfuscation?

    View Slide

  25. What is Obfuscation?
    ● Obfuscation:
    ○ 〈心などを〉暗くする; 〈判断などを〉曇らせる .
    ○ 〈問題などを〉不明瞭にする,わかりにくくする .

    View Slide

  26. PHP Obfuscation
    (source: https://yonghwi-kwon.github.io/data/cubismo_acsac19_slides.pdf)

    View Slide

  27. Ex. Deobfuscate
    PHP Code

    View Slide

  28. Ex. Deobfuscate PHP Code
    ● ZS.zip を展開し、index.php を開いてください
    ● Q. 難読化される前のコードは?
    (1 minute)

    View Slide

  29. 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

    View Slide

  30. 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

    View Slide

  31. Ex. Deobfuscate PHP Code
    ● 16Shop-AMZ-V19.zip を展開し、auth.php を開いてください
    ● Q. 難読化される前のコードは?
    ○ ⚠ まずはツールを使わずにチャレンジしてみてください
    ○ ツールを使って完全自動では解けないかも
    ● ys.zip を展開し、index.php を開いてください
    ● Q. 難読化される前のコードは?
    (15 minutes)

    View Slide

  32. How to Collect
    Phishing Kits

    View Slide

  33. 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

    View Slide

  34. What is YARA?

    View Slide

  35. What is YARA?
    ● YARAとは:
    ○ The pattern matching swiss knife for malware researchers (and everyone else)
    ○ YARAは超強力な Grep みたいなもの

    View Slide

  36. Basics of YARA Rule
    ⬇ Rule name
    ⬇ Hex string
    ⬅ Text string

    View Slide

  37. 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

    View Slide

  38. Basics of YARA Rule

    View Slide

  39. Basics of YARA Rule

    View Slide

  40. 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 でスキャン

    View Slide

  41. Basics of YARA Rule
    ● CLI usage:
    ○ $ yara apple.yar -r /path/to/phishing_kits

    View Slide

  42. 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

    View Slide

  43. Why YARA?
    ● すでに知っているものを分類するため
    ● 未知のものを見つけるため
    ○ YARAルールにマッチしないサンプルがあれば、新しい種類の phsihing kitかも

    View Slide

  44. Ex. Write YARA
    Rules

    View Slide

  45. Ex. Write YARA Rules
    ● Questions:
    ○ Phishing kitをブランドごと(Apple, Amazon, etc.)に分類するYARAルールは?
    ○ Phishing kitを種類ごと(16shop, xBanana, etc.)に分類するYARAルールは?
    (20 minutes)

    View Slide

  46. If you want to know more...
    ● YARA docs:
    ○ https://yara.readthedocs.io/en/stable/
    ● Awesome YARA:
    ○ https://github.com/InQuest/awesome-yara

    View Slide

  47. Questions?

    View Slide

  48. Acknowledgements
    ● Thank you @sepi140, @papa_anniekey and @__Thanat0s__ for reviewing this
    material kindly.

    View Slide