mirror of
https://github.com/TheOfficialFloW/bd-jb
synced 2025-02-07 02:30:12 -05:00
Improve screen printing.
This commit is contained in:
parent
20c77c4f47
commit
f3a31c611e
@ -23,6 +23,8 @@ class Loader implements Runnable {
|
||||
private static final String MAIN_METHOD_NAME = "main";
|
||||
private static final String PRINTLN_METHOD_NAME = "println";
|
||||
|
||||
private static final int JAR_PORT = 9025;
|
||||
|
||||
static void startJarLoader() {
|
||||
new Thread(new Loader()).start();
|
||||
}
|
||||
@ -31,10 +33,10 @@ class Loader implements Runnable {
|
||||
Screen.println("[+] bd-jb by theflow");
|
||||
|
||||
while (true) {
|
||||
Screen.println("[*] Listening for remote JAR on port 9025...");
|
||||
Screen.println("[*] Listening for JAR on port " + JAR_PORT + "...");
|
||||
|
||||
try {
|
||||
ServerSocket serverSocket = new ServerSocket(9025);
|
||||
ServerSocket serverSocket = new ServerSocket(JAR_PORT);
|
||||
Socket socket = serverSocket.accept();
|
||||
InputStream inputStream = socket.getInputStream();
|
||||
OutputStream outputStream = new FileOutputStream(MNT_ADA_JAR_FILE);
|
||||
@ -49,7 +51,7 @@ class Loader implements Runnable {
|
||||
|
||||
outputStream.close();
|
||||
inputStream.close();
|
||||
|
||||
socket.close();
|
||||
serverSocket.close();
|
||||
|
||||
Screen.println("[+] Received " + total + " bytes");
|
||||
@ -59,10 +61,10 @@ class Loader implements Runnable {
|
||||
DVBClassLoader dvbClassLoader =
|
||||
DVBClassLoader.newInstance(new URL[] {new URL("file://" + MNT_ADA_JAR_FILE)});
|
||||
Class exploitClass = dvbClassLoader.loadClass(EXPLOIT_CLASS_NAME);
|
||||
Method main = exploitClass.getMethod(MAIN_METHOD_NAME, new Class[] {Method.class});
|
||||
Method exploitMain = exploitClass.getMethod(MAIN_METHOD_NAME, new Class[] {Method.class});
|
||||
Method screenPrintln =
|
||||
Screen.class.getMethod(PRINTLN_METHOD_NAME, new Class[] {String.class});
|
||||
main.invoke(null, new Object[] {screenPrintln});
|
||||
exploitMain.invoke(null, new Object[] {screenPrintln});
|
||||
|
||||
Screen.println("[+] JAR exited");
|
||||
} catch (Exception e) {
|
||||
|
@ -12,19 +12,22 @@ import java.awt.Container;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Screen extends Container {
|
||||
private static final long serialVersionUID = 0x4141414141414141L;
|
||||
|
||||
private static final Font FONT = new Font(null, Font.PLAIN, 40);
|
||||
private static final int MAX_LINES = 32;
|
||||
|
||||
private static final ArrayList messages = new ArrayList();
|
||||
private static final Font FONT = new Font(null, Font.PLAIN, 32);
|
||||
|
||||
private static final String[] lines = new String[MAX_LINES];
|
||||
|
||||
private static final Screen instance = new Screen();
|
||||
|
||||
private static Method remoteScreenPrintln = null;
|
||||
|
||||
private static int currentLine = 0;
|
||||
|
||||
public static Screen getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@ -33,7 +36,7 @@ public class Screen extends Container {
|
||||
remoteScreenPrintln = screenPrintln;
|
||||
}
|
||||
|
||||
public static void println(String msg) {
|
||||
public static synchronized void println(String msg) {
|
||||
if (remoteScreenPrintln != null) {
|
||||
try {
|
||||
remoteScreenPrintln.invoke(null, new Object[] {msg});
|
||||
@ -41,7 +44,8 @@ public class Screen extends Container {
|
||||
// Ignore.
|
||||
}
|
||||
} else {
|
||||
messages.add(msg);
|
||||
lines[currentLine] = msg;
|
||||
currentLine = (currentLine + 1) % MAX_LINES;
|
||||
instance.repaint();
|
||||
}
|
||||
}
|
||||
@ -49,14 +53,13 @@ public class Screen extends Container {
|
||||
public void paint(Graphics g) {
|
||||
g.setFont(FONT);
|
||||
g.setColor(Color.WHITE);
|
||||
g.clearRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
int x = 80;
|
||||
int y = 80;
|
||||
int x = 64;
|
||||
int y = 64;
|
||||
int height = g.getFontMetrics().getHeight();
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
String msg = (String) messages.get(i);
|
||||
g.drawString(msg, x, y);
|
||||
y += height;
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
g.drawString(lines[i], x, y + i * height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user