fix SimplePacketLogger, expand HabboClient code 4windows

This commit is contained in:
sirjonasxx 2018-06-29 10:06:56 +02:00
parent e04918d228
commit b1964c126e
7 changed files with 97 additions and 9 deletions

View File

@ -96,6 +96,8 @@ public class HConnection {
private volatile boolean autoDetectHost = false;
private volatile String clientHostAndPort = "";
public State getState() {
return state;
@ -211,7 +213,7 @@ public class HConnection {
final boolean[] aborted = new boolean[1];
Rc4Obtainer rc4Obtainer = new Rc4Obtainer();
Rc4Obtainer rc4Obtainer = new Rc4Obtainer(this);
// wachten op data van client
new Thread(() -> {
@ -226,6 +228,8 @@ public class HConnection {
handler.act(buffer);
if (!datastream[0] && handler.isDataStream()) {
clientHostAndPort = client.getInetAddress().getHostAddress() + ":" + client.getPort();
System.out.println(clientHostAndPort);
datastream[0] = true;
setState(State.CONNECTED);
onConnect();
@ -373,6 +377,10 @@ public class HConnection {
sendToServerAsyncQueue.clear();
}
if (state != this.state) {
if (state != State.CONNECTED) {
clientHostAndPort = "";
}
State buffer = this.state;
this.state = state;
for (StateChangeListener listener : stateChangeListeners) {
@ -443,4 +451,8 @@ public class HConnection {
}
}
public String getClientHostAndPort() {
return clientHostAndPort;
}
}

View File

@ -1,5 +1,6 @@
package main.protocol.memory;
import main.protocol.HConnection;
import main.protocol.HPacket;
import main.protocol.crypto.RC4;
import main.protocol.memory.habboclient.HabboClient;
@ -20,8 +21,8 @@ public class Rc4Obtainer {
OutgoingHandler outgoingHandler = null;
IncomingHandler incomingHandler = null;
public Rc4Obtainer() {
client = HabboClientFactory.get();
public Rc4Obtainer(HConnection hConnection) {
client = HabboClientFactory.get(hConnection);
}
private boolean hashappened1 = false;

View File

@ -1,11 +1,19 @@
package main.protocol.memory.habboclient;
import main.protocol.HConnection;
import java.util.List;
/**
* Created by Jonas on 13/06/18.
*/
public interface HabboClient {
public abstract class HabboClient {
List<byte[]> getRC4possibilities();
protected HConnection hConnection;
public HabboClient(HConnection connection) {
this.hConnection = connection;
}
public abstract List<byte[]> getRC4possibilities();
}

View File

@ -1,7 +1,9 @@
package main.protocol.memory.habboclient;
import main.misc.OSValidator;
import main.protocol.HConnection;
import main.protocol.memory.habboclient.linux.LinuxHabboClient;
import main.protocol.memory.habboclient.windows.WindowsHabboClient;
/**
* Created by Jonas on 13/06/18.
@ -9,8 +11,9 @@ import main.protocol.memory.habboclient.linux.LinuxHabboClient;
public class HabboClientFactory {
public static HabboClient get() {
if (OSValidator.isUnix()) return new LinuxHabboClient();
public static HabboClient get(HConnection connection) {
if (OSValidator.isUnix()) return new LinuxHabboClient(connection);
if (OSValidator.isWindows()) return new WindowsHabboClient(connection);
return null;
}

View File

@ -1,12 +1,13 @@
package main.protocol.memory.habboclient.linux;
import main.protocol.HConnection;
import main.protocol.memory.habboclient.HabboClient;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
public class LinuxHabboClient implements HabboClient {
public class LinuxHabboClient extends HabboClient {
private static final String[] potentialProcessNames = {"--ppapi-flash-args", "plugin-container"};
@ -16,7 +17,9 @@ public class LinuxHabboClient implements HabboClient {
private static final boolean DEBUG = false;
public LinuxHabboClient() {
public LinuxHabboClient(HConnection connection) {
super(connection);
File folder = new File("/proc");
boolean found = false;

View File

@ -0,0 +1,59 @@
package main.protocol.memory.habboclient.windows;
import main.protocol.HConnection;
import main.protocol.memory.habboclient.HabboClient;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Jeunez on 27/06/2018.
*/
public class WindowsHabboClient extends HabboClient {
private static final boolean DEBUG = true;
private int[] PID; // list of potential PIDs
public WindowsHabboClient(HConnection connection) {
super(connection);
}
private void obtain_PID () {
String command="cmd /C netstat -a -o -n | findstr "+hConnection.getClientHostAndPort()+" | findstr ESTABLISHED";
try {
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader=new BufferedReader( new InputStreamReader(process.getInputStream()));
String s;
while ((s = reader.readLine()) != null){
String[] split = s.split(" ");
List<String> realSplit = new ArrayList<>();
for (String spli : split) {
if (!spli.equals("") && !spli.equals(" ")) {
realSplit.add(spli);
}
}
if (realSplit.get(1).equals(hConnection.getClientHostAndPort())) {
// PID = Integer.parseInt(realSplit.get(4));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public List<byte[]> getRC4possibilities() {
obtain_PID();
if (DEBUG) System.out.println("FLASH PROCESS ID: " + PID);
while (true) {}
// return null;
}
}

View File

@ -48,6 +48,8 @@ class SimpleTerminalLogger implements PacketLogger {
"<packet skipped>" :
packet.toString()
);
System.out.println(output.toString());
}
@Override