介绍
- SSRF漏洞(服务器端请求伪造):是一种由攻击者构造形成由服务端发起请求的一个安全漏洞。一般情况下,SSRF攻击的目标是从外网无法访问的内部系统。(正是因为它是由服务端发起的,所以它能够请求到与它相连而与外网隔离的内部系统)。
- file的路径不识别时候,可以copy去brower,再copy使用
作用
-
对服务器所在的内网、本地进行端口扫描,获取一些服务的banner信息 。
-
攻击运行在内网或者本地的应用程序。
-
对内网web应用进行指纹识别,通过访问默认文件实现 。
-
攻击内外网的web应用。sql注入、struct2、redis等。
-
利用file协议读取本地文件等。
-
php ssrf中的伪协议:
file dict sftp ldap tftp gopher
-
Java ssrf 中的伪协议:
file ftp mailto http https jar netdoc
-
关键词
URLConnection
-
在某些代码中HttpURLConnection httpUrl = (HttpURLConnection) urlConnection;。得出结论:
URLConnection:可以走邮件、文件传输协议、HTTP协议等协议。 HttpURLConnection 只能走浏览器的HTTP协议
/**
* http://localhost:8080/ssrf/urlConnection/vuln?url=file:///etc/passwd
*
*/
@RequestMapping(value = "/urlConnection/vuln", method = {RequestMethod.POST, RequestMethod.GET})
public String URLConnectionVuln(String url) {
return HttpUtils.URLConnection(url);
}
openStream
- openStream基层也是调用URLConnection
@GetMapping("/openStream") public void openStream(@RequestParam String url, HttpServletResponse response) throws IOException { InputStream inputStream = null; OutputStream outputStream = null; try { String downLoadImgFileName = WebUtils.getNameWithoutExtension(url) + "." + WebUtils.getFileExtension(url); // download response.setHeader("content-disposition", "attachment;fileName=" + downLoadImgFileName); URL u = new URL(url); int length; byte[] bytes = new byte[1024]; inputStream = u.openStream(); // send request outputStream = response.getOutputStream(); while ((length = inputStream.read(bytes)) > 0) { outputStream.write(bytes, 0, length); } ################### public final InputStream openStream() throws java.io.IOException { return openConnection().getInputStream(); } ################### public URLConnection openConnection() throws java.io.IOException { return handler.openConnection(this); }