diff --git a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java index 626648ee..f76da557 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java +++ b/Launcher/src/main/java/ru/gravit/launcher/hwid/OshiHWIDProvider.java @@ -19,20 +19,40 @@ public String getSerial() return ""; } + } + public String getProcessorID() + { + try { + return systemInfo.getHardware().getProcessor().getProcessorID(); + } catch (Exception e) + { + LogHelper.error(e); + return ""; + } + } public String getHWDisk() { - for(HWDiskStore s : systemInfo.getHardware().getDiskStores()) + try { + for (HWDiskStore s : systemInfo.getHardware().getDiskStores()) { + if (!s.getModel().contains("USB")) + return s.getSerial(); + } + return ""; + } catch (Exception e) { - if(!s.getModel().contains("USB")) - return s.getSerial(); + LogHelper.error(e); + return ""; } - return ""; } public long getTotalMemory() { return systemInfo.getHardware().getMemory().getTotal(); } + public long getAvailableMemory() + { + return systemInfo.getHardware().getMemory().getAvailable(); + } @Override public HWID getHWID() { @@ -40,9 +60,11 @@ public HWID getHWID() { hwid.serialNumber = getSerial(); hwid.totalMemory = getTotalMemory(); hwid.HWDiskSerial = getHWDisk(); + hwid.processorID = getProcessorID(); LogHelper.debug("serialNumber %s",hwid.serialNumber); LogHelper.debug("totalMemory %d",hwid.totalMemory); LogHelper.debug("HWDiskSerial %s",hwid.HWDiskSerial); + LogHelper.debug("ProcessorID %s",hwid.processorID); return hwid; } } diff --git a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java index d998c9ec..b62e837e 100644 --- a/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/ru/gravit/launcher/request/auth/AuthRequest.java @@ -2,10 +2,7 @@ import java.io.IOException; -import ru.gravit.launcher.Launcher; -import ru.gravit.launcher.LauncherAPI; -import ru.gravit.launcher.LauncherConfig; -import ru.gravit.launcher.LauncherHWIDInterface; +import ru.gravit.launcher.*; import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.launcher.profiles.PlayerProfile; @@ -33,10 +30,10 @@ private Result(PlayerProfile pp, String accessToken) { private final byte[] encryptedPassword; private final int auth_id; - private final LauncherHWIDInterface hwid; + private final HWID hwid; @LauncherAPI - public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, LauncherHWIDInterface hwid) { + public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, HWID hwid) { super(config); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = encryptedPassword.clone(); @@ -45,7 +42,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword } @LauncherAPI - public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, LauncherHWIDInterface hwid, int auth_id) { + public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, HWID hwid, int auth_id) { super(config); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.encryptedPassword = encryptedPassword.clone(); @@ -54,12 +51,12 @@ public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword } @LauncherAPI - public AuthRequest(String login, byte[] encryptedPassword, LauncherHWIDInterface hwid) { + public AuthRequest(String login, byte[] encryptedPassword, HWID hwid) { this(null, login, encryptedPassword,hwid); } @LauncherAPI - public AuthRequest(String login, byte[] encryptedPassword, LauncherHWIDInterface hwid, int auth_id) { + public AuthRequest(String login, byte[] encryptedPassword, HWID hwid, int auth_id) { this(null, login, encryptedPassword, hwid, auth_id); } @@ -75,7 +72,7 @@ protected Result requestDo(HInput input, HOutput output) throws IOException { if (Launcher.profile != null) output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); output.writeInt(auth_id); - output.writeString(hwid.getHWID().getSerializeString(),0); + output.writeString(hwid.getSerializeString(),0); //output.writeLong(0); //output.writeLong(0); //output.writeLong(0); diff --git a/libLauncher/src/main/java/ru/gravit/launcher/HWID.java b/libLauncher/src/main/java/ru/gravit/launcher/HWID.java index cc510103..d1cf0f9c 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/HWID.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/HWID.java @@ -2,5 +2,6 @@ public interface HWID { String getSerializeString(); + int getLevel(); //Уровень доверия, насколько уникальные значения boolean isNull(); } diff --git a/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java b/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java index 5b1a7a0c..24be03ea 100644 --- a/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java +++ b/libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java @@ -4,20 +4,27 @@ public class OshiHWID implements HWID { public static Gson gson = new Gson(); + @LauncherAPI public long totalMemory = 0; + @LauncherAPI public String serialNumber; + @LauncherAPI public String HWDiskSerial; + @LauncherAPI + public String processorID; @Override public String getSerializeString() { return gson.toJson(this); } + @Override public int getLevel() //Уровень доверия, насколько уникальные значения { int result = 0; if(totalMemory != 0) result++; - if(serialNumber != null) result+=5; - if(HWDiskSerial != null) result+=8; + if(serialNumber != null && !serialNumber.equals("unknown")) result+=4; + if(HWDiskSerial != null && !HWDiskSerial.equals("unknown")) result+=15; + if(processorID != null && !processorID.equals("unknown")) result+=6; return result; } @Override