mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
Использованеи библиотеки OSHI для получения HWID
This commit is contained in:
parent
8597206e84
commit
16803776d0
17 changed files with 141 additions and 133 deletions
|
@ -1,8 +1,10 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
|
||||
|
||||
public class AcceptHWIDHandler extends HWIDHandler {
|
||||
|
@ -28,7 +30,7 @@ public void close() {
|
|||
|
||||
@Override
|
||||
public List<HWID> getHwid(String username) {
|
||||
return Collections.singletonList(nullHWID);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launcher.serialize.HOutput;
|
||||
|
||||
public class HWID {
|
||||
public static HWID fromData(HInput in) throws IOException {
|
||||
return gen(in.readLong(), in.readLong(), in.readLong());
|
||||
}
|
||||
|
||||
public static HWID gen(long hwid_hdd, long hwid_bios, long hwid_cpu) {
|
||||
return new HWID(hwid_hdd, hwid_bios, hwid_cpu);
|
||||
}
|
||||
|
||||
private long hwid_bios;
|
||||
|
||||
private long hwid_hdd;
|
||||
|
||||
private long hwid_cpu;
|
||||
|
||||
private HWID(long hwid_hdd, long hwid_bios, long hwid_cpu) {
|
||||
this.hwid_hdd = hwid_hdd;
|
||||
this.hwid_bios = hwid_bios;
|
||||
this.hwid_cpu = hwid_cpu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof HWID))
|
||||
return false;
|
||||
HWID other = (HWID) obj;
|
||||
if (hwid_bios != other.hwid_bios)
|
||||
return false;
|
||||
if (hwid_cpu != other.hwid_cpu)
|
||||
return false;
|
||||
return hwid_hdd == other.hwid_hdd;
|
||||
}
|
||||
|
||||
public long getHwid_bios() {
|
||||
return hwid_bios;
|
||||
}
|
||||
|
||||
public long getHwid_cpu() {
|
||||
return hwid_cpu;
|
||||
}
|
||||
|
||||
public long getHwid_hdd() {
|
||||
return hwid_hdd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (int) (hwid_bios ^ hwid_bios >>> 32);
|
||||
result = prime * result + (int) (hwid_cpu ^ hwid_cpu >>> 32);
|
||||
result = prime * result + (int) (hwid_hdd ^ hwid_hdd >>> 32);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void toData(HOutput out) throws IOException {
|
||||
out.writeLong(hwid_hdd);
|
||||
out.writeLong(hwid_bios);
|
||||
out.writeLong(hwid_cpu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("HWID {hwid_bios=%s, hwid_hdd=%s, hwid_cpu=%s}", hwid_bios, hwid_hdd, hwid_cpu);
|
||||
}
|
||||
}
|
|
@ -5,13 +5,13 @@
|
|||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
import ru.gravit.launcher.serialize.config.ConfigObject;
|
||||
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
|
||||
|
||||
public abstract class HWIDHandler extends ConfigObject implements AutoCloseable {
|
||||
private static final Map<String, Adapter<HWIDHandler>> HW_HANDLERS = new ConcurrentHashMap<>(4);
|
||||
public static final HWID nullHWID = HWID.gen(0, 0, 0);
|
||||
private static boolean registredHandl = false;
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ protected HWIDHandler(BlockConfigEntry block) {
|
|||
public abstract void ban(List<HWID> hwid) throws HWIDException;
|
||||
|
||||
public void check(HWID hwid, String username) throws HWIDException {
|
||||
if (nullHWID.equals(hwid)) return;
|
||||
if (hwid.isNull()) return;
|
||||
check0(hwid, username);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.utils.HTTPRequest;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
@ -25,30 +27,20 @@ public final class JsonHWIDHandler extends HWIDHandler {
|
|||
|
||||
public class banRequest
|
||||
{
|
||||
long hwid_hdd;
|
||||
|
||||
public banRequest(long hwid_hdd, long hwid_cpu, long hwid_bios) {
|
||||
this.hwid_hdd = hwid_hdd;
|
||||
this.hwid_cpu = hwid_cpu;
|
||||
this.hwid_bios = hwid_bios;
|
||||
public banRequest(String hwid) {
|
||||
this.hwid = hwid;
|
||||
}
|
||||
|
||||
long hwid_cpu;
|
||||
long hwid_bios;
|
||||
String hwid;
|
||||
}
|
||||
public class checkRequest
|
||||
{
|
||||
public checkRequest(String username, long hwid_hdd, long hwid_cpu, long hwid_bios) {
|
||||
public checkRequest(String username, String hwid) {
|
||||
this.username = username;
|
||||
this.hwid_hdd = hwid_hdd;
|
||||
this.hwid_cpu = hwid_cpu;
|
||||
this.hwid_bios = hwid_bios;
|
||||
this.hwid = hwid;
|
||||
}
|
||||
|
||||
String username;
|
||||
long hwid_hdd;
|
||||
long hwid_cpu;
|
||||
long hwid_bios;
|
||||
String hwid;
|
||||
|
||||
}
|
||||
public class Result
|
||||
|
@ -62,9 +54,7 @@ public class BannedResult
|
|||
}
|
||||
public class HWIDResult
|
||||
{
|
||||
long hwid_hdd;
|
||||
long hwid_cpu;
|
||||
long hwid_bios;
|
||||
String string;
|
||||
}
|
||||
public class HWIDRequest
|
||||
{
|
||||
|
@ -90,7 +80,7 @@ public HWIDRequest(String username) {
|
|||
@Override
|
||||
public void ban(List<HWID> l_hwid) throws HWIDException {
|
||||
for (HWID hwid : l_hwid) {
|
||||
banRequest request = new banRequest(hwid.getHwid_hdd(),hwid.getHwid_cpu(),hwid.getHwid_bios());
|
||||
banRequest request = new banRequest(hwid.getSerializeString());
|
||||
try {
|
||||
JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlBan);
|
||||
Result r = gson.fromJson(result,Result.class);
|
||||
|
@ -104,7 +94,7 @@ public void ban(List<HWID> l_hwid) throws HWIDException {
|
|||
|
||||
@Override
|
||||
public void check0(HWID hwid, String username) throws HWIDException {
|
||||
checkRequest request = new checkRequest(username,hwid.getHwid_hdd(),hwid.getHwid_cpu(),hwid.getHwid_bios());
|
||||
checkRequest request = new checkRequest(username,hwid.getSerializeString());
|
||||
try {
|
||||
JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlBan);
|
||||
BannedResult r = gson.fromJson(result,BannedResult.class);
|
||||
|
@ -131,7 +121,7 @@ public List<HWID> getHwid(String username) throws HWIDException {
|
|||
HWIDResult[] r = gson.fromJson(result,HWIDResult[].class);
|
||||
for( HWIDResult hw : r)
|
||||
{
|
||||
hwids.add(HWID.gen(hw.hwid_hdd,hw.hwid_bios,hw.hwid_cpu));
|
||||
hwids.add(OshiHWID.gson.fromJson(hw.string,OshiHWID.class));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
|
@ -143,7 +133,7 @@ public List<HWID> getHwid(String username) throws HWIDException {
|
|||
@Override
|
||||
public void unban(List<HWID> l_hwid) throws HWIDException {
|
||||
for (HWID hwid : l_hwid) {
|
||||
banRequest request = new banRequest(hwid.getHwid_hdd(),hwid.getHwid_cpu(),hwid.getHwid_bios());
|
||||
banRequest request = new banRequest(hwid.getSerializeString());
|
||||
try {
|
||||
JsonElement result = HTTPRequest.jsonRequest(gson.toJsonTree(request), urlUnBan);
|
||||
Result r = gson.fromJson(result,Result.class);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package ru.gravit.launchserver.auth.hwid;
|
||||
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.utils.helper.CommonHelper;
|
||||
import ru.gravit.utils.helper.VerifyHelper;
|
||||
import ru.gravit.launcher.serialize.config.entry.BlockConfigEntry;
|
||||
|
@ -22,7 +24,7 @@ public class MysqlHWIDHandler extends HWIDHandler {
|
|||
private final String banMessage;
|
||||
private final String isBannedName;
|
||||
private final String loginName;
|
||||
private final String hddName, cpuName, biosName;
|
||||
private final String hwidName, cpuName, biosName;
|
||||
private final String[] queryParams;
|
||||
private final String queryUpd;
|
||||
private final String[] queryParamsUpd;
|
||||
|
@ -45,8 +47,8 @@ public MysqlHWIDHandler(BlockConfigEntry block) {
|
|||
loginName = VerifyHelper.verify(block.getEntryValue("loginName", StringConfigEntry.class),
|
||||
VerifyHelper.NOT_EMPTY, "loginName can't be empty");
|
||||
banMessage = block.hasEntry("banMessage") ? block.getEntryValue("banMessage", StringConfigEntry.class) : "You HWID Banned";
|
||||
hddName = VerifyHelper.verify(block.getEntryValue("hddName", StringConfigEntry.class),
|
||||
VerifyHelper.NOT_EMPTY, "hddName can't be empty");
|
||||
hwidName = VerifyHelper.verify(block.getEntryValue("hwidName", StringConfigEntry.class),
|
||||
VerifyHelper.NOT_EMPTY, "hwidName can't be empty");
|
||||
cpuName = VerifyHelper.verify(block.getEntryValue("cpuName", StringConfigEntry.class),
|
||||
VerifyHelper.NOT_EMPTY, "cpuName can't be empty");
|
||||
biosName = VerifyHelper.verify(block.getEntryValue("biosName", StringConfigEntry.class),
|
||||
|
@ -72,7 +74,7 @@ public void check0(HWID hwid, String username) throws HWIDException {
|
|||
Connection c = mySQLHolder.getConnection();
|
||||
|
||||
PreparedStatement s = c.prepareStatement(query);
|
||||
String[] replaceParams = {"hwid_hdd", String.valueOf(hwid.getHwid_hdd()), "hwid_cpu", String.valueOf(hwid.getHwid_cpu()), "hwid_bios", String.valueOf(hwid.getHwid_bios()), "login", username};
|
||||
String[] replaceParams = {"hwid", String.valueOf(hwid.getSerializeString()), "login", username};
|
||||
for (int i = 0; i < queryParams.length; i++) {
|
||||
s.setString(i + 1, CommonHelper.replace(queryParams[i], replaceParams));
|
||||
}
|
||||
|
@ -109,7 +111,7 @@ public void writeHWID(HWID hwid, String username, Connection c) {
|
|||
LogHelper.debug("Write HWID %s from username %s", hwid.toString(), username);
|
||||
try (PreparedStatement a = c.prepareStatement(queryUpd)) {
|
||||
//IF
|
||||
String[] replaceParamsUpd = {"hwid_hdd", String.valueOf(hwid.getHwid_hdd()), "hwid_cpu", String.valueOf(hwid.getHwid_cpu()), "hwid_bios", String.valueOf(hwid.getHwid_bios()), "login", username};
|
||||
String[] replaceParamsUpd = {"hwid", String.valueOf(hwid.getSerializeString()), "login", username};
|
||||
for (int i = 0; i < queryParamsUpd.length; i++) {
|
||||
a.setString(i + 1, CommonHelper.replace(queryParamsUpd[i], replaceParamsUpd));
|
||||
}
|
||||
|
@ -130,7 +132,7 @@ public void setIsBanned(HWID hwid, boolean isBanned) {
|
|||
}
|
||||
try (PreparedStatement a = c.prepareStatement(queryBan)) {
|
||||
//IF
|
||||
String[] replaceParamsUpd = {"hwid_hdd", String.valueOf(hwid.getHwid_hdd()), "hwid_cpu", String.valueOf(hwid.getHwid_cpu()), "hwid_bios", String.valueOf(hwid.getHwid_bios()), "isBanned", isBanned ? "1" : "0"};
|
||||
String[] replaceParamsUpd = {"hwid", String.valueOf(hwid.getSerializeString()), "isBanned", isBanned ? "1" : "0"};
|
||||
for (int i = 0; i < queryParamsBan.length; i++) {
|
||||
a.setString(i + 1, CommonHelper.replace(queryParamsBan[i], replaceParamsUpd));
|
||||
}
|
||||
|
@ -166,19 +168,17 @@ public List<HWID> getHwid(String username) {
|
|||
for (int i = 0; i < queryParamsSelect.length; i++) {
|
||||
s.setString(i + 1, CommonHelper.replace(queryParamsSelect[i], replaceParams));
|
||||
}
|
||||
long hdd, cpu, bios;
|
||||
String hwid_str;
|
||||
try (ResultSet set = s.executeQuery()) {
|
||||
if (!set.next()) {
|
||||
LogHelper.error(new HWIDException("HWID not found"));
|
||||
return new ArrayList<>();
|
||||
}
|
||||
hdd = set.getLong(hddName);
|
||||
cpu = set.getLong(cpuName);
|
||||
bios = set.getLong(biosName);
|
||||
hwid_str = set.getString(hwidName);
|
||||
}
|
||||
ArrayList<HWID> list = new ArrayList<>();
|
||||
HWID hwid = HWID.gen(hdd, bios, cpu);
|
||||
if (hdd == 0 && cpu == 0 && bios == 0) {
|
||||
HWID hwid = OshiHWID.gson.fromJson(hwid_str,OshiHWID.class);
|
||||
if (hwid.isNull()) {
|
||||
LogHelper.warning("Null HWID");
|
||||
} else {
|
||||
list.add(hwid);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import java.util.List;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.hwid.HWID;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
public class BanCommand extends Command {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import java.util.List;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.hwid.HWID;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launchserver.command.Command;
|
||||
|
||||
public class UnbanCommand extends Command {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
@ -19,7 +20,7 @@
|
|||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.hwid.HWID;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDException;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
|
@ -45,9 +46,7 @@ public void reply() throws Exception {
|
|||
if (isClient)
|
||||
client = input.readString(SerializeLimits.MAX_CLIENT);
|
||||
int auth_id = input.readInt();
|
||||
long hwid_hdd = input.readLong();
|
||||
long hwid_cpu = input.readLong();
|
||||
long hwid_bios = input.readLong();
|
||||
String hwid_str = input.readString(0);
|
||||
if (auth_id + 1 > server.config.authProvider.length || auth_id < 0) auth_id = 0;
|
||||
byte[] encryptedPassword = input.readByteArray(SecurityHelper.CRYPTO_MAX_LENGTH);
|
||||
// Decrypt password
|
||||
|
@ -93,7 +92,7 @@ public void reply() throws Exception {
|
|||
throw new AuthException("You profile not found");
|
||||
}
|
||||
}
|
||||
server.config.hwidHandler.check(HWID.gen(hwid_hdd, hwid_bios, hwid_cpu), result.username);
|
||||
server.config.hwidHandler.check(OshiHWID.gson.fromJson(hwid_str,OshiHWID.class), result.username);
|
||||
} catch (AuthException | HWIDException e) {
|
||||
requestError(e.getMessage());
|
||||
return;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import ru.gravit.launcher.serialize.signed.SignedObjectHolder;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthException;
|
||||
import ru.gravit.launchserver.auth.hwid.HWID;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launchserver.auth.hwid.HWIDException;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProvider;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
dependencies {
|
||||
compile project(':LauncherAPI')
|
||||
compile 'org.javassist:javassist:3.23.1-GA'
|
||||
compile group: 'com.github.oshi', name: 'oshi-core', version: '3.11.0'
|
||||
}
|
||||
|
||||
task genRuntimeJS(type: Zip) {
|
||||
|
|
|
@ -118,7 +118,7 @@ function makeSetProfileRequest(profile, callback) {
|
|||
|
||||
function makeAuthRequest(login, rsaPassword, callback) {
|
||||
var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) :
|
||||
newRequestTask(new AuthRequest(login, rsaPassword));
|
||||
newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID()));
|
||||
processing.setTaskProperties(task, callback, null, true);
|
||||
task.updateMessage("Авторизация на сервере");
|
||||
startTask(task);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import ru.gravit.launcher.client.ClientLauncher;
|
||||
import ru.gravit.launcher.hasher.FileNameMatcher;
|
||||
import ru.gravit.launcher.hasher.HashedDir;
|
||||
import ru.gravit.launcher.hwid.OshiHWIDProvider;
|
||||
import ru.gravit.launcher.request.Request;
|
||||
import ru.gravit.launcher.request.update.LegacyLauncherRequest;
|
||||
import ru.gravit.launcher.request.websockets.RequestInterface;
|
||||
|
@ -20,6 +21,8 @@ public class FunctionalBridge {
|
|||
public static LauncherSettings settings;
|
||||
@LauncherAPI
|
||||
public static RequestWorker worker;
|
||||
@LauncherAPI
|
||||
public static OshiHWIDProvider hwidProvider = new OshiHWIDProvider();
|
||||
|
||||
@LauncherAPI
|
||||
public HashedDirRunnable offlineUpdateRequest(String dirName, Path dir, SignedObjectHolder<HashedDir> hdir, FileNameMatcher matcher, boolean digest) throws Exception {
|
||||
|
@ -65,4 +68,9 @@ public void startTask(@SuppressWarnings("rawtypes") Task task)
|
|||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
@LauncherAPI
|
||||
public HWID getHWID()
|
||||
{
|
||||
return hwidProvider.getHWID();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package ru.gravit.launcher.hwid;
|
||||
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.HWDiskStore;
|
||||
import ru.gravit.launcher.HWID;
|
||||
import ru.gravit.launcher.LauncherHWIDInterface;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class OshiHWIDProvider implements LauncherHWIDInterface {
|
||||
public static SystemInfo systemInfo = new SystemInfo();
|
||||
public String getSerial()
|
||||
{
|
||||
try {
|
||||
return systemInfo.getHardware().getComputerSystem().getSerialNumber();
|
||||
} catch (Exception e)
|
||||
{
|
||||
LogHelper.error(e);
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
public String getHWDisk()
|
||||
{
|
||||
for(HWDiskStore s : systemInfo.getHardware().getDiskStores())
|
||||
{
|
||||
if(!s.getModel().contains("USB"))
|
||||
return s.getSerial();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public long getTotalMemory()
|
||||
{
|
||||
return systemInfo.getHardware().getMemory().getTotal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HWID getHWID() {
|
||||
OshiHWID hwid = new OshiHWID();
|
||||
hwid.serialNumber = getSerial();
|
||||
hwid.totalMemory = getTotalMemory();
|
||||
hwid.HWDiskSerial = getHWDisk();
|
||||
return hwid;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
import ru.gravit.launcher.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.VerifyHelper;
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
|
@ -33,31 +34,34 @@ private Result(PlayerProfile pp, String accessToken) {
|
|||
|
||||
private final byte[] encryptedPassword;
|
||||
private final int auth_id;
|
||||
private final LauncherHWIDInterface hwid;
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword) {
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, LauncherHWIDInterface hwid) {
|
||||
super(config);
|
||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||
this.encryptedPassword = encryptedPassword.clone();
|
||||
this.hwid = hwid;
|
||||
auth_id = 0;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, int auth_id) {
|
||||
public AuthRequest(LauncherConfig config, String login, byte[] encryptedPassword, LauncherHWIDInterface hwid, int auth_id) {
|
||||
super(config);
|
||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||
this.encryptedPassword = encryptedPassword.clone();
|
||||
this.hwid = hwid;
|
||||
this.auth_id = auth_id;
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(String login, byte[] encryptedPassword) {
|
||||
this(null, login, encryptedPassword);
|
||||
public AuthRequest(String login, byte[] encryptedPassword, LauncherHWIDInterface hwid) {
|
||||
this(null, login, encryptedPassword,hwid);
|
||||
}
|
||||
|
||||
@LauncherAPI
|
||||
public AuthRequest(String login, byte[] encryptedPassword, int auth_id) {
|
||||
this(null, login, encryptedPassword, auth_id);
|
||||
public AuthRequest(String login, byte[] encryptedPassword, LauncherHWIDInterface hwid, int auth_id) {
|
||||
this(null, login, encryptedPassword, hwid, auth_id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,9 +76,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.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetHddId() : 0);
|
||||
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetCpuid() : 0);
|
||||
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetSmbiosId() : 0);
|
||||
output.writeString(hwid.getHWID().getSerializeString(),0);
|
||||
output.writeByteArray(encryptedPassword, SecurityHelper.CRYPTO_MAX_LENGTH);
|
||||
output.flush();
|
||||
|
||||
|
|
6
libLauncher/src/main/java/ru/gravit/launcher/HWID.java
Normal file
6
libLauncher/src/main/java/ru/gravit/launcher/HWID.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package ru.gravit.launcher;
|
||||
|
||||
public interface HWID {
|
||||
String getSerializeString();
|
||||
boolean isNull();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package ru.gravit.launcher;
|
||||
|
||||
public interface LauncherHWIDInterface {
|
||||
HWID getHWID();
|
||||
}
|
27
libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java
Normal file
27
libLauncher/src/main/java/ru/gravit/launcher/OshiHWID.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package ru.gravit.launcher;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class OshiHWID implements HWID {
|
||||
public static Gson gson = new Gson();
|
||||
public long totalMemory = 0;
|
||||
public String serialNumber;
|
||||
public String HWDiskSerial;
|
||||
|
||||
@Override
|
||||
public String getSerializeString() {
|
||||
return gson.toJson(this);
|
||||
}
|
||||
public int getLevel() //Уровень доверия, насколько уникальные значения
|
||||
{
|
||||
int result = 0;
|
||||
if(totalMemory != 0) result++;
|
||||
if(serialNumber != null) result+=5;
|
||||
if(HWDiskSerial != null) result+=8;
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean isNull() {
|
||||
return getLevel() < 2;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue