mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 16:53:22 +08:00
Full support for both parties
This commit is contained in:
parent
0a557ccfcd
commit
ae8b5e30ac
@ -103,12 +103,6 @@ public final class DefaultAuthenticators {
|
|||||||
String responseMessage = translate("messages.dispatch.account.username_error");
|
String responseMessage = translate("messages.dispatch.account.username_error");
|
||||||
String loggerMessage = "";
|
String loggerMessage = "";
|
||||||
String decryptedPassword = "";
|
String decryptedPassword = "";
|
||||||
|
|
||||||
// Get Password
|
|
||||||
if (GAME_OPTIONS.uaPatchCompatible) {
|
|
||||||
// Make sure your patch can send passwords in plain text
|
|
||||||
decryptedPassword = request.getPasswordRequest().password;
|
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
byte[] key = FileUtils.readResource("/keys/auth_private-key.der");
|
byte[] key = FileUtils.readResource("/keys/auth_private-key.der");
|
||||||
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(key);
|
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(key);
|
||||||
@ -121,8 +115,7 @@ public final class DefaultAuthenticators {
|
|||||||
|
|
||||||
decryptedPassword = new String(cipher.doFinal(Utils.base64Decode(request.getPasswordRequest().password)), StandardCharsets.UTF_8);
|
decryptedPassword = new String(cipher.doFinal(Utils.base64Decode(request.getPasswordRequest().password)), StandardCharsets.UTF_8);
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
ignored.printStackTrace();
|
decryptedPassword = request.getPasswordRequest().password;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decryptedPassword == null) {
|
if (decryptedPassword == null) {
|
||||||
|
@ -11,6 +11,7 @@ import emu.grasscutter.server.event.dispatch.QueryCurrentRegionEvent;
|
|||||||
import emu.grasscutter.server.http.Router;
|
import emu.grasscutter.server.http.Router;
|
||||||
import emu.grasscutter.server.http.objects.QueryCurRegionRspJson;
|
import emu.grasscutter.server.http.objects.QueryCurRegionRspJson;
|
||||||
import emu.grasscutter.utils.Crypto;
|
import emu.grasscutter.utils.Crypto;
|
||||||
|
import emu.grasscutter.utils.FileUtils;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import express.Express;
|
import express.Express;
|
||||||
import express.http.Request;
|
import express.http.Request;
|
||||||
@ -19,6 +20,11 @@ import io.javalin.Javalin;
|
|||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.security.KeyFactory;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.security.Signature;
|
import java.security.Signature;
|
||||||
@ -139,9 +145,8 @@ public final class RegionHandler implements Router {
|
|||||||
try {
|
try {
|
||||||
QueryCurrentRegionEvent event = new QueryCurrentRegionEvent(regionData); event.call();
|
QueryCurrentRegionEvent event = new QueryCurrentRegionEvent(regionData); event.call();
|
||||||
|
|
||||||
if (GAME_OPTIONS.uaPatchCompatible) {
|
if (request.query("dispatchSeed") == null) {
|
||||||
// More love for UA Patch players
|
// More love for UA Patch players
|
||||||
|
|
||||||
var rsp = new QueryCurRegionRspJson();
|
var rsp = new QueryCurRegionRspJson();
|
||||||
|
|
||||||
rsp.content = event.getRegionInfo();
|
rsp.content = event.getRegionInfo();
|
||||||
|
@ -101,19 +101,7 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
|
|
||||||
// Only >= 2.7.50 has this
|
// Only >= 2.7.50 has this
|
||||||
if (req.getKeyId() > 0) {
|
if (req.getKeyId() > 0) {
|
||||||
if (GAME_OPTIONS.uaPatchCompatible) {
|
try {
|
||||||
// More love for ua patch plz 😭
|
|
||||||
|
|
||||||
byte[] clientBytes = Utils.base64Decode(req.getClientSeed());
|
|
||||||
byte[] seed = ByteHelper.longToBytes(Crypto.ENCRYPT_SEED);
|
|
||||||
Crypto.xor(clientBytes, seed);
|
|
||||||
|
|
||||||
String base64str = Utils.base64Encode(clientBytes);
|
|
||||||
|
|
||||||
session.send(new PacketGetPlayerTokenRsp(session, base64str, "bm90aGluZyBoZXJl"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
|
||||||
cipher.init(Cipher.DECRYPT_MODE, Crypto.CUR_SIGNING_KEY);
|
cipher.init(Cipher.DECRYPT_MODE, Crypto.CUR_SIGNING_KEY);
|
||||||
|
|
||||||
@ -134,6 +122,16 @@ public class HandlerGetPlayerTokenReq extends PacketHandler {
|
|||||||
privateSignature.update(seed_bytes);
|
privateSignature.update(seed_bytes);
|
||||||
|
|
||||||
session.send(new PacketGetPlayerTokenRsp(session, Utils.base64Encode(seed_encrypted), Utils.base64Encode(privateSignature.sign())));
|
session.send(new PacketGetPlayerTokenRsp(session, Utils.base64Encode(seed_encrypted), Utils.base64Encode(privateSignature.sign())));
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
// Only UA Patch users will have exception
|
||||||
|
byte[] clientBytes = Utils.base64Decode(req.getClientSeed());
|
||||||
|
byte[] seed = ByteHelper.longToBytes(Crypto.ENCRYPT_SEED);
|
||||||
|
Crypto.xor(clientBytes, seed);
|
||||||
|
|
||||||
|
String base64str = Utils.base64Encode(clientBytes);
|
||||||
|
|
||||||
|
session.send(new PacketGetPlayerTokenRsp(session, base64str, "bm90aGluZyBoZXJl"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Send packet
|
// Send packet
|
||||||
|
@ -211,7 +211,6 @@ public class ConfigContainer {
|
|||||||
public int cap = 160;
|
public int cap = 160;
|
||||||
public int rechargeTime = 480;
|
public int rechargeTime = 480;
|
||||||
}
|
}
|
||||||
public boolean uaPatchCompatible = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class JoinOptions {
|
public static class JoinOptions {
|
||||||
|
Loading…
Reference in New Issue
Block a user