mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
Merge branch 'feature/eccrypt' of
github.com:GravitLauncher/Launcher into feature/eccrypt
This commit is contained in:
commit
7ef7099430
7 changed files with 81 additions and 16 deletions
|
@ -5,10 +5,12 @@
|
||||||
|
|
||||||
import org.bouncycastle.cert.X509CertificateHolder;
|
import org.bouncycastle.cert.X509CertificateHolder;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.hwid.HWIDCheckHelper;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.command.Command;
|
import pro.gravit.launchserver.command.Command;
|
||||||
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
import pro.gravit.launchserver.socket.handlers.NettyServerSocketHandler;
|
||||||
import pro.gravit.utils.helper.CommonHelper;
|
import pro.gravit.utils.helper.CommonHelper;
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class TestCommand extends Command {
|
public class TestCommand extends Command {
|
||||||
public TestCommand(LaunchServer server) {
|
public TestCommand(LaunchServer server) {
|
||||||
|
@ -55,5 +57,9 @@ public void invoke(String... args) throws Exception {
|
||||||
server.certificateManager.writePrivateKey(Paths.get(name.concat(".key")), pair.getPrivate());
|
server.certificateManager.writePrivateKey(Paths.get(name.concat(".key")), pair.getPrivate());
|
||||||
server.certificateManager.writeCertificate(Paths.get(name.concat(".crt")), cert);
|
server.certificateManager.writeCertificate(Paths.get(name.concat(".crt")), cert);
|
||||||
}
|
}
|
||||||
|
if(args[0].equals("hwidcheck"))
|
||||||
|
{
|
||||||
|
LogHelper.info("HWID String %s bad rating %d", args[1], HWIDCheckHelper.checkString(args[1]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,12 +40,6 @@ public static void main(String... args) throws Throwable {
|
||||||
//if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
//if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
try {
|
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
|
||||||
} catch (Exception ignored)
|
|
||||||
{
|
|
||||||
LogHelper.warning("BouncyCastle not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
LauncherEngine.modulesManager = new ClientModuleManager();
|
LauncherEngine.modulesManager = new ClientModuleManager();
|
||||||
LauncherConfig.getAutogenConfig().initModules();
|
LauncherConfig.getAutogenConfig().initModules();
|
||||||
|
|
|
@ -4,12 +4,15 @@
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.Launcher;
|
||||||
import pro.gravit.launcher.modules.LauncherModule;
|
import pro.gravit.launcher.modules.LauncherModule;
|
||||||
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
import pro.gravit.launcher.modules.impl.SimpleModuleManager;
|
||||||
|
import pro.gravit.utils.verify.LauncherTrustManager;
|
||||||
|
|
||||||
public class ClientModuleManager extends SimpleModuleManager {
|
public class ClientModuleManager extends SimpleModuleManager {
|
||||||
public ClientModuleManager() {
|
public ClientModuleManager() {
|
||||||
super(null, null);
|
super(null, null, Launcher.getConfig().trustManager);
|
||||||
|
checkMode = LauncherTrustManager.CheckMode.EXCEPTION_IN_NOT_SIGNED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +29,13 @@ public void autoload(Path dir) throws IOException {
|
||||||
public LauncherModule loadModule(Path file) throws IOException {
|
public LauncherModule loadModule(Path file) throws IOException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LauncherModule loadModule(LauncherModule module) {
|
||||||
|
checkModuleClass(module.getClass(), LauncherTrustManager.CheckMode.EXCEPTION_IN_NOT_SIGNED);
|
||||||
|
return super.loadModule(module);
|
||||||
|
}
|
||||||
|
|
||||||
public void callWrapper(ProcessBuilder processBuilder, Collection<String> jvmArgs)
|
public void callWrapper(ProcessBuilder processBuilder, Collection<String> jvmArgs)
|
||||||
{
|
{
|
||||||
for(LauncherModule module : modules)
|
for(LauncherModule module : modules)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package pro.gravit.launcher;
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
import java.security.interfaces.ECPrivateKey;
|
import java.security.interfaces.ECPrivateKey;
|
||||||
import java.security.interfaces.ECPublicKey;
|
import java.security.interfaces.ECPublicKey;
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
@ -16,9 +17,11 @@
|
||||||
import pro.gravit.launcher.serialize.stream.StreamObject;
|
import pro.gravit.launcher.serialize.stream.StreamObject;
|
||||||
import pro.gravit.utils.helper.SecurityHelper;
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
import pro.gravit.utils.helper.VerifyHelper;
|
import pro.gravit.utils.helper.VerifyHelper;
|
||||||
|
import pro.gravit.utils.verify.LauncherTrustManager;
|
||||||
|
|
||||||
public final class LauncherConfig extends StreamObject {
|
public final class LauncherConfig extends StreamObject {
|
||||||
private static final AutogenConfig config = new AutogenConfig();
|
private static final AutogenConfig config = new AutogenConfig();
|
||||||
|
private static final SecureAutogenConfig secureConfig = new SecureAutogenConfig();
|
||||||
|
|
||||||
|
|
||||||
public static AutogenConfig getAutogenConfig() {
|
public static AutogenConfig getAutogenConfig() {
|
||||||
|
@ -32,6 +35,7 @@ public static AutogenConfig getAutogenConfig() {
|
||||||
public final int clientPort;
|
public final int clientPort;
|
||||||
public String secretKeyClient;
|
public String secretKeyClient;
|
||||||
public String oemUnlockKey;
|
public String oemUnlockKey;
|
||||||
|
public final LauncherTrustManager trustManager;
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
public final ECPublicKey publicKey;
|
public final ECPublicKey publicKey;
|
||||||
|
|
||||||
|
@ -60,6 +64,11 @@ public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException
|
||||||
clientPort = config.clientPort;
|
clientPort = config.clientPort;
|
||||||
secretKeyClient = config.secretKeyClient;
|
secretKeyClient = config.secretKeyClient;
|
||||||
oemUnlockKey = config.oemUnlockKey;
|
oemUnlockKey = config.oemUnlockKey;
|
||||||
|
try {
|
||||||
|
trustManager = new LauncherTrustManager(secureConfig.certificates);
|
||||||
|
} catch (CertificateException e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
|
||||||
isWarningMissArchJava = config.isWarningMissArchJava;
|
isWarningMissArchJava = config.isWarningMissArchJava;
|
||||||
guardLicenseEncryptKey = config.guardLicenseEncryptKey;
|
guardLicenseEncryptKey = config.guardLicenseEncryptKey;
|
||||||
|
@ -104,6 +113,7 @@ public LauncherConfig(String address, ECPublicKey publicKey, Map<String, byte[]>
|
||||||
secureCheckSalt = null;
|
secureCheckSalt = null;
|
||||||
secureCheckHash = null;
|
secureCheckHash = null;
|
||||||
passwordEncryptKey = null;
|
passwordEncryptKey = null;
|
||||||
|
trustManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LauncherAPI
|
@LauncherAPI
|
||||||
|
@ -123,6 +133,7 @@ public LauncherConfig(String address, ECPublicKey publicKey, Map<String, byte[]>
|
||||||
secureCheckSalt = null;
|
secureCheckSalt = null;
|
||||||
secureCheckHash = null;
|
secureCheckHash = null;
|
||||||
passwordEncryptKey = null;
|
passwordEncryptKey = null;
|
||||||
|
trustManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package pro.gravit.launcher;
|
||||||
|
|
||||||
|
public class SecureAutogenConfig {
|
||||||
|
public byte[][] certificates;
|
||||||
|
|
||||||
|
public SecureAutogenConfig() {
|
||||||
|
//Пока не реализован SecureLauncherConfigurator
|
||||||
|
certificates = new byte[][] {
|
||||||
|
("-----BEGIN CERTIFICATE-----\n" +
|
||||||
|
"MIIFyjCCA7KgAwIBAgIRALnsjNjfvOTXfla3fX1fNEUwDQYJKoZIhvcNAQELBQAw\n" +
|
||||||
|
"WTELMAkGA1UEBhMCUlUxFzAVBgNVBAoTDkdyYXZpdFRydXN0IENBMRAwDgYDVQQL\n" +
|
||||||
|
"EwdSb290IENBMR8wHQYDVQQDExZHcmF2aXQgQ2VudHJhbCBSb290IENBMCAXDTE5\n" +
|
||||||
|
"MDYwOTAyNDIwMFoYDzIwNTEwNjA5MDI0MjAwWjBZMQswCQYDVQQGEwJSVTEXMBUG\n" +
|
||||||
|
"A1UEChMOR3Jhdml0VHJ1c3QgQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHzAdBgNVBAMT\n" +
|
||||||
|
"FkdyYXZpdCBDZW50cmFsIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw\n" +
|
||||||
|
"ggIKAoICAQDA3Qm9OH8Xz3YM3bKkZuQI7T/aL3ulMOdY5GFADYgHrOVZXVSJi/4P\n" +
|
||||||
|
"PruBsut4WXN6TGQdpJtNZ2kyWTYzENGTm/TMzBcIchor1M3JW5Uv/C0r5gSEU1uP\n" +
|
||||||
|
"DPe7oEpeKtb3FXML/pGoGpLv/sonTKky4AKZnK7B15bZ+oVZNwh7UKANpNrVA8k5\n" +
|
||||||
|
"0gb4BisFcegLidYL9Y00H1x5WzUxldQAA1IQuwdkL3NP0NPQrSVJ2Ka2EtebE2HP\n" +
|
||||||
|
"fXHtbftvvnvSWyh4CXAxTfEmJgut0gSPQPm9wVt6pIWWd4O0hHwVmxkKQidgnP6A\n" +
|
||||||
|
"+d05FnJGsBw0ztMCifIteqNiHF0D8E0GuSz6N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oZbvspGAwxmrNMtLE3OYNuMXFF410QSPf4o9QqpGDC3a2mccTXb231a18\n" +
|
||||||
|
"5vDJixeZpuzEm5ECXg8j6aj53X3rtm7C8yfOsg5UTKJJj+pSNz4YTp91IDHm0nTP\n" +
|
||||||
|
"2KhrgS7jujgKdJn9xv07e/API3kLWkVmMwHBiaSCIaHOfAN0RJMQVV+YgnSp2sIa\n" +
|
||||||
|
"OATWgSKH0qTkleE/v7k+USs0a+KV8wmC5wwliqH+uLO++yIP/9bjDctyLulQX5Ee\n" +
|
||||||
|
"+EhD7tb1R/yyWY4uhkzlsr3N2Kl34aQAEBMn8Z1mHsyyu1FcbEaNLU8jcS3pHPVM\n" +
|
||||||
|
"gQRn3m1iDnQlFciAMxW0pW6mW/4xKYzhXk5BTSolnqMVylxHgWXuBwdDDQQVnQ==\n" +
|
||||||
|
"-----END CERTIFICATE-----").getBytes()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package pro.gravit.launcher.hwid;
|
package pro.gravit.launcher.hwid;
|
||||||
|
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class HWIDCheckHelper {
|
public class HWIDCheckHelper {
|
||||||
public static int checkString(String str)
|
public static int checkString(String str)
|
||||||
{
|
{
|
||||||
|
@ -18,16 +20,15 @@ public static int checkString(String str)
|
||||||
if(c == lastChar || Math.abs(c - lastChar) == 1 ||
|
if(c == lastChar || Math.abs(c - lastChar) == 1 ||
|
||||||
( ( lastChar == '0' || lastChar == '9' ) && ( c == 'A' || c == 'a' ))) //Переход с 0 или 9 на A или a
|
( ( lastChar == '0' || lastChar == '9' ) && ( c == 'A' || c == 'a' ))) //Переход с 0 или 9 на A или a
|
||||||
{
|
{
|
||||||
lastChar = c;
|
|
||||||
combo++;
|
combo++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(maxCombo < combo)
|
|
||||||
maxCombo = combo;
|
|
||||||
lastChar = c;
|
|
||||||
combo = 1;
|
combo = 1;
|
||||||
}
|
}
|
||||||
|
lastChar = c;
|
||||||
|
if(maxCombo < combo)
|
||||||
|
maxCombo = combo;
|
||||||
int charType = getCharType(c);
|
int charType = getCharType(c);
|
||||||
if(lastCharType == charType) {
|
if(lastCharType == charType) {
|
||||||
lastCharTypeCombo++;
|
lastCharTypeCombo++;
|
||||||
|
@ -56,6 +57,8 @@ public static int checkString(String str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Считаем результат
|
//Считаем результат
|
||||||
|
LogHelper.debug("HWID Checker maxCombo %d", maxCombo);
|
||||||
|
LogHelper.debug("HWID Checker wtfCharTypeCombo %d", wtfCharTypeCombo);
|
||||||
if(maxCombo > 3) result+= maxCombo * 3;
|
if(maxCombo > 3) result+= maxCombo * 3;
|
||||||
if(wtfCharTypeCombo > 1) result+= wtfCharTypeCombo * 2;
|
if(wtfCharTypeCombo > 1) result+= wtfCharTypeCombo * 2;
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
|
||||||
import org.bouncycastle.jce.provider.JCEIESCipher;
|
|
||||||
import pro.gravit.launcher.LauncherAPI;
|
import pro.gravit.launcher.LauncherAPI;
|
||||||
|
|
||||||
public final class SecurityHelper {
|
public final class SecurityHelper {
|
||||||
|
@ -187,8 +184,8 @@ private static Cipher newCipher(String algo) {
|
||||||
*/
|
*/
|
||||||
private static Cipher newBCCipher(String algo) {
|
private static Cipher newBCCipher(String algo) {
|
||||||
try {
|
try {
|
||||||
return Cipher.getInstance(algo, new BouncyCastleProvider());
|
return Cipher.getInstance(algo, "BC");
|
||||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
} catch (NoSuchAlgorithmException | NoSuchPaddingException | NoSuchProviderException e) {
|
||||||
throw new InternalError(e);
|
throw new InternalError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue