mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-02-21 21:32:36 +01:00
autoDetect hotel, autodetect ping headerid
This commit is contained in:
parent
68a98a6885
commit
469e1ace61
183
src/main/Cacher.java
Normal file
183
src/main/Cacher.java
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
package main;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Jonas on 05/04/18.
|
||||||
|
*/
|
||||||
|
public class Cacher {
|
||||||
|
|
||||||
|
private static String getCacheDir() {
|
||||||
|
return System.getProperty("user.home") + File.separator + ".G-Earth/";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean exists(String key) {
|
||||||
|
File f = new File(getCacheDir(), "cache.txt");
|
||||||
|
if (f.exists()) {
|
||||||
|
try {
|
||||||
|
List<String> lines = Files.readAllLines(f.toPath());
|
||||||
|
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.startsWith(key+":")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(String key) {
|
||||||
|
File f = new File(getCacheDir(), "cache.txt");
|
||||||
|
if (f.exists()) {
|
||||||
|
try {
|
||||||
|
List<String> lines = Files.readAllLines(f.toPath());
|
||||||
|
|
||||||
|
for (String line : lines) {
|
||||||
|
if (line.startsWith(key+":")) {
|
||||||
|
return line.split(":")[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(String key) {
|
||||||
|
File targetFile = new File(getCacheDir() + File.separator + "cache.txt");
|
||||||
|
File parent = targetFile.getParentFile();
|
||||||
|
if (!parent.exists() && !parent.mkdirs()) {
|
||||||
|
throw new IllegalStateException("Couldn't create dir: " + parent);
|
||||||
|
}
|
||||||
|
if (!targetFile.exists()) {
|
||||||
|
try {
|
||||||
|
targetFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArrayList<String> lines = new ArrayList<String>();
|
||||||
|
File f1 = new File(getCacheDir() + File.separator + "cache.txt");
|
||||||
|
FileReader fr = new FileReader(f1);
|
||||||
|
BufferedReader br = new BufferedReader(fr);
|
||||||
|
String line = null;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
if (!line.startsWith(key + ":"))
|
||||||
|
lines.add(line);
|
||||||
|
|
||||||
|
}
|
||||||
|
fr.close();
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
FileWriter fw = new FileWriter(f1);
|
||||||
|
BufferedWriter out = new BufferedWriter(fw);
|
||||||
|
|
||||||
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
|
out.write(lines.get(i));
|
||||||
|
if (i != lines.size() - 1) out.write("\n");
|
||||||
|
}
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void add(String key, String value) {
|
||||||
|
File targetFile = new File(getCacheDir() + File.separator + "cache.txt");
|
||||||
|
File parent = targetFile.getParentFile();
|
||||||
|
if (!parent.exists() && !parent.mkdirs()) {
|
||||||
|
throw new IllegalStateException("Couldn't create dir: " + parent);
|
||||||
|
}
|
||||||
|
if (!targetFile.exists()) {
|
||||||
|
try {
|
||||||
|
targetFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// File f = new File(getCacheDir(), "cache.txt");
|
||||||
|
// if (!f.exists()) {
|
||||||
|
// try {
|
||||||
|
// PrintWriter writer = new PrintWriter(f.getPath(), "UTF-8");
|
||||||
|
// writer.write("");
|
||||||
|
// writer.close();
|
||||||
|
// } catch (FileNotFoundException | UnsupportedEncodingException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ArrayList<String> lines = new ArrayList<String>();
|
||||||
|
File f1 = new File(getCacheDir() + File.separator + "cache.txt");
|
||||||
|
FileReader fr = new FileReader(f1);
|
||||||
|
BufferedReader br = new BufferedReader(fr);
|
||||||
|
String line = null;
|
||||||
|
boolean containmmm = false;
|
||||||
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
|
if (line.startsWith(key+":"))
|
||||||
|
containmmm = true;
|
||||||
|
lines.add(line);
|
||||||
|
|
||||||
|
}
|
||||||
|
fr.close();
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
FileWriter fw = new FileWriter(f1);
|
||||||
|
BufferedWriter out = new BufferedWriter(fw);
|
||||||
|
|
||||||
|
if (!containmmm) {
|
||||||
|
out.write(key+":"+value);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
|
out.write("\n"+ lines.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void update(String key, String value) {
|
||||||
|
remove(key);
|
||||||
|
add(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// System.out.println(exists("hallo"));
|
||||||
|
// System.out.println(get("hallo"));
|
||||||
|
//
|
||||||
|
// add("hallo","doei");
|
||||||
|
//
|
||||||
|
// System.out.println(exists("hallo"));
|
||||||
|
// System.out.println(get("hallo"));
|
||||||
|
//
|
||||||
|
// remove("hallo");
|
||||||
|
// System.out.println(get("hallo"));
|
||||||
|
System.out.println(get("PRODUCTION-201804032203-770536283-pingHeader"));
|
||||||
|
}
|
||||||
|
}
|
@ -13,9 +13,7 @@ import java.net.ServerSocket;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class HConnection {
|
public class HConnection {
|
||||||
|
|
||||||
@ -27,9 +25,9 @@ public class HConnection {
|
|||||||
CONNECTED // CONNECTED
|
CONNECTED // CONNECTED
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<String> autoDetectHosts;
|
private static List<String> autoDetectHosts;
|
||||||
static {
|
static {
|
||||||
autoDetectHosts = new HashSet<>();
|
autoDetectHosts = new ArrayList<>();
|
||||||
autoDetectHosts.add("game-us.habbo.com:38101");
|
autoDetectHosts.add("game-us.habbo.com:38101");
|
||||||
autoDetectHosts.add("game-nl.habbo.com:30000");
|
autoDetectHosts.add("game-nl.habbo.com:30000");
|
||||||
autoDetectHosts.add("game-br.habbo.com:30000");
|
autoDetectHosts.add("game-br.habbo.com:30000");
|
||||||
@ -47,39 +45,60 @@ public class HConnection {
|
|||||||
private volatile Object[] trafficListeners = {new ArrayList<TrafficListener>(), new ArrayList<TrafficListener>(), new ArrayList<TrafficListener>()};
|
private volatile Object[] trafficListeners = {new ArrayList<TrafficListener>(), new ArrayList<TrafficListener>(), new ArrayList<TrafficListener>()};
|
||||||
private volatile List<StateChangeListener> stateChangeListeners = new ArrayList<>();
|
private volatile List<StateChangeListener> stateChangeListeners = new ArrayList<>();
|
||||||
private volatile State state = State.NOT_CONNECTED;
|
private volatile State state = State.NOT_CONNECTED;
|
||||||
private volatile String input_domain = null; // given string representation
|
|
||||||
|
|
||||||
private volatile String actual_domain; // actual ip representation
|
private volatile List<String> input_domain = new ArrayList<>(); // given string representation
|
||||||
private volatile int port = -1;
|
private volatile List<String> actual_domain = new ArrayList<>(); // actual ip representation
|
||||||
|
private volatile List<Integer> port = new ArrayList<>();
|
||||||
|
|
||||||
|
private volatile List<ServerSocket> proxy = new ArrayList<>();
|
||||||
|
private volatile int realProxyIndex = -1;
|
||||||
|
|
||||||
private volatile ServerSocket proxy;
|
|
||||||
private volatile Handler inHandler = null;
|
private volatile Handler inHandler = null;
|
||||||
private volatile Handler outHandler = null;
|
private volatile Handler outHandler = null;
|
||||||
|
|
||||||
|
private volatile boolean autoDetectHost = false;
|
||||||
|
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
private String detourIP() {
|
|
||||||
return "127.0.0.1";
|
// autodetect method
|
||||||
|
public void prepare() {
|
||||||
|
prepare(autoDetectHosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manual method
|
||||||
public void prepare(String domain, int port) {
|
public void prepare(String domain, int port) {
|
||||||
setState(State.PREPARING);
|
List<String> potentialHost = new ArrayList<>();
|
||||||
|
potentialHost.add(domain+":"+port);
|
||||||
|
prepare(potentialHost);
|
||||||
|
realProxyIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.actual_domain = domain;
|
private void prepare(List<String> allPotentialHosts) {
|
||||||
this.port = port;
|
setState(State.PREPARING);
|
||||||
|
input_domain.clear();
|
||||||
|
actual_domain.clear();
|
||||||
|
port.clear();
|
||||||
|
clearAllProxies();
|
||||||
|
realProxyIndex = -1;
|
||||||
|
|
||||||
|
for (String host : allPotentialHosts) {
|
||||||
|
String[] split = host.split(":");
|
||||||
|
input_domain.add(split[0]);
|
||||||
|
port.add(Integer.parseInt(split[1]));
|
||||||
|
}
|
||||||
|
|
||||||
if (hostRedirected) {
|
if (hostRedirected) {
|
||||||
hostsReplacer.removeRedirect(domain, detourIP());
|
removeFromHosts();
|
||||||
hostRedirected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InetAddress address = InetAddress.getByName(domain);
|
for (String host : allPotentialHosts) {
|
||||||
actual_domain = address.getHostAddress();
|
InetAddress address = InetAddress.getByName(host.split(":")[0]);
|
||||||
if (DEBUG) System.out.println("found dom:" + actual_domain);
|
actual_domain.add(address.getHostAddress());
|
||||||
input_domain = domain;
|
}
|
||||||
setState(State.PREPARED);
|
setState(State.PREPARED);
|
||||||
|
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
@ -87,49 +106,63 @@ public class HConnection {
|
|||||||
setState(State.NOT_CONNECTED);
|
setState(State.NOT_CONNECTED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() throws IOException {
|
public void start() throws IOException {
|
||||||
if (state == State.PREPARED) {
|
if (state == State.PREPARED) {
|
||||||
if (DEBUG) System.out.println("waiting for client on port: " + port);
|
|
||||||
|
|
||||||
setState(State.WAITING_FOR_CLIENT);
|
setState(State.WAITING_FOR_CLIENT);
|
||||||
if (!hostRedirected) {
|
if (!hostRedirected) {
|
||||||
hostsReplacer.addRedirect(input_domain, detourIP());
|
addToHosts();
|
||||||
hostRedirected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy = new ServerSocket(port);
|
|
||||||
|
|
||||||
try {
|
for (int i = 0; i < actual_domain.size(); i++) {
|
||||||
while ((state == State.WAITING_FOR_CLIENT) && !proxy.isClosed()) {
|
ServerSocket proxy = new ServerSocket(port.get(i), 10, InetAddress.getByName("127.0.0." + (i+1)));
|
||||||
try {
|
this.proxy.add(proxy);
|
||||||
Socket client = proxy.accept();
|
String dom = actual_domain.get(i);
|
||||||
if (DEBUG) System.out.println("accepted a proxy");
|
Integer port2 = port.get(i);
|
||||||
new Thread(() -> {
|
|
||||||
|
int[] i2 = {i};
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
while ((state == State.WAITING_FOR_CLIENT) && !proxy.isClosed()) {
|
||||||
try {
|
try {
|
||||||
startProxyThread(client);
|
Socket client = proxy.accept();
|
||||||
} catch (InterruptedException | IOException e) {
|
realProxyIndex = i2[0];
|
||||||
|
closeAllProxies(i2[0]);
|
||||||
|
if (DEBUG) System.out.println("accepted a proxy");
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
try {
|
||||||
|
startProxyThread(client, dom, port2);
|
||||||
|
} catch (InterruptedException | IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
|
||||||
|
} catch (IOException e1) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
//e1.printStackTrace();
|
||||||
}
|
}
|
||||||
}).start();
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
} catch (IOException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
//e1.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}).start();
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (DEBUG) System.out.println("done waiting for clients with: " + this.state );
|
if (DEBUG) System.out.println("done waiting for clients with: " + this.state );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void startProxyThread(Socket client) throws InterruptedException, UnknownHostException, IOException {
|
private void startProxyThread(Socket client, String ip, int port) throws InterruptedException, UnknownHostException, IOException {
|
||||||
final boolean[] datastream = new boolean[1];
|
final boolean[] datastream = new boolean[1];
|
||||||
|
|
||||||
Socket habbo_server = new Socket(actual_domain, port);
|
Socket habbo_server = new Socket(ip, port);
|
||||||
|
|
||||||
OutputStream client_out = client.getOutputStream();
|
OutputStream client_out = client.getOutputStream();
|
||||||
InputStream client_in = client.getInputStream();
|
InputStream client_in = client.getInputStream();
|
||||||
@ -141,6 +174,7 @@ public class HConnection {
|
|||||||
final boolean[] aborted = new boolean[1];
|
final boolean[] aborted = new boolean[1];
|
||||||
|
|
||||||
Rc4Obtainer rc4Obtainer = new Rc4Obtainer();
|
Rc4Obtainer rc4Obtainer = new Rc4Obtainer();
|
||||||
|
rc4Obtainer.setHConnection(this);
|
||||||
|
|
||||||
// wachten op data van client
|
// wachten op data van client
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
@ -243,37 +277,58 @@ public class HConnection {
|
|||||||
}
|
}
|
||||||
private void onConnect() {
|
private void onConnect() {
|
||||||
if (hostRedirected) {
|
if (hostRedirected) {
|
||||||
hostsReplacer.removeRedirect(input_domain, detourIP());
|
removeFromHosts();
|
||||||
hostRedirected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy != null && !proxy.isClosed()) {
|
clearAllProxies();
|
||||||
try {
|
|
||||||
proxy.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public void abort() {
|
public void abort() {
|
||||||
if (hostRedirected) {
|
if (hostRedirected) {
|
||||||
hostsReplacer.removeRedirect(input_domain, detourIP());
|
removeFromHosts();
|
||||||
hostRedirected = false;
|
|
||||||
}
|
}
|
||||||
port = -1;
|
|
||||||
|
port.clear();
|
||||||
|
input_domain.clear();
|
||||||
|
actual_domain.clear();
|
||||||
|
realProxyIndex = -1;
|
||||||
|
|
||||||
setState(State.NOT_CONNECTED);
|
setState(State.NOT_CONNECTED);
|
||||||
actual_domain = null;
|
clearAllProxies();
|
||||||
if (proxy != null && !proxy.isClosed()) {
|
}
|
||||||
try {
|
|
||||||
proxy.close();
|
private void clearAllProxies() {
|
||||||
} catch (IOException e) {
|
closeAllProxies(-1);
|
||||||
// TODO Auto-generated catch block
|
proxy.clear();
|
||||||
e.printStackTrace();
|
}
|
||||||
|
private void closeAllProxies(int except) {
|
||||||
|
for (int i = 0; i < proxy.size(); i++) {
|
||||||
|
if (i != except) {
|
||||||
|
ServerSocket prox = proxy.get(i);
|
||||||
|
if (prox != null && !prox.isClosed()) {
|
||||||
|
try {
|
||||||
|
prox.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addToHosts() {
|
||||||
|
for (int i = 0; i < input_domain.size(); i++) {
|
||||||
|
hostsReplacer.addRedirect(input_domain.get(i), "127.0.0." + (i+1));
|
||||||
|
}
|
||||||
|
hostRedirected = true;
|
||||||
|
}
|
||||||
|
private void removeFromHosts(){
|
||||||
|
for (int i = 0; i < input_domain.size(); i++) {
|
||||||
|
hostsReplacer.removeRedirect(input_domain.get(i), "127.0.0." + (i+1));
|
||||||
|
}
|
||||||
|
hostRedirected = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void setState(State state) {
|
private void setState(State state) {
|
||||||
if (state != this.state) {
|
if (state != this.state) {
|
||||||
@ -311,12 +366,17 @@ public class HConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return port;
|
if (realProxyIndex == -1) return -1;
|
||||||
|
return port.get(realProxyIndex);
|
||||||
}
|
}
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return actual_domain;
|
if (realProxyIndex == -1) return "<auto-detect>";
|
||||||
|
return actual_domain.get(realProxyIndex);
|
||||||
|
}
|
||||||
|
public String getDomain() {
|
||||||
|
if (realProxyIndex == -1) return "<auto-detect>";
|
||||||
|
return input_domain.get(realProxyIndex);
|
||||||
}
|
}
|
||||||
public String getDomain() { return input_domain; }
|
|
||||||
|
|
||||||
|
|
||||||
public boolean sendToClient(HPacket message) {
|
public boolean sendToClient(HPacket message) {
|
||||||
|
@ -21,6 +21,10 @@ public class HMessage {
|
|||||||
isBlocked = false;
|
isBlocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
public void setBlocked(boolean block) {
|
public void setBlocked(boolean block) {
|
||||||
isBlocked = block;
|
isBlocked = block;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
package main.protocol.memory;
|
package main.protocol.memory;
|
||||||
|
|
||||||
|
import main.Cacher;
|
||||||
|
import main.protocol.HConnection;
|
||||||
|
import main.protocol.HMessage;
|
||||||
import main.protocol.HPacket;
|
import main.protocol.HPacket;
|
||||||
|
import main.protocol.TrafficListener;
|
||||||
import main.protocol.crypto.RC4;
|
import main.protocol.crypto.RC4;
|
||||||
import main.protocol.packethandler.IncomingHandler;
|
import main.protocol.packethandler.IncomingHandler;
|
||||||
import main.protocol.packethandler.OutgoingHandler;
|
import main.protocol.packethandler.OutgoingHandler;
|
||||||
|
import sun.misc.Cache;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -16,6 +21,9 @@ public class Rc4Obtainer {
|
|||||||
OutgoingHandler outgoingHandler = null;
|
OutgoingHandler outgoingHandler = null;
|
||||||
IncomingHandler incomingHandler = null;
|
IncomingHandler incomingHandler = null;
|
||||||
|
|
||||||
|
String habboVersion = "";
|
||||||
|
int pingHeader = -1;
|
||||||
|
|
||||||
public Rc4Obtainer() {
|
public Rc4Obtainer() {
|
||||||
client = HabboClient.create();
|
client = HabboClient.create();
|
||||||
}
|
}
|
||||||
@ -35,15 +43,34 @@ public class Rc4Obtainer {
|
|||||||
incomingHandler = handler;
|
incomingHandler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHConnection(HConnection hConnection) {
|
||||||
|
hConnection.addTrafficListener(0, message -> {
|
||||||
|
if (message.getIndex() == 0 && message.getDestination() == HMessage.Side.TOSERVER) {
|
||||||
|
habboVersion = message.getPacket().readString(6);
|
||||||
|
if (Cacher.exists(habboVersion +"-pingHeader")) {
|
||||||
|
pingHeader = Integer.parseInt(Cacher.get(habboVersion +"-pingHeader"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pingHeader == -1 && message.getDestination() == HMessage.Side.TOCLIENT && message.getPacket().length() == 2) {
|
||||||
|
pingHeader = message.getPacket().headerId();
|
||||||
|
Cacher.add(habboVersion +"-pingHeader", pingHeader+"");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private volatile int addedBytes = 0;
|
private volatile int addedBytes = 0;
|
||||||
private void onSendFirstEncryptedMessage() {
|
private void onSendFirstEncryptedMessage() {
|
||||||
incomingHandler.block();
|
|
||||||
outgoingHandler.block();
|
outgoingHandler.block();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
|
|
||||||
if (DEBUG) System.out.println("[+] send encrypted");
|
if (DEBUG) System.out.println("[+] send encrypted");
|
||||||
sleep(20);
|
sleep(20);
|
||||||
|
|
||||||
|
while (pingHeader == -1) {
|
||||||
|
sleep(50);
|
||||||
|
}
|
||||||
|
incomingHandler.block();
|
||||||
|
|
||||||
List<MemorySnippet> diff = null;
|
List<MemorySnippet> diff = null;
|
||||||
|
|
||||||
|
|
||||||
@ -63,7 +90,7 @@ public class Rc4Obtainer {
|
|||||||
if (i % 2 == 1) {
|
if (i % 2 == 1) {
|
||||||
am = rand.nextInt(30) + 1;
|
am = rand.nextInt(30) + 1;
|
||||||
for (int j = 0; j < am; j++) {
|
for (int j = 0; j < am; j++) {
|
||||||
incomingHandler.sendToStream(new HPacket(3794).toBytes());
|
incomingHandler.sendToStream(new HPacket(pingHeader).toBytes());
|
||||||
outgoingHandler.fakePongAlert();
|
outgoingHandler.fakePongAlert();
|
||||||
sleep(20);
|
sleep(20);
|
||||||
}
|
}
|
||||||
@ -111,7 +138,7 @@ public class Rc4Obtainer {
|
|||||||
|
|
||||||
MemorySnippet snippet1 = new MemorySnippet(snippet.getOffset(), new byte[snippet.getData().length]);
|
MemorySnippet snippet1 = new MemorySnippet(snippet.getOffset(), new byte[snippet.getData().length]);
|
||||||
client.fetchMemory(snippet1);
|
client.fetchMemory(snippet1);
|
||||||
incomingHandler.sendToStream(new HPacket(3794).toBytes());
|
incomingHandler.sendToStream(new HPacket(pingHeader).toBytes());
|
||||||
outgoingHandler.fakePongAlert();
|
outgoingHandler.fakePongAlert();
|
||||||
sleep(70);
|
sleep(70);
|
||||||
|
|
||||||
@ -154,6 +181,12 @@ public class Rc4Obtainer {
|
|||||||
|
|
||||||
//if result = null ud better reload
|
//if result = null ud better reload
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
System.out.println("please try again.");
|
||||||
|
System.out.println("found RC4 table:");
|
||||||
|
printByteArray(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// STEP FOUR: undo all sent packets in the rc4 stream
|
// STEP FOUR: undo all sent packets in the rc4 stream
|
||||||
|
@ -78,7 +78,12 @@ public class Connection extends SubForm {
|
|||||||
public void btnConnect_clicked(ActionEvent actionEvent) {
|
public void btnConnect_clicked(ActionEvent actionEvent) {
|
||||||
if (!isBusy) {
|
if (!isBusy) {
|
||||||
isBusy = true;
|
isBusy = true;
|
||||||
getHConnection().prepare(inpHost.getEditor().getText(), Integer.parseInt(inpPort.getEditor().getText()));
|
if (cbx_autodetect.isSelected()) {
|
||||||
|
getHConnection().prepare();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getHConnection().prepare(inpHost.getEditor().getText(), Integer.parseInt(inpPort.getEditor().getText()));
|
||||||
|
}
|
||||||
|
|
||||||
if (HConnection.DEBUG) System.out.println("connecting");
|
if (HConnection.DEBUG) System.out.println("connecting");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user