hproxy hclient

This commit is contained in:
sirjonasxx 2020-12-27 22:14:43 +01:00
parent d252c33c8b
commit 7c840ae98a
5 changed files with 21 additions and 19 deletions

View File

@ -0,0 +1,6 @@
package gearth.protocol.connection;
public enum HClient {
UNITY,
FLASH
}

View File

@ -1,12 +1,13 @@
package gearth.protocol.connection; package gearth.protocol.connection;
import gearth.protocol.packethandler.PacketHandler; import gearth.protocol.packethandler.PacketHandler;
import gearth.protocol.packethandler.flash.IncomingFlashPacketHandler;
import gearth.protocol.packethandler.flash.OutgoingFlashPacketHandler;
import java.net.ServerSocket; import java.net.ServerSocket;
public class HProxy { public class HProxy {
private final HClient hClient;
private volatile String input_domain; //string representation of the domain to intercept private volatile String input_domain; //string representation of the domain to intercept
private volatile String actual_domain; //dns resolved domain (ignoring hosts file) private volatile String actual_domain; //dns resolved domain (ignoring hosts file)
private volatile int actual_port; //port of the server private volatile int actual_port; //port of the server
@ -22,7 +23,8 @@ public class HProxy {
private volatile String hotelVersion = ""; private volatile String hotelVersion = "";
private volatile AsyncPacketSender asyncPacketSender = null; private volatile AsyncPacketSender asyncPacketSender = null;
public HProxy(String input_domain, String actual_domain, int actual_port, int intercept_port, String intercept_host) { public HProxy(HClient hClient, String input_domain, String actual_domain, int actual_port, int intercept_port, String intercept_host) {
this.hClient = hClient;
this.input_domain = input_domain; this.input_domain = input_domain;
this.actual_domain = actual_domain; this.actual_domain = actual_domain;
this.actual_port = actual_port; this.actual_port = actual_port;
@ -80,4 +82,8 @@ public class HProxy {
public AsyncPacketSender getAsyncPacketSender() { public AsyncPacketSender getAsyncPacketSender() {
return asyncPacketSender; return asyncPacketSender;
} }
public HClient gethClient() {
return hClient;
}
} }

View File

@ -2,10 +2,7 @@ package gearth.protocol.connection.proxy.flash;
import gearth.misc.Cacher; import gearth.misc.Cacher;
import gearth.protocol.HConnection; import gearth.protocol.HConnection;
import gearth.protocol.connection.HProxy; import gearth.protocol.connection.*;
import gearth.protocol.connection.HProxySetter;
import gearth.protocol.connection.HState;
import gearth.protocol.connection.HStateSetter;
import gearth.protocol.connection.proxy.ProxyProviderFactory; import gearth.protocol.connection.proxy.ProxyProviderFactory;
import gearth.protocol.connection.proxy.SocksConfiguration; import gearth.protocol.connection.proxy.SocksConfiguration;
import gearth.protocol.hostreplacer.hostsfile.HostReplacer; import gearth.protocol.hostreplacer.hostsfile.HostReplacer;
@ -73,7 +70,7 @@ public class NormalFlashProxyProvider extends FlashProxyProvider {
int intercept_port = port; int intercept_port = port;
String intercept_host = "127.0." + (c / 254) + "." + (1 + c % 254); String intercept_host = "127.0." + (c / 254) + "." + (1 + c % 254);
potentialProxies.add(new HProxy(input_dom, actual_dom, port, intercept_port, intercept_host)); potentialProxies.add(new HProxy(HClient.FLASH, input_dom, actual_dom, port, intercept_port, intercept_host));
c++; c++;
} }
} }

View File

@ -1,10 +1,7 @@
package gearth.protocol.connection.proxy.flash.unix; package gearth.protocol.connection.proxy.flash.unix;
import gearth.protocol.HConnection; import gearth.protocol.HConnection;
import gearth.protocol.connection.HProxy; import gearth.protocol.connection.*;
import gearth.protocol.connection.HProxySetter;
import gearth.protocol.connection.HState;
import gearth.protocol.connection.HStateSetter;
import gearth.protocol.connection.proxy.flash.FlashProxyProvider; import gearth.protocol.connection.proxy.flash.FlashProxyProvider;
import gearth.protocol.connection.proxy.ProxyProviderFactory; import gearth.protocol.connection.proxy.ProxyProviderFactory;
import gearth.protocol.connection.proxy.SocksConfiguration; import gearth.protocol.connection.proxy.SocksConfiguration;
@ -46,7 +43,7 @@ public class LinuxRawIpFlashProxyProvider extends FlashProxyProvider {
new Thread(() -> { new Thread(() -> {
try { try {
stateSetter.setState(HState.PREPARING); stateSetter.setState(HState.PREPARING);
proxy = new HProxy(input_host, input_host, input_port, input_port, "0.0.0.0"); proxy = new HProxy(HClient.FLASH, input_host, input_host, input_port, input_port, "0.0.0.0");
maybeRemoveMapping(); maybeRemoveMapping();

View File

@ -3,10 +3,7 @@ package gearth.protocol.connection.proxy.unity;
import gearth.protocol.HConnection; import gearth.protocol.HConnection;
import gearth.protocol.HMessage; import gearth.protocol.HMessage;
import gearth.protocol.HPacket; import gearth.protocol.HPacket;
import gearth.protocol.connection.HProxy; import gearth.protocol.connection.*;
import gearth.protocol.connection.HProxySetter;
import gearth.protocol.connection.HState;
import gearth.protocol.connection.HStateSetter;
import gearth.protocol.connection.proxy.ProxyProvider; import gearth.protocol.connection.proxy.ProxyProvider;
import gearth.protocol.packethandler.unity.UnityPacketHandler; import gearth.protocol.packethandler.unity.UnityPacketHandler;
@ -58,8 +55,7 @@ public class UnityCommunicator {
if (hProxy == null && b[0] == 1) { if (hProxy == null && b[0] == 1) {
HPacket maybe = new HPacket(packet); HPacket maybe = new HPacket(packet);
if (maybe.getBytesLength() > 6 && maybe.headerId() == 4000) { if (maybe.getBytesLength() > 6 && maybe.headerId() == 4000) {
String hotelVersion = maybe.readString(); hProxy = new HProxy(HClient.UNITY, "", "", -1, -1, "");
hProxy = new HProxy("", "", -1, -1, "");
hProxy.verifyProxy( hProxy.verifyProxy(
new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOCLIENT), new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOCLIENT),
new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOSERVER), new UnityPacketHandler(hConnection.getExtensionHandler(), hConnection.getTrafficObservables(), session, HMessage.Direction.TOSERVER),