|
| 1 | +import java.net.DatagramSocket; |
| 2 | +import java.net.Proxy; |
| 3 | +import java.net.Socket; |
| 4 | +import java.net.SocketAddress; |
1 | 5 | import java.net.URL;
|
| 6 | +import java.net.URLClassLoader; |
2 | 7 | import javax.servlet.http.HttpServletRequest;
|
3 | 8 | import javafx.scene.web.WebEngine;
|
4 | 9 | import org.codehaus.cargo.container.installer.ZipURLInstaller;
|
5 | 10 |
|
6 | 11 | public class Test {
|
7 | 12 |
|
8 |
| - public static Object source(HttpServletRequest request) { |
| 13 | + private static HttpServletRequest request; |
| 14 | + |
| 15 | + public static Object source() { |
9 | 16 | return request.getParameter(null);
|
10 | 17 | }
|
11 | 18 |
|
| 19 | + public void test(DatagramSocket socket) throws Exception { |
| 20 | + // "java.net;DatagramSocket;true;connect;(SocketAddress);;Argument[0];open-url;ai-generated" |
| 21 | + socket.connect((SocketAddress) source()); // $ SSRF |
| 22 | + } |
| 23 | + |
| 24 | + public void test(URL url) throws Exception { |
| 25 | + // "java.net;URL;false;openConnection;(Proxy);:Argument[-1]:open-url;manual" |
| 26 | + ((URL) source()).openConnection(); // $ SSRF |
| 27 | + // "java.net;URL;false;openConnection;(Proxy);:Argument[0]:open-url;ai-generated" |
| 28 | + url.openConnection((Proxy) source()); // $ SSRF |
| 29 | + // "java.net;URL;false;openStream;;:Argument[-1]:open-url;manual" |
| 30 | + ((URL) source()).openStream(); // $ SSRF |
| 31 | + } |
| 32 | + |
| 33 | + public void test(URLClassLoader cl) throws Exception { |
| 34 | + // "java.net;URLClassLoader;false;URLClassLoader;(String,URL[],ClassLoader);;Argument[1];open-url;manual" |
| 35 | + new URLClassLoader("", (URL[]) source(), null); // $ SSRF |
| 36 | + // "java.net;URLClassLoader;false;URLClassLoader;(String,URL[],ClassLoader,URLStreamHandlerFactory);;Argument[1];open-url;manual" |
| 37 | + new URLClassLoader("", (URL[]) source(), null, null); // $ SSRF |
| 38 | + // "java.net;URLClassLoader;false;URLClassLoader;(URL[]);;Argument[0];open-url;manual" |
| 39 | + new URLClassLoader((URL[]) source()); // $ SSRF |
| 40 | + // "java.net;URLClassLoader;false;URLClassLoader;(URL[],ClassLoader);;Argument[0];open-url;manual" |
| 41 | + new URLClassLoader((URL[]) source(), null); // $ SSRF |
| 42 | + // "java.net;URLClassLoader;false;URLClassLoader;(URL[],ClassLoader,URLStreamHandlerFactory);;Argument[0];open-url;manual" |
| 43 | + new URLClassLoader((URL[]) source(), null, null); // $ SSRF |
| 44 | + // "java.net;URLClassLoader;false;newInstance;;;Argument[0];open-url;manual" |
| 45 | + URLClassLoader.newInstance((URL[]) source()); // $ SSRF |
| 46 | + } |
| 47 | + |
12 | 48 | public void test(WebEngine webEngine) {
|
13 | 49 | // "javafx.scene.web;WebEngine;false;load;(String);;Argument[0];open-url;ai-generated"
|
14 |
| - webEngine.load((String) source(null)); // $ SSRF |
| 50 | + webEngine.load((String) source()); // $ SSRF |
15 | 51 | }
|
16 | 52 |
|
17 |
| - public void test() { |
| 53 | + public void test(ZipURLInstaller zui) { |
18 | 54 | // "org.codehaus.cargo.container.installer;ZipURLInstaller;true;ZipURLInstaller;(URL,String,String);;Argument[0];open-url:ai-generated"
|
19 |
| - new ZipURLInstaller((URL) source(null), "", ""); // $ SSRF |
| 55 | + new ZipURLInstaller((URL) source(), "", ""); // $ SSRF |
20 | 56 | }
|
21 | 57 |
|
22 | 58 | }
|
0 commit comments