Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XePeleato committed Apr 18, 2019
0 parents commit f03bb5d
Show file tree
Hide file tree
Showing 10 changed files with 1,790 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# XeHideawayLogger

### What the hell is this?
This is a packet interceptor for the game 'Hotel Hideaway' by Sulake.

Currently it's a very basic program, I don't have much interest in this game so don't expect wonders.

### Ok how can I get it working?
Check the wiki for instructions on Android. It should be similar on IOS but I can't test so good luck!

### Some code in there looks FAMILIAR to me!
Yeah I took some of it from sirjonasxx's G-Earth, more specifically the whole HPacket class and some of the connection logic.

### Screenshots
![](https://i.imgur.com/IVMEj1a.png)

Nice and simple!
67 changes: 67 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>G-EarthGang</groupId>
<artifactId>XeHideawayLogger</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<outputDirectory>${project.build.directory}/bin</outputDirectory>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>HideawayLogger.App</mainClass>
<useUniqueVersions>false</useUniqueVersions>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>${project.build.directory}/bin</outputDirectory>
<archive>
<manifest>
<mainClass>HideawayLogger.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>XeHideawayLogger</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
</dependencies>
</project>
59 changes: 59 additions & 0 deletions src/main/java/HideawayLogger/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package HideawayLogger;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

public class App extends Application {

public TextArea txtPacket;
public Button btnSendToServer;
public Button btnSendToClient;
public CheckBox cbMute;

private static HideawayLogger Logger;

public static void main( String[] args )
{
launch(args);
}

@Override
public void start(Stage primaryStage) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/Injector.fxml"));
Parent root = loader.load();
primaryStage.setTitle("XeHideawayLogger");
primaryStage.setScene(new Scene(root, 598, 238));
primaryStage.show();

new Thread(() -> {
Logger = new HideawayLogger();
Logger.run();
}).start();

}

public void onBtnSendToServerClick(ActionEvent actionEvent) {
HPacket send = new HPacket(txtPacket.getText());
if (!send.isCorrupted())
Logger.getDefaultSession().sendToServerAsync(send.toBytes());
}

public void onBtnSendToClientClick(ActionEvent actionEvent) {
HPacket send = new HPacket(txtPacket.getText());
if (!send.isCorrupted())
Logger.getDefaultSession().sendToClientAsync(send.toBytes());
}

public void onCbMuteToggle(ActionEvent actionEvent) {
Logger.getDefaultSession().getLogger().toggleMuteIncoming(cbMute.isSelected());
}


}
178 changes: 178 additions & 0 deletions src/main/java/HideawayLogger/DebugSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
package HideawayLogger;

import javax.net.ssl.*;
import java.io.*;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.LinkedList;
import java.util.Queue;

class DebugSession {
private final Queue<byte[]> sendToClientAsyncQueue = new LinkedList<>();
private final Queue<byte[]> sendToServerAsyncQueue = new LinkedList<>();

private SSLSocket toHideaway;
private SSLSocket client;

private BufferedInputStream dInHideaway;
private BufferedOutputStream dOsHideaway;

private BufferedInputStream dInClient;
private BufferedOutputStream dOsClient;

private PacketLogger Logger = new PacketLogger();

private static TrustManager[] trustAllCerts = new TrustManager[] {
new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) {
}

@Override
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) {
}

@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}
};
DebugSession(SSLSocket client)
{
this.client = client;
}

public PacketLogger getLogger() {
return Logger;
}

private void sendToServer(byte[] packet) {
if (dOsClient == null) return;
try {
dOsClient.write(packet);
dOsClient.flush();
} catch (IOException e) {
e.printStackTrace();
}
}

private void sendToClient(byte[] packet) {
if (dOsHideaway == null) {
return;
}
try {
dOsHideaway.write(packet);
dOsHideaway.flush();
} catch (IOException ignored) {}
}

public void sendToClientAsync(byte[] message) {
synchronized (sendToClientAsyncQueue) {
sendToClientAsyncQueue.add(message);
}

}
public void sendToServerAsync(byte[] message) {
synchronized (sendToServerAsyncQueue) {
sendToServerAsyncQueue.add(message);
}
}

void StartSession()
{
try {
SSLContext sc = SSLContext.getInstance("TLSv1.2");
sc.init(null, trustAllCerts, new SecureRandom());
SSLSocketFactory ssf = sc.getSocketFactory();

toHideaway = (SSLSocket) ssf.createSocket("server225.hotelhideawaythegame.com", 9999);
System.out.println("[+] Socket to hideaway created. Handshake...");
toHideaway.startHandshake();
System.out.println("[+] Handshake succeeded");
} catch (Exception ignored) {}

new Thread(() -> {
while (true) {
byte[] packet;
synchronized (sendToClientAsyncQueue) {
while ((packet = sendToClientAsyncQueue.poll()) != null) {
Logger.addIncomingMessage(packet);
sendToClient(packet);
}
}
try { Thread.sleep(1); } catch (InterruptedException e) {
e.printStackTrace(); } }
}).start();

new Thread(() -> {
while (true) {
byte[] packet;
synchronized (sendToServerAsyncQueue) {
while ((packet = sendToServerAsyncQueue.poll()) != null) {
sendToServer(packet);
Logger.addOutgoingMessage(packet);
}
}

try { Thread.sleep(1); } catch (InterruptedException e) { e.printStackTrace(); }
}
}).start();

System.out.println("[+] Starting debug session...");

new Thread(() -> {
try {
dInHideaway = new BufferedInputStream(toHideaway.getInputStream());
dOsHideaway = new BufferedOutputStream(client.getOutputStream());

byte[] pLen = new byte[4];
byte[] buf = new byte[1024];
while (!toHideaway.isClosed()) {

int amount = dInHideaway.read(buf);

byte[] ret = new byte[amount];

for (int i = 0; i < amount; i++)
ret[i] = buf[i];
sendToClientAsync(ret);
}
} catch (Exception e) {
e.printStackTrace();
}
}).start();


new Thread(() -> {
try {
dInClient = new BufferedInputStream(client.getInputStream());
dOsClient = new BufferedOutputStream(toHideaway.getOutputStream());

byte[] packetLen = new byte[4];
while (!client.isClosed()) {
int amountRead = 0;

if (dInClient.read(packetLen, 0, 4) < 4)
System.out.println("[-] The client probably disconnected");

int packetLength = ByteBuffer.wrap(packetLen).getInt();

byte[] buf = new byte[4 + packetLength];

while (amountRead < packetLength) {
amountRead += dInClient.read(buf, 4 + amountRead, Math.min(dInClient.available(), packetLength - amountRead));
}

byte[] lengthBytes = ByteBuffer.allocate(4).putInt(packetLength).array();

System.arraycopy(lengthBytes, 0, buf, 0, lengthBytes.length);

sendToServerAsync(buf);
} }
catch (Exception ignored) {}
}).start();

}
}

0 comments on commit f03bb5d

Please sign in to comment.