More abstraction

This commit is contained in:
Michael Wain 2024-06-03 04:56:24 +03:00
parent f71f61e51b
commit e646db41fe
20 changed files with 582 additions and 459 deletions

File diff suppressed because one or more lines are too long

View File

@ -45,7 +45,8 @@ public class PresenceProcessor extends Processor {
// FIRST
/*Protocol.AddNotification addNotification = Protocol.AddNotification.parseFrom(Util.hexStringToByteArray("1A71AA066E0A120900000000000000011193710E1A0000000012190A170A0A08CE84011001180620001209189AB1D8B499BCCC02121A0A180A0A08CE8401100118012000120A2A086A6F686E20626F6E12210A1F0A0A08CE840110011804200012112A0F517569726B794F7263233239363838"));
System.out.println(addNotification);*/
System.out.println(Util.bytesToHex(bb));
//System.out.println(Util.bytesToHex(bb));
conn.send(new BattleNetPacket(header, bb));

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class BattlePayConfig extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 237;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class CheckAccountLicenses extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 267;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class CheckGameLicenses extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 276;
}
}

View File

@ -0,0 +1,14 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public abstract class ClientRequestParser {
public abstract void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn);
public abstract int getId();
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class GetAchieves extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 253;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class GetAdventureProgress extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 305;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class GetAssetsVersion extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 303;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class GetBattlePayStatus extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 255;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class NetCacheObject extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 201;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class NetCacheObjectList extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 327;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class SendUnsubcribeRequest extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 329;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class SetOptions extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 239;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class SubscriptionRequest extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 314;
}
}

View File

@ -0,0 +1,17 @@
package com.alterdekim.hearthhack.component.processor.client.request;
import com.alterdekim.hearthhack.component.TcpConnection;
import com.alterdekim.hearthhack.util.BattleNetPacket;
import com.alterdekim.hearthhack.util.ClientRequestBody;
public class UpdateLogin extends ClientRequestParser {
@Override
public void parse(BattleNetPacket packet, ClientRequestBody body, TcpConnection conn) {
}
@Override
public int getId() {
return 205;
}
}

View File

@ -8,4 +8,5 @@ public class ClientRequestBody {
private int sendCount;
private byte[] body;
private int type;
private long route;
}

View File

@ -79,7 +79,7 @@ public class PegasusPacket {
return num2;
}
/*public byte[] Encode() {
/* public byte[] Encode() {
if (this.body instanceof GeneratedMessageV3) {
GeneratedMessageV3 protoBuf = (GeneratedMessageV3) this.body;
this.size = (int) protoBuf.GetSerializedSize();

View File

@ -1,7 +1,6 @@
package com.alterdekim.hearthhack.util;
import com.google.protobuf.MessageOrBuilder;
import com.google.protobuf.util.JsonFormat;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@ -14,13 +13,13 @@ import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
import javax.net.ssl.*;
import java.io.FileReader;
import java.io.IOException;
import java.security.KeyPair;
import java.security.KeyStore;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
@Slf4j
public class Util {
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
@ -139,7 +138,14 @@ public class Util {
return s.length() % 2 == 0 ? s : "0" + s;
}
public static String prototoJson(MessageOrBuilder messageOrBuilder) throws IOException {
return JsonFormat.printer().print(messageOrBuilder);
public static void setTimeout(Runnable runnable, int delay) {
new Thread(() -> {
try {
Thread.sleep(delay);
runnable.run();
} catch (Exception e){
log.error(e.getMessage());
}
}).start();
}
}

View File

@ -3038,4 +3038,139 @@ message RewardChest {
optional RewardBag bag3 = 3;
optional RewardBag bag4 = 4;
optional RewardBag bag5 = 5;
}
// ref: PegasusUtil.BattlePayConfigResponse
message BattlePayConfigResponse {
// ref: PegasusUtil.BattlePayConfigResponse/PacketID
enum PacketID {
ID = 238;
}
repeated Bundle bundles = 1;
optional int32 currency = 2;
optional bool unavailable = 4;
optional int32 secs_before_auto_cancel = 5;
repeated GoldCostBooster gold_cost_boosters = 6;
optional int64 gold_cost_arena = 7;
}
// ref: PegasusUtil.GoldCostBooster
message GoldCostBooster {
required int64 cost = 1;
required int32 pack_type = 2;
optional string buy_with_gold_event_name = 3;
}
// ref: PegasusUtil.Bundle
message Bundle {
required string id = 1;
optional double cost = 2;
optional string apple_id = 3;
optional string google_play_id = 4;
repeated BundleItem items = 5;
optional int64 gold_cost = 6;
optional string amazon_id = 7;
optional string product_event_name = 9;
repeated BattlePayProvider exclusive_providers = 10;
optional string real_money_product_event_name = 11;
}
// ref: PegasusUtil.BundleItem
message BundleItem {
required ProductType product_type = 1;
required int32 data = 2;
required int32 quantity = 3;
}
// ref: PegasusUtil.ProductType
enum ProductType {
PRODUCT_TYPE_UNKNOWN = 0;
PRODUCT_TYPE_BOOSTER = 1;
PRODUCT_TYPE_DRAFT = 2;
PRODUCT_TYPE_NAXX = 3;
PRODUCT_TYPE_BRM = 4;
PRODUCT_TYPE_CARD_BACK = 5;
PRODUCT_TYPE_HERO = 6;
PRODUCT_TYPE_LOE = 7;
}
// ref: PegasusShared.BattlePayProvider
enum BattlePayProvider {
BP_PROVIDER_BLIZZARD = 1;
BP_PROVIDER_APPLE = 2;
BP_PROVIDER_GOOGLE_PLAY = 3;
BP_PROVIDER_AMAZON = 4;
}
// ref: PegasusUtil.BattlePayStatusResponse
message BattlePayStatusResponse {
// ref: PegasusUtil.BattlePayStatusResponse/PacketID
enum PacketID {
ID = 265;
}
// ref: PegasusUtil.BattlePayStatusResponse/PurchaseState
enum PurchaseState {
PS_READY = 0;
PS_CHECK_RESULTS = 1;
PS_ERROR = 2;
}
required PurchaseState status = 1;
optional string product_id = 2;
optional PurchaseError purchase_error = 3;
required bool battle_pay_available = 4;
optional int64 transaction_id = 5;
optional string third_party_id = 6;
optional int32 currency = 7;
optional BattlePayProvider provider = 8 [default = BP_PROVIDER_BLIZZARD];
}
// ref: PegasusUtil.PurchaseError
message PurchaseError {
// ref: PegasusUtil.PurchaseError/Error
enum Error {
E_UNKNOWN = -1;
E_SUCCESS = 0;
E_STILL_IN_PROGRESS = 1;
E_INVALID_BNET = 2;
E_SERVICE_NA = 3;
E_PURCHASE_IN_PROGRESS = 4;
E_DATABASE = 5;
E_INVALID_QUANTITY = 6;
E_DUPLICATE_LICENSE = 7;
E_REQUEST_NOT_SENT = 8;
E_NO_ACTIVE_BPAY = 9;
E_FAILED_RISK = 10;
E_CANCELED = 11;
E_WAIT_MOP = 12;
E_WAIT_CLIENT_CONFIRM = 13;
E_WAIT_CLIENT_RISK = 14;
E_PRODUCT_NA = 15;
E_RISK_TIMEOUT = 16;
E_PRODUCT_ALREADY_OWNED = 17;
E_WAIT_THIRD_PARTY_RECEIPT = 18;
E_PRODUCT_EVENT_HAS_ENDED = 19;
E_BP_GENERIC_FAIL = 100;
E_BP_INVALID_CC_EXPIRY = 101;
E_BP_RISK_ERROR = 102;
E_BP_NO_VALID_PAYMENT = 103;
E_BP_PAYMENT_AUTH = 104;
E_BP_PROVIDER_DENIED = 105;
E_BP_PURCHASE_BAN = 106;
E_BP_SPENDING_LIMIT = 107;
E_BP_PARENTAL_CONTROL = 108;
E_BP_THROTTLED = 109;
E_BP_THIRD_PARTY_BAD_RECEIPT = 110;
E_BP_THIRD_PARTY_RECEIPT_USED = 111;
E_BP_PRODUCT_UNIQUENESS_VIOLATED = 112;
E_BP_REGION_IS_DOWN = 113;
E_BP_GENERIC_FAIL_RETRY_CONTACT_CS_IF_PERSISTS = 115;
E_BP_CHALLENGE_ID_FAILED_VERIFICATION = 116;
}
required Error error = 1;
optional string purchase_in_progress = 2;
optional string error_code = 3;
}