MMS - PacSec

スマフォを吹き飛ばせ
自分のSMS/MMSファザーを構築すること
Brian Gorenc, Manager, Vulnerability Research
Matt Molinyawe, Security Researcher
本日の内容
• 
• 
• 
• 
• 
2
自己紹介
バグハンティング
テスト環境
ライブ・デモ
まとめ
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
自己紹介
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Brian Gorencとは何者?
勤務先:
HP
所属組織:
HP Security 調査
Zero Day イニシアチブ
職責 :
Manager, Vulnerability Research(脆弱性リサーチのマネージャ)
Pwn2Own コンテストを主宰
「EIP == 0x41414141」を検証
余暇の過ごしかた:
ツイッター:
4
コードを見てめったに見つからない脆弱性をひたすら追いかける
@MaliciousInput, @thezdi
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Matt Molinyaweとは何者?
勤務先:
HP
所属組織:
HP Security 調査
Zero Day イニシアチブ
職責:
Security Researcher(セキュリティ研究員)
おもしろくていけてるPoCを楽しむ
YouTubeを観た時間で生産性を計る
プロセス管理人:攻撃を輝かせる、失敗させない
Pwn2Ownに出てくる全ての計算機の目利き
余暇の過ごしかた:
ツイッター:
5
DJ Manila Ice – 全米DJコンテスト最終戦に2回進出
2014年にPwnie Awardsにノミネートされた“Security Kate”を作詞作曲
魂斗羅のレーザーガンだけでの攻略
QWOPの攻略
格闘技
@djmanilaice
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
“Do-It-Yourself(今回のは日曜大工的な調査)”
SMSやMMSへのファジングは興味深い
常に「ON」の状態にある技術
インラインでの防御は限られている
アップデート能力も限られている
各々の研究者は異なった方法を試している
大抵の場合は変化ロジックを備えたファジングツールを作成
今回の狙いは、電話へのファジングを始めるためのアプローチをデモすること
デバイスはAndroidを使用
6
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
バグハンティング
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
メッセージング・サービス
ペイロードを届ける
ショート・メッセージ・サービス (SMS)
3GPP TS 23.040
保存と転送を行う技術
異なる文字セットと拡張メッセージをサポート
マルチメディア・メッセージング・サービス (MMS)
オープン・モバイル・アライアンス(OMA)による標準仕様
音、動画、画像の送信が可能
マルチメディア・メッセージング・サービスセンターを通じてメッセー
ジを転送
緊急時のアラート・メッセージ配信 (CMAS)
テキストベースのアラート・メッセージ配信D
•  国家的非常時、生活を脅かす緊急事態、子どもの誘拐や失踪等の警報
国家的非常時はオプトアウト不可
8
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
ファイルフォーマット
音
動画
"audio/aac”, "audio/amr”, "audio/imelody”,
"audio/mid”, "audio/midi”, "audio/
mp3”,"audio/mpeg3”, "audio/mpeg”, "audio/
mpg”, "audio/mp4”, "audio/x-mid”, "audio/xmidi”, "audio/x-mp3”, "audio/x-mpeg3”,
"audio/x-mpeg”, "audio/x-mpg”,"audio/3gpp”,
"audio/x-wav”, "application/ogg"
"video/3gpp”, "video/3gpp2”, "video/h263”,
"video/mp4”
画像
"image/jpeg”, "image/jpg”, "image/gif”,
"image/vnd.wap.wbmp” ,"image/
png”,"image/x-ms-bmp”
その他
"text/x-vCalendar”, "text/x-vCard"
対応しているファイルフォーマットを簡単に探すことのできるソース:
•  https://github.com/klinker41/android-smsmms/blob/master/src/com/google/android/mms/
ContentType.java
•  AOSPをダウンロード (http://source.android.com)
•  サムソンからのソースコード (http://opensource.samsung.com/reception.do)
•  rgrep を mime, image/, audio/, video/ で実行
9
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
ファジングのフレームワーク
シード
ライブラリ
https://samples.libav.org/
http://samples.mplayerhq.hu/
Google out some file formats with filetype:
operator
Hachoir
突然変異ライブラリ
vcards および vcal を作成
•  http://vobject.skyhouseconsulting.com/
•  https://pypi.python.org/pypi/vobject
Pduフォーマットをファジング
•  https://pypi.python.org/pypi/smspdu/
10
•  https://bitbucket.org/haypo/hachoir/wiki/Home
Radamsa
•  https://www.ee.oulu.fi/research/ouspg/
Radamsa
•  https://code.google.com/p/ouspg/wiki/
Radamsa
クラッシュ事案の優先順位付け
独自のgdbラッパーを組み込んで、データ
ベースをバックエンドに持つファジング用Web
アプリケーションをつくるのはとても簡単
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
テスト環境
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
仮想ラボと設定
Android エミュレーション
簡単に手に入る -> http://developer.android.com/sdk
仮想ARMをつくるのは簡単:
•  android create avd –n MyDeviceName –t android-19 –b default/armeabi-v7a
•  UIには android avd を使用
AVDを生成して火を入れるスクリプトを書く
iOS エミュレーション
デフォルトのメッセージングアプリケーションが無い
でも、それが、マルチメディアファイルを開かない理由にはならない
Windows フォン エミュレーション
SDKをここから引っ張ってくる http://dev.windowsphone.com/en-us/downloadsdk
12
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Android エミュレータのオプション
タダでつくれるので電話よりも安い
Android SDK
複数のAPIバージョンをテストできる
•  ARM イメージ
•  x86 イメージ
エミュレーションが遅くなる傾向に有る
Genymotion
高速な x86 Virtualbox 仮想マシン
使いやすいインターフェース
genymotion.com からダウンロード可能
13
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
デバッグ
仮想デバイスにデバッガを装着
Android仮想デバイス上:
•  シェルでデバイスに入る
•  プロセス“com.android.mms” とmediaserver にアタッチさせてgdbserver を実行
-  gdbserver :5039 –attach 1234
•  トラフィックをTCPポートに転送
-  adb forward tcp:5039 tcp:5039
ホストマシン上:
•  Android NDKをダウンロード: http://developer.android.com/tools/sdk/ndk/index.html
•  プレビルド版 gdb を実行: arm-linux-androideabi-gdb for example
•  デバッグセッションで下記のコマンドを実行:
-  target remote :5039
Pythonでデバッガのアウトプットをアタッチして制御し取得
デバッガのアウトプットをWebアプリとデータベースにプッシュ
これでデバッグ開始!
14
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
エミュレータをスクリプトで自動化
エミュレータ上でSMSをファジング:
“send pdu” でPDUフォーマットメッセージをテルネット・チャネルで送信
•  この分野では既に多くの研究有り
MMSでの最初の失敗 – 何度も失敗することで学ぶことが成功へつながる
MMSネットワークをエミュレータで動かすために数週間トライし続けた、弾には諦めるのも良
い・・・
MMSをバックアップ
EasyBackup に注目
•  エミュレータにインストール
•  自分の電話からMMSメッセージをエミュレータにリストア可能
•  やった!!!これでエミュレータ上でMMSメッセージをつくれる!
ネット上でコードその他を物色
mmssms.db(SQLiteデータベース)をjavaコードを書かずに操作できることを確信(やった!
Mattは燃え尽きたSun Certified Enterprise Architectだから・・・)
15
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
エミュレータをスクリプトで自動化
クリーンな状態の mmssms.db を保存して変更後のデータベースと比較
adbでクリーンな状態のデータベースを引っぱり、変更した後に新しいデータベースを
プッシュ
•  興味深いディレクトリ
–  /data/data/com.android.providers.telephony/databases – mmssms.db が存在
–  /data/data/com.android.providers.telephony/app_parts – アタッチメントの送信先
MMSを偽の番号に送信
テーブルを変更: pdu、addr、part、 canonical_addresses 、threads
•  Python と sqlite3 で簡単に自動化
変更した mmssms.db を電話に戻す
パーミッションをradio:radio に戻したことを確認
Monkeyrunner
http://developer.android.com/tools/help/monkeyrunner_concepts.html
•  電話の上でクリックしたりテキストを送信することに使用
•  実際にはSDKツール中でのJythonスクリプトによる自動化
•  しかし、シェルコマンドにも対応・・・
16
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
シェルで電話に入る– coordinateを取得
17
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
シェルで電話に入る– (画面上の)ポインタ情報
18
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
シェルで電話に入る– XY 座標
入力コマンド:
input tap <x> <y>
XとYは直近の値に連動させることも含めて自
由に設定可能
この絵は、ZDIの殴り書き、Zを頭に乗せた人で
はない
19
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
マルチメディア ファジングケースの生成と展開
20
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
「切り刻んだ絵を貼り合わせた」テストケース
21
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
エミュレータをクラッシュさせるビデオ
22
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
より意味のあるデバッグ –AOSP を SDK エミュレータの
ためにビルド
23
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
マルチメディアファイルをインテントで開く
ファイルをプッシュ:
adb –s emulator-5554 push myfile.png /sdcard/myfile.png
インテントを実行:
adb –s emulator-5554 am start –a android.intent.action.View –d file:///sdcard/myfile.png -t
image/*
adb –s emulator-5554 am start –a android.intent.action.View –d file:///sdcard/myfile.mp3 -t
audio/*
adb –s emulator-5554 am start –a android.intent.action.View –d file:///sdcard/myfile.mp4 -t
video/*
これは、メッセージングプロセス・テーブルを取り扱わずにクラッシュさせることにだけ注力する場
合に、ファイルをSMSデータベースに送り込むためのもう一つの方法
24
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
GDBスクリプトファイルとAOSP(-x スイッチ)を使ったより
意味のあるデバッグ
25
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
AOSP デバッグ: シンボルとソースをデバッグすること
は有効
クラッシュ事案の優先順位付けを行うことができる
ARMやx86の命令を見ることすら必要ないかもしれない
クラッシュ事案のバックトレースからソースコードと行番号がわかる
ソースコードを素早く確認することができ、また、要点を多く見つけることができるので有効
arm-eabi-gdbを、AOSPソースに含まれるbuild/envsetup.sh におけるgdbclient 関数のように
セットアップする
26
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
リアルなラボと設定
ハードウェア
RX/TX
•  Universal Software Radio Peripheral (USRP)
•  BladeRF
•  RangeNetworks Device
電波輻射制御
•  RF エンクロージャ
ソフトウェア
OpenBTS - http://www.openbts.org/
NanoBTS - http://openbsc.osmocom.org/trac/wiki/nanoBTS
基地局情報 - http://openbsc.osmocom.org/trac
デバッグ・ツール – プラットフォームについてくるもの、もしくは、別途購入
電話およびその他の機材
ファジングのターゲットとしての気に入った電話
SIMカード
27
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Photo: HP ZDI
OpenBTS
OpenBTSのセットアップ
https://github.com/RangeNetworks/dev/wiki
Ubuntu 12.04 32-bit を VM 上で使用
OpenBTSのためのバイナリをビルド&検索
よく参考にしたリンク
•  https://wush.net/trac/rangepublic/wiki/BuildInstallRun
•  svn co コマンドでチェックアウト http://wush.net/svn/range/software/public
--with-uhd (Ettus N210 USRP) でビルド
簡単に行うため、トランシーバーは svn チェックアウトでビルドし、4.0バイナリをインストールした
Ettus N210 をサポートするためのUHDドライバ
ここで入手可能: http://code.ettus.com/redmine/ettus/projects/uhd/wiki/UHD_Linux
UHDドライバがビルドされた後はUSRPで通信するために下記のコマンドを使用:
•  uhd_find_device
•  uhd_usrp_probe
28
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
USRP/アンテナ/ケーブル
Ettus N210 USRP
29
VERT900 アンテナ
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
SMA ケーブル
RF エンクロージャ(電波輻射制)
Ramsey STE3000FAV: http://www.ramseytest.com/product.php?pid=10
30
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
電話/SIMカード
好きな電話を選択
Android
iPhone
Windows フォン
ブラック・ベリー
その他
GSM
AT&Tネットワークに見せかけるためにGSM
ネットワークをRFエンクロージャの中でセット
アップ
•  GSM.Identity.MCC を310にセット
•  GSM.Identity.MNC を410にセット
SIM カード
巨大スーパーで購入
31
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
機材にかかった経費
USRP とアクセサリ
RF エンクロージャとアクセサリ
USRP N210 Kit (782747-01) - $1,717.00
WBX-40 USRP ドーターボード - $480.00
USRP GPS-対応 発振キット - $758.00
SMA-to-SMA ケーブルアセンブリ - $30.00
VERT900 デュアルバンド垂直アンテナ- $35.00
合計: $3,020.00
STE3000FAV - $2,495.00
SMA コネクタ
DB9 10 PF およびDB9 100 PF コネクタ
USB, RJ45 アダプタ・キット
合計: $3,096.00
電話とSIMカード
ロック解除された電話 ~ $500
プリペイドSIM ~ $10-$20
Micro SIM カッター ~ $5
合計: ~$550
32
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
OpenBTSを起動
33
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
System Readyの状態
34
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Android上でUSRPに接続
35
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Android上でUSRPに接続
36
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
tmsis –接続されたデバイスをチェック
37
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
OpenBTSでメッセージを送信
38
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
基本的なテキストメッセージ
39
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
MMSを電話に送信
NowSMS
Windows上で動作するSMS/MMS ゲートウェイ
多くのモバイルプロトコルが実装されている
AndroidデバイスをGSMモデムとして使用できる
MMSゲートウェイ経由でメッセージを送信できる
電話の上でセットアップ
APN設定画面でMMSサーバURLを設定
アプリはここからインストール: http://www.nowsms.com/apk
セットアップの解説書
このpdfを読めば、上司が休んでいる日に自分のPCから上司宛にMMSを送ることができる:
http://www.nowsms.com/download/nowsms-android-quickstart.pdf
40
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
MMSを電話に送る – NowSMS ゲートウェイ
Android携帯に対してSMSCコネクションを追加
41
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
MMSを電話に送る – NowSMS ゲートウェイ
42
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
MMSを電話に送る – NowSMS ゲートウェイ
43
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
MMSを電話に送る – 電話において
44
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
ライブ・デモ
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
動画:エミュレータのファジング
46
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
まとめ
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
吹き飛ばせ!
魅力的なターゲット
個人情報と企業秘密が詰まっている
ユーザが介在せずに情報を処理
多くのレガシー・フォーマットに対応している
入るための障壁は低くなっている
OS開発者によるエミュレーションの活用
物理ハードウェアの価格低下
ソフトウェア無線の人気向上
既存の研究成果の活用
MMSデータハンドラのバグを探すためのデスクトップアプリケーションに対するファジングと似て
いる
携帯電話の近寄りがたいイメージを打ち破る
48
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.
Thank you
© Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice.