|
29 | 29 | import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
|
30 | 30 |
|
31 | 31 | import org.apache.hc.client5.http.fluent.Request;
|
32 |
| -// import org.apache.hc.client5.http.protocol.RedirectLocations; |
33 |
| -// import org.apache.hc.client5.http.utils.URIUtils; |
| 32 | + |
| 33 | +import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncRequester; |
| 34 | +import org.apache.hc.core5.http.impl.io.DefaultClassicHttpRequestFactory; |
| 35 | +import org.apache.hc.core5.http.impl.nio.DefaultHttpRequestFactory; |
| 36 | + |
| 37 | +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; |
| 38 | + |
| 39 | +import org.apache.hc.core5.http.message.BasicClassicHttpRequest; |
| 40 | +import org.apache.hc.core5.http.message.BasicHttpRequest; |
| 41 | +import org.apache.hc.core5.http.message.HttpRequestWrapper; |
| 42 | + |
34 | 43 |
|
35 | 44 | public class ApacheHttp5SSRF extends HttpServlet {
|
36 | 45 |
|
@@ -285,4 +294,119 @@ protected void doGet3(HttpServletRequest request, HttpServletResponse response)
|
285 | 294 | // TODO: handle exception
|
286 | 295 | }
|
287 | 296 | }
|
| 297 | + |
| 298 | + // org.apache.hc.core5.http.impl.bootstrap |
| 299 | + // org.apache.hc.core5.http.impl.io |
| 300 | + // org.apache.hc.core5.http.impl.nio |
| 301 | + protected void doGet4(HttpServletRequest request, HttpServletResponse response) |
| 302 | + throws ServletException, IOException { |
| 303 | + try { |
| 304 | + |
| 305 | + String uriSink = request.getParameter("uri"); |
| 306 | + URI uri = new URI(uriSink); |
| 307 | + |
| 308 | + String hostSink = request.getParameter("host"); |
| 309 | + HttpHost host = new HttpHost(hostSink); |
| 310 | + |
| 311 | + // org.apache.hc.core5.http.impl.bootstrap |
| 312 | + //AsyncRequesterBootstrap asyncReq = new AsyncRequesterBootstrap(); |
| 313 | + HttpAsyncRequester httpAsyncReq = new HttpAsyncRequester(null, null, null, null, null, null); |
| 314 | + httpAsyncReq.connect(host, null); // $ SSRF |
| 315 | + httpAsyncReq.connect(host, null, null, null); // $ SSRF |
| 316 | + |
| 317 | + // org.apache.hc.core5.http.impl.io |
| 318 | + DefaultClassicHttpRequestFactory defClassicHttpReqFact = new DefaultClassicHttpRequestFactory(); |
| 319 | + defClassicHttpReqFact.newHttpRequest("method", uri.toString()); // $ SSRF |
| 320 | + defClassicHttpReqFact.newHttpRequest("method", uri); // $ SSRF |
| 321 | + |
| 322 | + // org.apache.hc.core5.http.impl.nio |
| 323 | + DefaultHttpRequestFactory defHttpReqFact = new DefaultHttpRequestFactory(); |
| 324 | + defHttpReqFact.newHttpRequest("method", uri.toString()); // $ SSRF |
| 325 | + defHttpReqFact.newHttpRequest("method", uri); // $ SSRF |
| 326 | + |
| 327 | + } catch (Exception e) { |
| 328 | + // TODO: handle exception |
| 329 | + } |
| 330 | + } |
| 331 | + |
| 332 | + // org.apache.hc.core5.http.io.support |
| 333 | + protected void doGet5(HttpServletRequest request, HttpServletResponse response) |
| 334 | + throws ServletException, IOException { |
| 335 | + try { |
| 336 | + |
| 337 | + String uriSink = request.getParameter("uri"); |
| 338 | + URI uri = new URI(uriSink); |
| 339 | + |
| 340 | + String hostSink = request.getParameter("host"); |
| 341 | + HttpHost host = new HttpHost(hostSink); |
| 342 | + |
| 343 | + // org.apache.hc.core5.http.io.support.ClassicRequestBuilder |
| 344 | + ClassicRequestBuilder.delete(uri.toString()); // $ SSRF |
| 345 | + ClassicRequestBuilder.delete(uri); // $ SSRF |
| 346 | + |
| 347 | + ClassicRequestBuilder.get(uri.toString()); // $ SSRF |
| 348 | + ClassicRequestBuilder.get(uri); // $ SSRF |
| 349 | + |
| 350 | + ClassicRequestBuilder.head(uri.toString()); // $ SSRF |
| 351 | + ClassicRequestBuilder.head(uri); // $ SSRF |
| 352 | + |
| 353 | + ClassicRequestBuilder.options(uri.toString()); // $ SSRF |
| 354 | + ClassicRequestBuilder.options(uri); // $ SSRF |
| 355 | + |
| 356 | + ClassicRequestBuilder.patch(uri.toString()); // $ SSRF |
| 357 | + ClassicRequestBuilder.patch(uri); // $ SSRF |
| 358 | + |
| 359 | + ClassicRequestBuilder.post(uri.toString()); // $ SSRF |
| 360 | + ClassicRequestBuilder.post(uri); // $ SSRF |
| 361 | + |
| 362 | + ClassicRequestBuilder.put(uri.toString()); // $ SSRF |
| 363 | + ClassicRequestBuilder.put(uri); // $ SSRF |
| 364 | + |
| 365 | + ClassicRequestBuilder.get().setHttpHost(host); // $ SSRF |
| 366 | + |
| 367 | + ClassicRequestBuilder.get().setUri(uri.toString()); // $ SSRF |
| 368 | + ClassicRequestBuilder.get().setUri(uri); // $ SSRF |
| 369 | + |
| 370 | + ClassicRequestBuilder.trace(uri.toString()); // $ SSRF |
| 371 | + ClassicRequestBuilder.trace(uri); // $ SSRF |
| 372 | + |
| 373 | + } catch (Exception e) { |
| 374 | + // TODO: handle exception |
| 375 | + } |
| 376 | + } |
| 377 | + |
| 378 | + // org.apache.hc.core5.http.message |
| 379 | + protected void doGet6(HttpServletRequest request, HttpServletResponse response) |
| 380 | + throws ServletException, IOException { |
| 381 | + try { |
| 382 | + |
| 383 | + String uriSink = request.getParameter("uri"); |
| 384 | + URI uri = new URI(uriSink); |
| 385 | + |
| 386 | + String hostSink = request.getParameter("host"); |
| 387 | + HttpHost host = new HttpHost(hostSink); |
| 388 | + |
| 389 | + // BasicClassicHttpRequest |
| 390 | + new BasicClassicHttpRequest(Method.CONNECT, host, "path"); // $ SSRF |
| 391 | + new BasicClassicHttpRequest(Method.CONNECT, uri); // $ SSRF |
| 392 | + new BasicClassicHttpRequest("method", host, "path"); // $ SSRF |
| 393 | + new BasicClassicHttpRequest("method", uri); // $ SSRF |
| 394 | + |
| 395 | + // BasicHttpRequest |
| 396 | + new BasicHttpRequest(Method.CONNECT, host, "path"); // $ SSRF |
| 397 | + new BasicHttpRequest(Method.CONNECT, uri); // $ SSRF |
| 398 | + new BasicHttpRequest("method", host, "path"); // $ SSRF |
| 399 | + new BasicHttpRequest("method", uri); // $ SSRF |
| 400 | + BasicHttpRequest bhr = new BasicHttpRequest("method", "path"); |
| 401 | + bhr.setUri(uri); // $ SSRF |
| 402 | + |
| 403 | + // HttpRequestWrapper |
| 404 | + HttpRequestWrapper hrw = new HttpRequestWrapper(null); |
| 405 | + hrw.setUri(uri); // $ SSRF |
| 406 | + |
| 407 | + } catch (Exception e) { |
| 408 | + // TODO: handle exception |
| 409 | + } |
| 410 | + } |
| 411 | + |
288 | 412 | }
|
0 commit comments