-
Notifications
You must be signed in to change notification settings - Fork 0
/
011-ssrf-okhttp3.jsp
50 lines (48 loc) · 1.59 KB
/
011-ssrf-okhttp3.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<%@ page import="okhttp3.OkHttpClient" %>
<%@ page import="okhttp3.Request" %>
<%@ page import="okhttp3.Response" %>
<%@ page import="org.apache.commons.lang.exception.ExceptionUtils" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%--
Created by IntelliJ IDEA.
User: anyang
Date: 2018/10/9
Time: 上午10:49
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>011-ssrf-okhttp3</h1>
<%!
public String httpGet(String url) {
String result = "";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(url).build();
try {
Response response = client.newCall(request).execute();
result = response.body().string();
} catch (Exception e) {
String[] rootCauseStackTrace = ExceptionUtils.getRootCauseStackTrace(e);
result = StringUtils.join(rootCauseStackTrace,System.lineSeparator());
}
return result;
}
%>
<%
String linux_querystring = "?url=http://127.0.0.1.xip.io";
String urlString = request.getParameter("url");
if (urlString != null) {
String result = httpGet(urlString);
result = result.replace("<", "<");
result = result.replace(">", ">");
out.println("<pre>" +result+ "</pre>");
}
%>
<p>okhttp 调用方式: </p>
<p>curl '<a href="<%=request.getRequestURL()+linux_querystring%>" target="_blank"><%=request.getRequestURL()+linux_querystring%></a>'</p>
</body>
</html>