Consistently use Hwid domain object, fix login bypass
Login bypass (skip pin/pic) was broken due to an inconsistency in hwid format.
This commit is contained in:
@@ -89,7 +89,6 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
private Hwid hwid;
|
private Hwid hwid;
|
||||||
private String remoteHwid; // Mac address + hwid in one. Retrieved from client when attempting to enter game.
|
|
||||||
private String remoteAddress;
|
private String remoteAddress;
|
||||||
private volatile boolean inTransition;
|
private volatile boolean inTransition;
|
||||||
|
|
||||||
@@ -269,14 +268,6 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
this.hwid = hwid;
|
this.hwid = hwid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRemoteHwid() {
|
|
||||||
return remoteHwid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemoteHwid(String remoteHwid) {
|
|
||||||
this.remoteHwid = remoteHwid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemoteAddress() {
|
public String getRemoteAddress() {
|
||||||
return remoteAddress;
|
return remoteAddress;
|
||||||
}
|
}
|
||||||
@@ -618,7 +609,7 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int login(String login, String pwd, String nibbleHwid) {
|
public int login(String login, String pwd, Hwid hwid) {
|
||||||
int loginok = 5;
|
int loginok = 5;
|
||||||
|
|
||||||
loginattempt++;
|
loginattempt++;
|
||||||
@@ -676,7 +667,7 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loginok == 0 || loginok == 4) {
|
if (loginok == 0 || loginok == 4) {
|
||||||
AntiMulticlientResult res = MapleSessionCoordinator.getInstance().attemptLoginSession(this, nibbleHwid, accId, loginok == 4);
|
AntiMulticlientResult res = MapleSessionCoordinator.getInstance().attemptLoginSession(this, hwid, accId, loginok == 4);
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case SUCCESS:
|
case SUCCESS:
|
||||||
@@ -756,16 +747,7 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
return ipAddress;
|
return ipAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateHwid(String hwidClientString) {
|
public void updateHwid(Hwid hwid) {
|
||||||
final Hwid hwid;
|
|
||||||
try {
|
|
||||||
hwid = Hwid.fromClientString(hwidClientString);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
log.warn("Failed to create hwid from client string: {}", hwidClientString, e);
|
|
||||||
this.disconnect(false, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hwid = hwid;
|
this.hwid = hwid;
|
||||||
|
|
||||||
try (Connection con = DatabaseConnection.getConnection();
|
try (Connection con = DatabaseConnection.getConnection();
|
||||||
|
|||||||
@@ -112,20 +112,18 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
|
|
||||||
MapleCharacter player = wserv.getPlayerStorage().getCharacterById(cid);
|
MapleCharacter player = wserv.getPlayerStorage().getCharacterById(cid);
|
||||||
|
|
||||||
String remoteHwid;
|
final Hwid hwid;
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
remoteHwid = MapleSessionCoordinator.getInstance().pickLoginSessionHwid(c);
|
hwid = MapleSessionCoordinator.getInstance().pickLoginSessionHwid(c);
|
||||||
if (remoteHwid == null) {
|
if (hwid == null) {
|
||||||
c.disconnect(true, false);
|
c.disconnect(true, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Hwid clientHwid = player.getClient().getHwid();
|
hwid = player.getClient().getHwid();
|
||||||
remoteHwid = clientHwid == null ? null : clientHwid.hwid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.setRemoteHwid(remoteHwid);
|
c.setHwid(hwid);
|
||||||
c.setHwid(new Hwid(remoteHwid));
|
|
||||||
|
|
||||||
if (!server.validateCharacteridInTransition(c, cid)) {
|
if (!server.validateCharacteridInTransition(c, cid)) {
|
||||||
c.disconnect(true, false);
|
c.disconnect(true, false);
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import net.server.Server;
|
|||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
record HostHwid(String hwid, Instant expiry) {
|
record HostHwid(Hwid hwid, Instant expiry) {
|
||||||
static HostHwid createWithDefaultExpiry(String hwid) {
|
static HostHwid createWithDefaultExpiry(Hwid hwid) {
|
||||||
return new HostHwid(hwid, getDefaultExpiry());
|
return new HostHwid(hwid, getDefaultExpiry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,20 +27,20 @@ class HostHwidCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addEntry(String remoteHost, String remoteHwid) {
|
void addEntry(String remoteHost, Hwid hwid) {
|
||||||
hostHwidCache.put(remoteHost, HostHwid.createWithDefaultExpiry(remoteHwid));
|
hostHwidCache.put(remoteHost, HostHwid.createWithDefaultExpiry(hwid));
|
||||||
}
|
}
|
||||||
|
|
||||||
HostHwid getEntry(String remoteHost) {
|
HostHwid getEntry(String remoteHost) {
|
||||||
return hostHwidCache.get(remoteHost);
|
return hostHwidCache.get(remoteHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
String removeEntryAndGetItsHwid(String remoteHost) {
|
Hwid removeEntryAndGetItsHwid(String remoteHost) {
|
||||||
HostHwid hostHwid = hostHwidCache.remove(remoteHost);
|
HostHwid hostHwid = hostHwidCache.remove(remoteHost);
|
||||||
return hostHwid == null ? null : hostHwid.hwid();
|
return hostHwid == null ? null : hostHwid.hwid();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getEntryHwid(String remoteHost) {
|
Hwid getEntryHwid(String remoteHost) {
|
||||||
HostHwid hostHwid = hostHwidCache.get(remoteHost);
|
HostHwid hostHwid = hostHwidCache.get(remoteHost);
|
||||||
return hostHwid == null ? null : hostHwid.hwid();
|
return hostHwid == null ? null : hostHwid.hwid();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,31 +5,22 @@ import java.util.regex.Pattern;
|
|||||||
public record Hwid (String hwid) {
|
public record Hwid (String hwid) {
|
||||||
private static final int HWID_LENGTH = 8;
|
private static final int HWID_LENGTH = 8;
|
||||||
// First part is a mac address (without dashes), second part is the hwid
|
// First part is a mac address (without dashes), second part is the hwid
|
||||||
private static final Pattern VALID_RAW_HWID_PATTERN = Pattern.compile("[0-9A-F]{12}_[0-9A-F]{8}");
|
private static final Pattern VALID_HOST_STRING_PATTERN = Pattern.compile("[0-9A-F]{12}_[0-9A-F]{8}");
|
||||||
|
|
||||||
public static boolean isValidRawHwid(String rawHwid) {
|
private static boolean isValidHostString(String hostString) {
|
||||||
return VALID_RAW_HWID_PATTERN.matcher(rawHwid).matches();
|
return VALID_HOST_STRING_PATTERN.matcher(hostString).matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Hwid fromClientString(String clientString) throws IllegalArgumentException {
|
public static Hwid fromHostString(String hostString) throws IllegalArgumentException {
|
||||||
if (clientString == null) {
|
if (hostString == null || !isValidHostString(hostString)) {
|
||||||
throw new IllegalArgumentException("clientString must not be null");
|
throw new IllegalArgumentException("hostString has invalid format");
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] split = clientString.split("_");
|
final String[] split = hostString.split("_");
|
||||||
if (split.length != 2 || split[1].length() != HWID_LENGTH) {
|
if (split.length != 2 || split[1].length() != HWID_LENGTH) {
|
||||||
throw new IllegalArgumentException("Hwid validation failed for hwid: " + clientString);
|
throw new IllegalArgumentException("Hwid validation failed for hwid: " + hostString);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder newHwid = new StringBuilder();
|
return new Hwid(split[1]);
|
||||||
String convert = split[1];
|
|
||||||
|
|
||||||
int len = convert.length();
|
|
||||||
for (int i = len - 2; i >= 0; i -= 2) {
|
|
||||||
newHwid.append(convert, i, i + 2);
|
|
||||||
}
|
|
||||||
newHwid.insert(4, "-");
|
|
||||||
|
|
||||||
return new Hwid(newHwid.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,22 +60,22 @@ public class MapleSessionCoordinator {
|
|||||||
private final SessionInitialization sessionInit = new SessionInitialization();
|
private final SessionInitialization sessionInit = new SessionInitialization();
|
||||||
private final LoginStorage loginStorage = new LoginStorage();
|
private final LoginStorage loginStorage = new LoginStorage();
|
||||||
private final Map<Integer, MapleClient> onlineClients = new HashMap<>(); // Key: account id
|
private final Map<Integer, MapleClient> onlineClients = new HashMap<>(); // Key: account id
|
||||||
private final Set<String> onlineRemoteHwids = new HashSet<>(); // Hwid/nibblehwid
|
private final Set<Hwid> onlineRemoteHwids = new HashSet<>(); // Hwid/nibblehwid
|
||||||
private final Map<String, Set<MapleClient>> loginRemoteHosts = new HashMap<>(); // Key: Ip (+ nibblehwid)
|
private final Map<String, Set<MapleClient>> loginRemoteHosts = new HashMap<>(); // Key: Ip (+ nibblehwid)
|
||||||
private final HostHwidCache hostHwidCache = new HostHwidCache();
|
private final HostHwidCache hostHwidCache = new HostHwidCache();
|
||||||
|
|
||||||
private MapleSessionCoordinator() {
|
private MapleSessionCoordinator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean attemptAccountAccess(int accountId, String nibbleHwid, boolean routineCheck) {
|
private static boolean attemptAccountAccess(int accountId, Hwid hwid, boolean routineCheck) {
|
||||||
try (Connection con = DatabaseConnection.getConnection()) {
|
try (Connection con = DatabaseConnection.getConnection()) {
|
||||||
List<HwidRelevance> hwidRelevances = SessionDAO.getHwidRelevance(con, accountId);
|
List<HwidRelevance> hwidRelevances = SessionDAO.getHwidRelevance(con, accountId);
|
||||||
for (HwidRelevance hwidRelevance : hwidRelevances) {
|
for (HwidRelevance hwidRelevance : hwidRelevances) {
|
||||||
if (hwidRelevance.hwid().endsWith(nibbleHwid)) {
|
if (hwidRelevance.hwid().endsWith(hwid.hwid())) {
|
||||||
if (!routineCheck) {
|
if (!routineCheck) {
|
||||||
// better update HWID relevance as soon as the login is authenticated
|
// better update HWID relevance as soon as the login is authenticated
|
||||||
Instant expiry = HwidAssociationExpiry.getHwidAccountExpiry(hwidRelevance.relevance());
|
Instant expiry = HwidAssociationExpiry.getHwidAccountExpiry(hwidRelevance.relevance());
|
||||||
SessionDAO.updateAccountAccess(con, nibbleHwid, accountId, expiry, hwidRelevance.getIncrementedRelevance());
|
SessionDAO.updateAccountAccess(con, hwid, accountId, expiry, hwidRelevance.getIncrementedRelevance());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -86,7 +86,7 @@ public class MapleSessionCoordinator {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Failed to update account access. Account id: {}, nibbleHwid: {}", accountId, nibbleHwid, e);
|
log.warn("Failed to update account access. Account id: {}, nibbleHwid: {}", accountId, hwid, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -188,9 +188,9 @@ public class MapleSessionCoordinator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AntiMulticlientResult attemptLoginSession(MapleClient client, String nibbleHwid, int accountId, boolean routineCheck) {
|
public AntiMulticlientResult attemptLoginSession(MapleClient client, Hwid hwid, int accountId, boolean routineCheck) {
|
||||||
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) {
|
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) {
|
||||||
client.setHwid(new Hwid(nibbleHwid));
|
client.setHwid(hwid);
|
||||||
return AntiMulticlientResult.SUCCESS;
|
return AntiMulticlientResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,16 +203,16 @@ public class MapleSessionCoordinator {
|
|||||||
try {
|
try {
|
||||||
if (!loginStorage.registerLogin(accountId)) {
|
if (!loginStorage.registerLogin(accountId)) {
|
||||||
return AntiMulticlientResult.MANY_ACCOUNT_ATTEMPTS;
|
return AntiMulticlientResult.MANY_ACCOUNT_ATTEMPTS;
|
||||||
} else if (routineCheck && !attemptAccountAccess(accountId, nibbleHwid, routineCheck)) {
|
} else if (routineCheck && !attemptAccountAccess(accountId, hwid, routineCheck)) {
|
||||||
return AntiMulticlientResult.REMOTE_REACHED_LIMIT;
|
return AntiMulticlientResult.REMOTE_REACHED_LIMIT;
|
||||||
} else if (onlineRemoteHwids.contains(nibbleHwid)) {
|
} else if (onlineRemoteHwids.contains(hwid)) {
|
||||||
return AntiMulticlientResult.REMOTE_LOGGEDIN;
|
return AntiMulticlientResult.REMOTE_LOGGEDIN;
|
||||||
} else if (!attemptAccountAccess(accountId, nibbleHwid, routineCheck)) {
|
} else if (!attemptAccountAccess(accountId, hwid, routineCheck)) {
|
||||||
return AntiMulticlientResult.REMOTE_REACHED_LIMIT;
|
return AntiMulticlientResult.REMOTE_REACHED_LIMIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
client.setHwid(new Hwid(nibbleHwid));
|
client.setHwid(hwid);
|
||||||
onlineRemoteHwids.add(nibbleHwid);
|
onlineRemoteHwids.add(hwid);
|
||||||
|
|
||||||
return AntiMulticlientResult.SUCCESS;
|
return AntiMulticlientResult.SUCCESS;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -220,11 +220,11 @@ public class MapleSessionCoordinator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AntiMulticlientResult attemptGameSession(MapleClient client, int accountId, String remoteHwid) {
|
public AntiMulticlientResult attemptGameSession(MapleClient client, int accountId, Hwid hwid) {
|
||||||
final String remoteHost = getSessionRemoteHost(client);
|
final String remoteHost = getSessionRemoteHost(client);
|
||||||
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) {
|
if (!YamlConfig.config.server.DETERRED_MULTICLIENT) {
|
||||||
hostHwidCache.addEntry(remoteHost, remoteHwid);
|
hostHwidCache.addEntry(remoteHost, hwid);
|
||||||
hostHwidCache.addEntry(client.getRemoteAddress(), remoteHwid); // no HWID information on the loggedin newcomer session...
|
hostHwidCache.addEntry(client.getRemoteAddress(), hwid); // no HWID information on the loggedin newcomer session...
|
||||||
return AntiMulticlientResult.SUCCESS;
|
return AntiMulticlientResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,26 +234,26 @@ public class MapleSessionCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Hwid nibbleHwid = client.getHwid(); // thanks Paxum for noticing account stuck after PIC failure
|
Hwid clientHwid = client.getHwid(); // thanks Paxum for noticing account stuck after PIC failure
|
||||||
if (nibbleHwid == null) {
|
if (clientHwid == null) {
|
||||||
return AntiMulticlientResult.REMOTE_NO_MATCH;
|
return AntiMulticlientResult.REMOTE_NO_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
onlineRemoteHwids.remove(nibbleHwid);
|
onlineRemoteHwids.remove(clientHwid);
|
||||||
|
|
||||||
if (!remoteHwid.endsWith(nibbleHwid.hwid())) {
|
if (!hwid.equals(clientHwid)) {
|
||||||
return AntiMulticlientResult.REMOTE_NO_MATCH;
|
return AntiMulticlientResult.REMOTE_NO_MATCH;
|
||||||
} else if (onlineRemoteHwids.contains(remoteHwid)) {
|
} else if (onlineRemoteHwids.contains(hwid)) {
|
||||||
return AntiMulticlientResult.REMOTE_LOGGEDIN;
|
return AntiMulticlientResult.REMOTE_LOGGEDIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// assumption: after a SUCCESSFUL login attempt, the incoming client WILL receive a new IoSession from the game server
|
// assumption: after a SUCCESSFUL login attempt, the incoming client WILL receive a new IoSession from the game server
|
||||||
|
|
||||||
// updated session CLIENT_HWID attribute will be set when the player log in the game
|
// updated session CLIENT_HWID attribute will be set when the player log in the game
|
||||||
onlineRemoteHwids.add(remoteHwid);
|
onlineRemoteHwids.add(hwid);
|
||||||
hostHwidCache.addEntry(remoteHost, remoteHwid);
|
hostHwidCache.addEntry(remoteHost, hwid);
|
||||||
hostHwidCache.addEntry(client.getRemoteAddress(), remoteHwid);
|
hostHwidCache.addEntry(client.getRemoteAddress(), hwid);
|
||||||
associateHwidAccountIfAbsent(remoteHwid, accountId);
|
associateHwidAccountIfAbsent(hwid, accountId);
|
||||||
|
|
||||||
return AntiMulticlientResult.SUCCESS;
|
return AntiMulticlientResult.SUCCESS;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -261,41 +261,32 @@ public class MapleSessionCoordinator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void associateHwidAccountIfAbsent(String remoteHwid, int accountId) {
|
private static void associateHwidAccountIfAbsent(Hwid hwid, int accountId) {
|
||||||
try (Connection con = DatabaseConnection.getConnection()) {
|
try (Connection con = DatabaseConnection.getConnection()) {
|
||||||
List<String> hwids = SessionDAO.getHwidsForAccount(con, accountId);
|
List<Hwid> hwids = SessionDAO.getHwidsForAccount(con, accountId);
|
||||||
|
|
||||||
boolean containsRemoteHwid = hwids.stream().anyMatch(hwid -> hwid.contentEquals(remoteHwid));
|
boolean containsRemoteHwid = hwids.stream().anyMatch(accountHwid -> accountHwid.equals(hwid));
|
||||||
if (containsRemoteHwid) {
|
if (containsRemoteHwid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hwids.size() < YamlConfig.config.server.MAX_ALLOWED_ACCOUNT_HWID) {
|
if (hwids.size() < YamlConfig.config.server.MAX_ALLOWED_ACCOUNT_HWID) {
|
||||||
Instant expiry = HwidAssociationExpiry.getHwidAccountExpiry(0);
|
Instant expiry = HwidAssociationExpiry.getHwidAccountExpiry(0);
|
||||||
SessionDAO.registerAccountAccess(con, accountId, remoteHwid, expiry);
|
SessionDAO.registerAccountAccess(con, accountId, hwid, expiry);
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
log.warn("Failed to associate hwid {} with account id {}", remoteHwid, accountId, ex);
|
log.warn("Failed to associate hwid {} with account id {}", hwid, accountId, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MapleClient fetchInTransitionSessionClient(MapleClient client) {
|
private static MapleClient fetchInTransitionSessionClient(MapleClient client) {
|
||||||
String remoteHwid = MapleSessionCoordinator.getInstance().getGameSessionHwid(client);
|
Hwid hwid = MapleSessionCoordinator.getInstance().getGameSessionHwid(client);
|
||||||
if (remoteHwid == null) { // maybe this session was currently in-transition?
|
if (hwid == null) { // maybe this session was currently in-transition?
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int hwidLen = remoteHwid.length();
|
|
||||||
final boolean isOnlyNibbleHwid = hwidLen <= 8;
|
|
||||||
if (isOnlyNibbleHwid) {
|
|
||||||
client.setHwid(new Hwid(remoteHwid));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
client.setRemoteHwid(remoteHwid);
|
|
||||||
client.setHwid(Hwid.fromClientString(remoteHwid));
|
|
||||||
}
|
|
||||||
|
|
||||||
MapleClient fakeClient = MapleClient.createMock();
|
MapleClient fakeClient = MapleClient.createMock();
|
||||||
|
fakeClient.setHwid(hwid);
|
||||||
Integer chrId = Server.getInstance().freeCharacteridInTransition(client);
|
Integer chrId = Server.getInstance().freeCharacteridInTransition(client);
|
||||||
if (chrId != null) {
|
if (chrId != null) {
|
||||||
try {
|
try {
|
||||||
@@ -316,17 +307,10 @@ public class MapleSessionCoordinator {
|
|||||||
final Hwid hwid = client.getHwid();
|
final Hwid hwid = client.getHwid();
|
||||||
client.setHwid(null); // making sure to clean up calls to this function on login phase
|
client.setHwid(null); // making sure to clean up calls to this function on login phase
|
||||||
if (hwid != null) {
|
if (hwid != null) {
|
||||||
onlineRemoteHwids.remove(hwid.hwid());
|
onlineRemoteHwids.remove(hwid);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String remoteHwid = client.getRemoteHwid();
|
final boolean isGameSession = hwid != null;
|
||||||
client.setRemoteHwid(null);
|
|
||||||
if (remoteHwid != null) {
|
|
||||||
onlineRemoteHwids.remove(remoteHwid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client != null) {
|
|
||||||
final boolean isGameSession = hwid != null || remoteHwid != null;
|
|
||||||
if (isGameSession) {
|
if (isGameSession) {
|
||||||
onlineClients.remove(client.getAccID());
|
onlineClients.remove(client.getAccID());
|
||||||
} else {
|
} else {
|
||||||
@@ -337,20 +321,19 @@ public class MapleSessionCoordinator {
|
|||||||
onlineClients.remove(client.getAccID());
|
onlineClients.remove(client.getAccID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (immediately != null && immediately) {
|
if (immediately != null && immediately) {
|
||||||
client.closeSession();
|
client.closeSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String pickLoginSessionHwid(MapleClient client) {
|
public Hwid pickLoginSessionHwid(MapleClient client) {
|
||||||
String remoteHost = client.getRemoteAddress();
|
String remoteHost = client.getRemoteAddress();
|
||||||
// thanks BHB, resinate for noticing players from same network not being able to login
|
// thanks BHB, resinate for noticing players from same network not being able to login
|
||||||
return hostHwidCache.removeEntryAndGetItsHwid(remoteHost);
|
return hostHwidCache.removeEntryAndGetItsHwid(remoteHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGameSessionHwid(MapleClient client) {
|
public Hwid getGameSessionHwid(MapleClient client) {
|
||||||
String remoteHost = getSessionRemoteHost(client);
|
String remoteHost = getSessionRemoteHost(client);
|
||||||
return hostHwidCache.getEntryHwid(remoteHost);
|
return hostHwidCache.getEntryHwid(remoteHost);
|
||||||
}
|
}
|
||||||
@@ -376,11 +359,11 @@ public class MapleSessionCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!onlineRemoteHwids.isEmpty()) {
|
if (!onlineRemoteHwids.isEmpty()) {
|
||||||
List<String> slist = new ArrayList<>(onlineRemoteHwids);
|
List<Hwid> hwids = new ArrayList<>(onlineRemoteHwids);
|
||||||
Collections.sort(slist);
|
hwids.sort(Comparator.comparing(Hwid::hwid));
|
||||||
|
|
||||||
System.out.println("Current online HWIDs: ");
|
System.out.println("Current online HWIDs: ");
|
||||||
for (String s : slist) {
|
for (Hwid s : hwids) {
|
||||||
System.out.println(" " + s);
|
System.out.println(" " + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,11 +393,11 @@ public class MapleSessionCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!onlineRemoteHwids.isEmpty()) {
|
if (!onlineRemoteHwids.isEmpty()) {
|
||||||
List<String> slist = new ArrayList<>(onlineRemoteHwids);
|
List<Hwid> hwids = new ArrayList<>(onlineRemoteHwids);
|
||||||
Collections.sort(slist);
|
hwids.sort(Comparator.comparing(Hwid::hwid));
|
||||||
|
|
||||||
str += ("Current online HWIDs:\r\n");
|
str += ("Current online HWIDs:\r\n");
|
||||||
for (String s : slist) {
|
for (Hwid s : hwids) {
|
||||||
str += (" " + s + "\r\n");
|
str += (" " + s + "\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class SessionDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> getHwidsForAccount(Connection con, int accountId) throws SQLException {
|
public static List<Hwid> getHwidsForAccount(Connection con, int accountId) throws SQLException {
|
||||||
final List<String> hwids = new ArrayList<>();
|
final List<Hwid> hwids = new ArrayList<>();
|
||||||
|
|
||||||
final String query = "SELECT hwid FROM hwidaccounts WHERE accountid = ?";
|
final String query = "SELECT hwid FROM hwidaccounts WHERE accountid = ?";
|
||||||
try (PreparedStatement ps = con.prepareStatement(query)) {
|
try (PreparedStatement ps = con.prepareStatement(query)) {
|
||||||
@@ -31,7 +31,7 @@ public class SessionDAO {
|
|||||||
|
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
hwids.add(rs.getString("hwid"));
|
hwids.add(new Hwid(rs.getString("hwid")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,12 +39,16 @@ public class SessionDAO {
|
|||||||
return hwids;
|
return hwids;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerAccountAccess(Connection con, int accountId, String remoteHwid, Instant expiry)
|
public static void registerAccountAccess(Connection con, int accountId, Hwid hwid, Instant expiry)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
if (hwid == null) {
|
||||||
|
throw new IllegalArgumentException("Hwid must not be null");
|
||||||
|
}
|
||||||
|
|
||||||
final String query = "INSERT INTO hwidaccounts (accountid, hwid, expiresat) VALUES (?, ?, ?)";
|
final String query = "INSERT INTO hwidaccounts (accountid, hwid, expiresat) VALUES (?, ?, ?)";
|
||||||
try (PreparedStatement ps = con.prepareStatement(query)) {
|
try (PreparedStatement ps = con.prepareStatement(query)) {
|
||||||
ps.setInt(1, accountId);
|
ps.setInt(1, accountId);
|
||||||
ps.setString(2, remoteHwid);
|
ps.setString(2, hwid.hwid());
|
||||||
ps.setTimestamp(3, Timestamp.from(expiry));
|
ps.setTimestamp(3, Timestamp.from(expiry));
|
||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
@@ -70,14 +74,14 @@ public class SessionDAO {
|
|||||||
return hwidRelevances;
|
return hwidRelevances;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateAccountAccess(Connection con, String remoteHwid, int accountId, Instant expiry, int loginRelevance)
|
public static void updateAccountAccess(Connection con, Hwid hwid, int accountId, Instant expiry, int loginRelevance)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
final String query = "UPDATE hwidaccounts SET relevance = ?, expiresat = ? WHERE accountid = ? AND hwid LIKE ?";
|
final String query = "UPDATE hwidaccounts SET relevance = ?, expiresat = ? WHERE accountid = ? AND hwid LIKE ?";
|
||||||
try (PreparedStatement ps = con.prepareStatement(query)) {
|
try (PreparedStatement ps = con.prepareStatement(query)) {
|
||||||
ps.setInt(1, loginRelevance);
|
ps.setInt(1, loginRelevance);
|
||||||
ps.setTimestamp(2, Timestamp.from(expiry));
|
ps.setTimestamp(2, Timestamp.from(expiry));
|
||||||
ps.setInt(3, accountId);
|
ps.setInt(3, accountId);
|
||||||
ps.setString(4, remoteHwid);
|
ps.setString(4, hwid.hwid());
|
||||||
|
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import net.server.coordinator.session.Hwid;
|
|||||||
import net.server.coordinator.session.MapleSessionCoordinator;
|
import net.server.coordinator.session.MapleSessionCoordinator;
|
||||||
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
||||||
import net.server.world.World;
|
import net.server.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
|
|
||||||
@@ -35,6 +37,7 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public final class CharSelectedHandler extends AbstractMaplePacketHandler {
|
public final class CharSelectedHandler extends AbstractMaplePacketHandler {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CharSelectedHandler.class);
|
||||||
|
|
||||||
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
||||||
return switch (res) {
|
return switch (res) {
|
||||||
@@ -51,9 +54,13 @@ public final class CharSelectedHandler extends AbstractMaplePacketHandler {
|
|||||||
int charId = slea.readInt();
|
int charId = slea.readInt();
|
||||||
|
|
||||||
String macs = slea.readMapleAsciiString();
|
String macs = slea.readMapleAsciiString();
|
||||||
String hwid = slea.readMapleAsciiString();
|
String hostString = slea.readMapleAsciiString();
|
||||||
|
|
||||||
if (!Hwid.isValidRawHwid(hwid)) {
|
final Hwid hwid;
|
||||||
|
try {
|
||||||
|
hwid = Hwid.fromHostString(hostString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.warn("Invalid host string: {}", hostString, e);
|
||||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import net.server.coordinator.session.Hwid;
|
|||||||
import net.server.coordinator.session.MapleSessionCoordinator;
|
import net.server.coordinator.session.MapleSessionCoordinator;
|
||||||
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
||||||
import net.server.world.World;
|
import net.server.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
|
|
||||||
@@ -14,24 +16,16 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public class CharSelectedWithPicHandler extends AbstractMaplePacketHandler {
|
public class CharSelectedWithPicHandler extends AbstractMaplePacketHandler {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(CharSelectedWithPicHandler.class);
|
||||||
|
|
||||||
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
||||||
switch (res) {
|
return switch (res) {
|
||||||
case REMOTE_PROCESSING:
|
case REMOTE_PROCESSING -> 10;
|
||||||
return 10;
|
case REMOTE_LOGGEDIN -> 7;
|
||||||
|
case REMOTE_NO_MATCH -> 17;
|
||||||
case REMOTE_LOGGEDIN:
|
case COORDINATOR_ERROR -> 8;
|
||||||
return 7;
|
default -> 9;
|
||||||
|
};
|
||||||
case REMOTE_NO_MATCH:
|
|
||||||
return 17;
|
|
||||||
|
|
||||||
case COORDINATOR_ERROR:
|
|
||||||
return 8;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,9 +34,13 @@ public class CharSelectedWithPicHandler extends AbstractMaplePacketHandler {
|
|||||||
int charId = slea.readInt();
|
int charId = slea.readInt();
|
||||||
|
|
||||||
String macs = slea.readMapleAsciiString();
|
String macs = slea.readMapleAsciiString();
|
||||||
String hwid = slea.readMapleAsciiString();
|
String hostString = slea.readMapleAsciiString();
|
||||||
|
|
||||||
if (!Hwid.isValidRawHwid(hwid)) {
|
final Hwid hwid;
|
||||||
|
try {
|
||||||
|
hwid = Hwid.fromHostString(hostString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.warn("Invalid host string: {}", hostString, e);
|
||||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import client.MapleClient;
|
|||||||
import config.YamlConfig;
|
import config.YamlConfig;
|
||||||
import net.MaplePacketHandler;
|
import net.MaplePacketHandler;
|
||||||
import net.server.Server;
|
import net.server.Server;
|
||||||
|
import net.server.coordinator.session.Hwid;
|
||||||
import tools.BCrypt;
|
import tools.BCrypt;
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
import tools.HexTool;
|
import tools.HexTool;
|
||||||
@@ -66,8 +67,8 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
|
|||||||
|
|
||||||
slea.skip(6); // localhost masked the initial part with zeroes...
|
slea.skip(6); // localhost masked the initial part with zeroes...
|
||||||
byte[] hwidNibbles = slea.read(4);
|
byte[] hwidNibbles = slea.read(4);
|
||||||
String nibbleHwid = HexTool.toCompressedString(hwidNibbles);
|
Hwid hwid = new Hwid(HexTool.bytesToHex(hwidNibbles));
|
||||||
int loginok = c.login(login, pwd, nibbleHwid);
|
int loginok = c.login(login, pwd, hwid);
|
||||||
|
|
||||||
|
|
||||||
if (YamlConfig.config.server.AUTOMATIC_REGISTER && loginok == 5) {
|
if (YamlConfig.config.server.AUTOMATIC_REGISTER && loginok == 5) {
|
||||||
@@ -87,7 +88,7 @@ public final class LoginPasswordHandler implements MaplePacketHandler {
|
|||||||
c.setAccID(-1);
|
c.setAccID(-1);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
loginok = c.login(login, pwd, nibbleHwid);
|
loginok = c.login(login, pwd, hwid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import net.server.coordinator.session.Hwid;
|
|||||||
import net.server.coordinator.session.MapleSessionCoordinator;
|
import net.server.coordinator.session.MapleSessionCoordinator;
|
||||||
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
||||||
import net.server.world.World;
|
import net.server.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
|
|
||||||
@@ -14,24 +16,16 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public final class RegisterPicHandler extends AbstractMaplePacketHandler {
|
public final class RegisterPicHandler extends AbstractMaplePacketHandler {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RegisterPicHandler.class);
|
||||||
|
|
||||||
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
||||||
switch (res) {
|
return switch (res) {
|
||||||
case REMOTE_PROCESSING:
|
case REMOTE_PROCESSING -> 10;
|
||||||
return 10;
|
case REMOTE_LOGGEDIN -> 7;
|
||||||
|
case REMOTE_NO_MATCH -> 17;
|
||||||
case REMOTE_LOGGEDIN:
|
case COORDINATOR_ERROR -> 8;
|
||||||
return 7;
|
default -> 9;
|
||||||
|
};
|
||||||
case REMOTE_NO_MATCH:
|
|
||||||
return 17;
|
|
||||||
|
|
||||||
case COORDINATOR_ERROR:
|
|
||||||
return 8;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -40,9 +34,13 @@ public final class RegisterPicHandler extends AbstractMaplePacketHandler {
|
|||||||
int charId = slea.readInt();
|
int charId = slea.readInt();
|
||||||
|
|
||||||
String macs = slea.readMapleAsciiString();
|
String macs = slea.readMapleAsciiString();
|
||||||
String hwid = slea.readMapleAsciiString();
|
String hostString = slea.readMapleAsciiString();
|
||||||
|
|
||||||
if (!Hwid.isValidRawHwid(hwid)) {
|
final Hwid hwid;
|
||||||
|
try {
|
||||||
|
hwid = Hwid.fromHostString(hostString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.warn("Invalid host string: {}", hostString, e);
|
||||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import net.server.coordinator.session.Hwid;
|
|||||||
import net.server.coordinator.session.MapleSessionCoordinator;
|
import net.server.coordinator.session.MapleSessionCoordinator;
|
||||||
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
||||||
import net.server.world.World;
|
import net.server.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.Randomizer;
|
import tools.Randomizer;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
@@ -15,24 +17,16 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public final class ViewAllCharRegisterPicHandler extends AbstractMaplePacketHandler {
|
public final class ViewAllCharRegisterPicHandler extends AbstractMaplePacketHandler {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ViewAllCharRegisterPicHandler.class);
|
||||||
|
|
||||||
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
||||||
switch (res) {
|
return switch (res) {
|
||||||
case REMOTE_PROCESSING:
|
case REMOTE_PROCESSING -> 10;
|
||||||
return 10;
|
case REMOTE_LOGGEDIN -> 7;
|
||||||
|
case REMOTE_NO_MATCH -> 17;
|
||||||
case REMOTE_LOGGEDIN:
|
case COORDINATOR_ERROR -> 8;
|
||||||
return 7;
|
default -> 9;
|
||||||
|
};
|
||||||
case REMOTE_NO_MATCH:
|
|
||||||
return 17;
|
|
||||||
|
|
||||||
case COORDINATOR_ERROR:
|
|
||||||
return 8;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -42,9 +36,13 @@ public final class ViewAllCharRegisterPicHandler extends AbstractMaplePacketHand
|
|||||||
slea.readInt(); // please don't let the client choose which world they should login
|
slea.readInt(); // please don't let the client choose which world they should login
|
||||||
|
|
||||||
String mac = slea.readMapleAsciiString();
|
String mac = slea.readMapleAsciiString();
|
||||||
String hwid = slea.readMapleAsciiString();
|
String hostString = slea.readMapleAsciiString();
|
||||||
|
|
||||||
if (!Hwid.isValidRawHwid(hwid)) {
|
final Hwid hwid;
|
||||||
|
try {
|
||||||
|
hwid = Hwid.fromHostString(hostString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.warn("Invalid host string: {}", hostString, e);
|
||||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import net.server.coordinator.session.Hwid;
|
|||||||
import net.server.coordinator.session.MapleSessionCoordinator;
|
import net.server.coordinator.session.MapleSessionCoordinator;
|
||||||
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
||||||
import net.server.world.World;
|
import net.server.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.Randomizer;
|
import tools.Randomizer;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
@@ -36,24 +38,16 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public final class ViewAllCharSelectedHandler extends AbstractMaplePacketHandler {
|
public final class ViewAllCharSelectedHandler extends AbstractMaplePacketHandler {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ViewAllCharSelectedHandler.class);
|
||||||
|
|
||||||
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
||||||
switch (res) {
|
return switch (res) {
|
||||||
case REMOTE_PROCESSING:
|
case REMOTE_PROCESSING -> 10;
|
||||||
return 10;
|
case REMOTE_LOGGEDIN -> 7;
|
||||||
|
case REMOTE_NO_MATCH -> 17;
|
||||||
case REMOTE_LOGGEDIN:
|
case COORDINATOR_ERROR -> 8;
|
||||||
return 7;
|
default -> 9;
|
||||||
|
};
|
||||||
case REMOTE_NO_MATCH:
|
|
||||||
return 17;
|
|
||||||
|
|
||||||
case COORDINATOR_ERROR:
|
|
||||||
return 8;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,9 +56,13 @@ public final class ViewAllCharSelectedHandler extends AbstractMaplePacketHandler
|
|||||||
slea.readInt(); // please don't let the client choose which world they should login
|
slea.readInt(); // please don't let the client choose which world they should login
|
||||||
|
|
||||||
String macs = slea.readMapleAsciiString();
|
String macs = slea.readMapleAsciiString();
|
||||||
String hwid = slea.readMapleAsciiString();
|
String hostString = slea.readMapleAsciiString();
|
||||||
|
|
||||||
if (!Hwid.isValidRawHwid(hwid)) {
|
final Hwid hwid;
|
||||||
|
try {
|
||||||
|
hwid = Hwid.fromHostString(hostString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.warn("Invalid host string: {}", hostString, e);
|
||||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import net.server.coordinator.session.Hwid;
|
|||||||
import net.server.coordinator.session.MapleSessionCoordinator;
|
import net.server.coordinator.session.MapleSessionCoordinator;
|
||||||
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
import net.server.coordinator.session.MapleSessionCoordinator.AntiMulticlientResult;
|
||||||
import net.server.world.World;
|
import net.server.world.World;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.Randomizer;
|
import tools.Randomizer;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
@@ -15,24 +17,16 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
public class ViewAllCharSelectedWithPicHandler extends AbstractMaplePacketHandler {
|
public class ViewAllCharSelectedWithPicHandler extends AbstractMaplePacketHandler {
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(ViewAllCharSelectedWithPicHandler.class);
|
||||||
|
|
||||||
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
private static int parseAntiMulticlientError(AntiMulticlientResult res) {
|
||||||
switch (res) {
|
return switch (res) {
|
||||||
case REMOTE_PROCESSING:
|
case REMOTE_PROCESSING -> 10;
|
||||||
return 10;
|
case REMOTE_LOGGEDIN -> 7;
|
||||||
|
case REMOTE_NO_MATCH -> 17;
|
||||||
case REMOTE_LOGGEDIN:
|
case COORDINATOR_ERROR -> 8;
|
||||||
return 7;
|
default -> 9;
|
||||||
|
};
|
||||||
case REMOTE_NO_MATCH:
|
|
||||||
return 17;
|
|
||||||
|
|
||||||
case COORDINATOR_ERROR:
|
|
||||||
return 8;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return 9;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -43,9 +37,13 @@ public class ViewAllCharSelectedWithPicHandler extends AbstractMaplePacketHandle
|
|||||||
slea.readInt(); // please don't let the client choose which world they should login
|
slea.readInt(); // please don't let the client choose which world they should login
|
||||||
|
|
||||||
String macs = slea.readMapleAsciiString();
|
String macs = slea.readMapleAsciiString();
|
||||||
String hwid = slea.readMapleAsciiString();
|
String hostString = slea.readMapleAsciiString();
|
||||||
|
|
||||||
if (!Hwid.isValidRawHwid(hwid)) {
|
final Hwid hwid;
|
||||||
|
try {
|
||||||
|
hwid = Hwid.fromHostString(hostString);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
log.warn("Invalid host string: {}", hostString, e);
|
||||||
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
c.announce(MaplePacketCreator.getAfterLoginError(17));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user