Исправления OSHI HWID

This commit is contained in:
Gravit 2018-12-03 17:44:23 +07:00
parent 6692a01fb1
commit 6cfb3b3dad
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
4 changed files with 43 additions and 16 deletions

View file

@ -19,20 +19,40 @@ public String getSerial()
return ""; return "";
} }
}
public String getProcessorID()
{
try {
return systemInfo.getHardware().getProcessor().getProcessorID();
} catch (Exception e)
{
LogHelper.error(e);
return "";
}
} }
public String getHWDisk() 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")) LogHelper.error(e);
return s.getSerial(); return "";
} }
return "";
} }
public long getTotalMemory() public long getTotalMemory()
{ {
return systemInfo.getHardware().getMemory().getTotal(); return systemInfo.getHardware().getMemory().getTotal();
} }
public long getAvailableMemory()
{
return systemInfo.getHardware().getMemory().getAvailable();
}
@Override @Override
public HWID getHWID() { public HWID getHWID() {
@ -40,9 +60,11 @@ public HWID getHWID() {
hwid.serialNumber = getSerial(); hwid.serialNumber = getSerial();
hwid.totalMemory = getTotalMemory(); hwid.totalMemory = getTotalMemory();
hwid.HWDiskSerial = getHWDisk(); hwid.HWDiskSerial = getHWDisk();
hwid.processorID = getProcessorID();
LogHelper.debug("serialNumber %s",hwid.serialNumber); LogHelper.debug("serialNumber %s",hwid.serialNumber);
LogHelper.debug("totalMemory %d",hwid.totalMemory); LogHelper.debug("totalMemory %d",hwid.totalMemory);
LogHelper.debug("HWDiskSerial %s",hwid.HWDiskSerial); LogHelper.debug("HWDiskSerial %s",hwid.HWDiskSerial);
LogHelper.debug("ProcessorID %s",hwid.processorID);
return hwid; return hwid;
} }
} }

View file

@ -2,10 +2,7 @@
import java.io.IOException; import java.io.IOException;
import ru.gravit.launcher.Launcher; import ru.gravit.launcher.*;
import ru.gravit.launcher.LauncherAPI;
import ru.gravit.launcher.LauncherConfig;
import ru.gravit.launcher.LauncherHWIDInterface;
import ru.gravit.utils.helper.SecurityHelper; import ru.gravit.utils.helper.SecurityHelper;
import ru.gravit.utils.helper.VerifyHelper; import ru.gravit.utils.helper.VerifyHelper;
import ru.gravit.launcher.profiles.PlayerProfile; import ru.gravit.launcher.profiles.PlayerProfile;
@ -33,10 +30,10 @@ private Result(PlayerProfile pp, String accessToken) {
private final byte[] encryptedPassword; private final byte[] encryptedPassword;
private final int auth_id; private final int auth_id;
private final LauncherHWIDInterface hwid; private final HWID hwid;
@LauncherAPI @LauncherAPI
public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, LauncherHWIDInterface hwid) { public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, HWID hwid) {
super(config); super(config);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = encryptedPassword.clone(); this.encryptedPassword = encryptedPassword.clone();
@ -45,7 +42,7 @@ public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword
} }
@LauncherAPI @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); super(config);
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty"); this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
this.encryptedPassword = encryptedPassword.clone(); this.encryptedPassword = encryptedPassword.clone();
@ -54,12 +51,12 @@ public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword
} }
@LauncherAPI @LauncherAPI
public AuthRequest(String login, byte[] encryptedPassword, LauncherHWIDInterface hwid) { public AuthRequest(String login, byte[] encryptedPassword, HWID hwid) {
this(null, login, encryptedPassword,hwid); this(null, login, encryptedPassword,hwid);
} }
@LauncherAPI @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); this(null, login, encryptedPassword, hwid, auth_id);
} }
@ -75,7 +72,7 @@ protected Result requestDo(HInput input, HOutput output) throws IOException {
if (Launcher.profile != null) if (Launcher.profile != null)
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT); output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT);
output.writeInt(auth_id); output.writeInt(auth_id);
output.writeString(hwid.getHWID().getSerializeString(),0); output.writeString(hwid.getSerializeString(),0);
//output.writeLong(0); //output.writeLong(0);
//output.writeLong(0); //output.writeLong(0);
//output.writeLong(0); //output.writeLong(0);

View file

@ -2,5 +2,6 @@
public interface HWID { public interface HWID {
String getSerializeString(); String getSerializeString();
int getLevel(); //Уровень доверия, насколько уникальные значения
boolean isNull(); boolean isNull();
} }

View file

@ -4,20 +4,27 @@
public class OshiHWID implements HWID { public class OshiHWID implements HWID {
public static Gson gson = new Gson(); public static Gson gson = new Gson();
@LauncherAPI
public long totalMemory = 0; public long totalMemory = 0;
@LauncherAPI
public String serialNumber; public String serialNumber;
@LauncherAPI
public String HWDiskSerial; public String HWDiskSerial;
@LauncherAPI
public String processorID;
@Override @Override
public String getSerializeString() { public String getSerializeString() {
return gson.toJson(this); return gson.toJson(this);
} }
@Override
public int getLevel() //Уровень доверия, насколько уникальные значения public int getLevel() //Уровень доверия, насколько уникальные значения
{ {
int result = 0; int result = 0;
if(totalMemory != 0) result++; if(totalMemory != 0) result++;
if(serialNumber != null) result+=5; if(serialNumber != null && !serialNumber.equals("unknown")) result+=4;
if(HWDiskSerial != null) result+=8; if(HWDiskSerial != null && !HWDiskSerial.equals("unknown")) result+=15;
if(processorID != null && !processorID.equals("unknown")) result+=6;
return result; return result;
} }
@Override @Override