Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Update Java_Gadget_Injector.java #9

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
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.vmware.software_forensic_kit.java_gadget;

import java.io.Console;
import java.io.EOFException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
Expand Down Expand Up @@ -114,7 +111,7 @@ public static void inject(ArrayList<String> matchedPids, String classMethodsPath
Runnable runnable = () -> {
System.out.println("Server started on port 31337.");
Console console = System.console();

while(exitserver == false) {
String out = console.readLine("Listening For Client Input: [E]xit");
exitserver = out.matches("(?i)e");
Expand Down Expand Up @@ -164,24 +161,22 @@ public static void inject(ArrayList<String> matchedPids, String classMethodsPath

while(exitserver == false){

Socket socket = server.accept();
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
String message = "";
Socket socket = server.accept();
InputStream inputStream = socket.getInputStream();
String message = "";
byte[] buffer = new byte[1024];
while(true) {
try {
//try to read all objects and catch fail if no more objects
message = (String) ois.readObject();
System.out.println("" + message);
//not readObject
int bytesRead = inputStream.read(buffer);
message = new String(buffer, 0, bytesRead);
System.out.println("Received message: " + message);
}
catch (EOFException e) {
break;
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

ois.close();
}
}
inputStream.close();
socket.close();
if(message.equalsIgnoreCase("exit")) break;

Expand All @@ -200,4 +195,4 @@ public static void inject(ArrayList<String> matchedPids, String classMethodsPath
}

}
}
}