diff --git a/CHANGELOG.md b/CHANGELOG.md index cecd2d1c..254ed99b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ * Remove bungee chatcolor for Bukkit to support KCauldron * Minor cleanup using inspections + Https * Increase hook delay to let ProtocolLib inject the listener -* Drop support for old authme API + Add support for new authme API +* Drop support for old AuthMe API + Add support for new AuthMe API * Remove ebean util usage to make it compatible with 1.12 * Do not try to hook into a plugin if auth plugin hook is already set using the FastLogin API * Automatically register accounts if they are not in the auth plugin database but in the FastLogin database @@ -14,7 +14,7 @@ * Finally set a value to the API column * No duplicate session login * Fix timestamp parsing in newer versions of SQLite -* Fix Spigot console command invocation sends result to ingame players +* Fix Spigot console command invocation sends result to in game players ### 1.9 @@ -170,7 +170,7 @@ ### 0.5 -* Added unpremium command +* Added cracked command * Added autologin - See config * Added config * Added isRegistered API method diff --git a/README.md b/README.md index b5acae72..28cb99b0 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,8 @@ Put your stats id from the BungeeCord config into this file #### How does minecraft logins work? ###### Online Mode 1. Client -> Server: I want to login, here is my username -2. Server -> Client: Okay. I'm in online mode so here is my public key for encryption and my serverid -3. Client -> Mojang: I'm player "xyz". I want to join a server with that serverid +2. Server -> Client: Okay. I'm in online mode so here is my public key for encryption and my server id +3. Client -> Mojang: I'm player "xyz". I want to join a server with that server id 4. Mojang -> Client: Session data checked. You can continue 5. Client -> Server: I received a successful response from Mojang. Here our shared secret key 6. Server -> Mojang: Does the player "xyz" with this shared secret key has a valid account to join me? @@ -155,7 +155,7 @@ of a cracked player that has the same username. The player have to proof first t to a paid account but if we request a online mode login from a cracked player (who uses a username from a paid account), the player will disconnect with the reason "bad login" or "Invalid session". There is no way to change that message on the server side (without client modifications), because it's a connection between the Client and the -sessionserver. +session-server. 3. If a premium player would skip registration too, a player of a cracked account could later still register the account and would claim and steal the account from the premium player. Because commands cannot be invoked unless the player has a account or is logged in, protects this method also premium players diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 1f8969fb..32a94971 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -34,7 +34,7 @@ http://repo.dmulloy2.net/content/groups/public/ - + xephi-repo https://ci.xephi.fr/plugin/repository/everything/ @@ -52,7 +52,7 @@ https://jitpack.io - + placeholderapi http://repo.extendedclip.com/content/repositories/placeholderapi/ diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java index 33e1d2fb..06df00fa 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/EncryptionUtil.java @@ -44,9 +44,9 @@ public class EncryptionUtil { , serverId.getBytes(Charsets.ISO_8859_1), secretKey.getEncoded(), publicKey.getEncoded()); } - private static byte[] digestOperation(String algo, byte[]... content) { + private static byte[] digestOperation(String algorithm, byte[]... content) { try { - MessageDigest messagedigest = MessageDigest.getInstance(algo); + MessageDigest messagedigest = MessageDigest.getInstance(algorithm); Stream.of(content).forEach(messagedigest::update); return messagedigest.digest(); @@ -81,8 +81,8 @@ public class EncryptionUtil { private static byte[] cipherOperation(int operationMode, Key key, byte[] data) { try { return createCipherInstance(operationMode, key.getAlgorithm(), key).doFinal(data); - } catch (IllegalBlockSizeException | BadPaddingException illegalblocksizeexception) { - illegalblocksizeexception.printStackTrace(); + } catch (IllegalBlockSizeException | BadPaddingException ex) { + ex.printStackTrace(); } System.err.println("Cipher data failed!"); @@ -95,8 +95,8 @@ public class EncryptionUtil { cipher.init(operationMode, key); return cipher; - } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException invalidkeyexception) { - invalidkeyexception.printStackTrace(); + } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException ex) { + ex.printStackTrace(); } System.err.println("Cipher creation failed!"); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java index ad762bf7..69a37dfb 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java @@ -126,7 +126,7 @@ public class FastLoginBukkit extends JavaPlugin implements PlatformPlugin localAddresses, int rateLimit, Map proxies) { super(logger, localAddresses, rateLimit, proxies); } @Override - public boolean hasJoinedServer(LoginSession session, String serverId) { + public boolean hasJoinedServer(LoginSession session, String serverId, InetSocketAddress ip) { BukkitLoginSession playerSession = (BukkitLoginSession) session; try { - String url = HAS_JOINED_URL + "username=" + playerSession.getUsername() + "&serverId=" + serverId; + String url = String.format(HAS_JOINED_URL, playerSession.getUsername(), serverId); + if (ip != null) { + url += "&ip=" + URLEncoder.encode(ip.getAddress().getHostAddress(), "UTF-8"); + } + HttpURLConnection conn = getConnection(url); BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); @@ -54,7 +61,7 @@ public class MojangApiBukkit extends MojangApiConnector { return true; } } catch (Exception ex) { - //catch not only ioexceptions also parse and NPE on unexpected json format + //catch not only io-exceptions also parse and NPE on unexpected json format logger.log(Level.WARNING, "Failed to verify session", ex); } diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java index 4af9faaf..ada11643 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hooks/CrazyLoginHook.java @@ -38,7 +38,7 @@ public class CrazyLoginHook implements AuthPlugin { playerData.setLoggedIn(true); String ip = player.getAddress().getAddress().getHostAddress(); -//this should be done after login to restore the inventory, unhide players, prevent potential memory leaks... +//this should be done after login to restore the inventory, show players, prevent potential memory leaks... //from: https://github.com/ST-DDT/CrazyLogin/blob/master/src/main/java/de/st_ddt/crazylogin/CrazyLogin.java#L1948 playerData.resetLoginFails(); player.setFireTicks(0); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java index cd2cbad7..782a7e66 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/BungeeCordListener.java @@ -54,7 +54,7 @@ public class BungeeCordListener implements PluginMessageListener { //check if the player is still online or disconnected Player checkedPlayer = plugin.getServer().getPlayerExact(playerName); - //fail if target player is blacklisted because already authed or wrong bungeecord id + //fail if target player is blacklisted because already authenticated or wrong bungeecord id if (checkedPlayer != null && !checkedPlayer.hasMetadata(plugin.getName())) { //bungeecord UUID long mostSignificantBits = dataInput.readLong(); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/LoginSkinApplyListener.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/LoginSkinApplyListener.java index eb429239..0bbf03a9 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/LoginSkinApplyListener.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/LoginSkinApplyListener.java @@ -42,7 +42,7 @@ public class LoginSkinApplyListener implements Listener { if (plugin.getConfig().getBoolean("forwardSkin")) { //go through every session, because player.getAddress is null - //loginEvent.getAddress is just a InetAddress not InetSocketAddres, so not unique enough + //loginEvent.getAddress is just a InetAddress not InetSocketAddress, so not unique enough for (BukkitLoginSession session : plugin.getLoginSessions().values()) { if (session.getUsername().equals(player.getName())) { String signature = session.getSkinSignature(); diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java index 12fef8e4..2f0cf1f9 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java @@ -55,7 +55,7 @@ public class NameCheckTask extends JoinManagement { +public class ForceLoginTask extends ForceLoginManagement { public ForceLoginTask(FastLoginCore core, Player player) { super(core, player); diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/MojangApiBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/MojangApiBungee.java index 3f058f03..210f2ed3 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/MojangApiBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/MojangApiBungee.java @@ -3,6 +3,7 @@ package com.github.games647.fastlogin.bungee; import com.github.games647.fastlogin.core.shared.LoginSession; import com.github.games647.fastlogin.core.shared.MojangApiConnector; +import java.net.InetSocketAddress; import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -35,7 +36,7 @@ public class MojangApiBungee extends MojangApiConnector { } @Override - public boolean hasJoinedServer(LoginSession session, String serverId) { + public boolean hasJoinedServer(LoginSession session, String serverId, InetSocketAddress ip) { //this is not needed in Bungee throw new UnsupportedOperationException("Not supported"); } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java index d02225a3..61c646c2 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/PlayerConnectionListener.java @@ -58,7 +58,7 @@ public class PlayerConnectionListener implements Listener { return; } - //use the loginevent instead of the postlogin event in order to send the loginsuccess packet to the client + //use the login event instead of the postlogin event in order to send the loginsuccess packet to the client //with the offline uuid this makes it possible to set the skin then PendingConnection connection = loginEvent.getConnection(); InitialHandler initialHandler = (InitialHandler) connection; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java index af514b06..3f4f8c97 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/tasks/AsyncPremiumCheck.java @@ -47,7 +47,7 @@ public class AsyncPremiumCheck extends JoinManagement { +public class ForceLoginTask extends ForceLoginManagement { private final Server server; diff --git a/core/src/main/java/com/github/games647/fastlogin/core/BalancedSSLFactory.java b/core/src/main/java/com/github/games647/fastlogin/core/BalancedSSLFactory.java index 1735cc1c..12d71543 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/BalancedSSLFactory.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/BalancedSSLFactory.java @@ -5,7 +5,6 @@ import com.google.common.collect.ImmutableList; import java.io.IOException; import java.net.InetAddress; import java.net.Socket; -import java.net.UnknownHostException; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -36,7 +35,7 @@ public class BalancedSSLFactory extends SSLSocketFactory { } @Override - public Socket createSocket(Socket socket, String host, int port, boolean autoclose) throws IOException { + public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { return oldFactory.createSocket(host, port, getNextLocalAddress(), 0); } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index 474929ae..46d353e8 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -65,7 +65,7 @@ public class FastLoginCore

> { protected final Map localeMessages = new ConcurrentHashMap<>(); - private final ConcurrentMap pendingLogins = FastLoginCore.buildCache(5, -1); + private final ConcurrentMap pendingLogin = FastLoginCore.buildCache(5, -1); private final Set pendingConfirms = Sets.newHashSet(); private final T plugin; @@ -186,8 +186,8 @@ public class FastLoginCore

> { this.passwordGenerator = passwordGenerator; } - public ConcurrentMap getPendingLogins() { - return pendingLogins; + public ConcurrentMap getPendingLogin() { + return pendingLogin; } public Collection getPendingConfirms() { diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginMangement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java similarity index 95% rename from core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginMangement.java rename to core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java index cf8588dd..3bc2f5cc 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginMangement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java @@ -6,7 +6,7 @@ import com.github.games647.fastlogin.core.hooks.AuthPlugin; import java.util.logging.Level; -public abstract class ForceLoginMangement

> +public abstract class ForceLoginManagement

> implements Runnable { protected final FastLoginCore core; @@ -14,7 +14,7 @@ public abstract class ForceLoginMangement

core, P player) { + public ForceLoginManagement(FastLoginCore core, P player) { this.core = core; this.player = player; } diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java index 6b24b08d..28a8e96e 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java @@ -29,7 +29,7 @@ public abstract class JoinManagement

{ profile.setLastIp(ip); try { if (profile.getUserId() == -1) { - if (core.getPendingLogins().remove(ip + username) != null && config.get("secondAttemptCracked", false)) { + if (core.getPendingLogin().remove(ip + username) != null && config.get("secondAttemptCracked", false)) { core.getPlugin().getLogger().log(Level.INFO, "Second attempt login -> cracked {0}", username); //first login request failed so make a cracked session diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/MojangApiConnector.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/MojangApiConnector.java index 1fba0727..b853f6fe 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/MojangApiConnector.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/MojangApiConnector.java @@ -112,7 +112,7 @@ public abstract class MojangApiConnector { return null; } - public abstract boolean hasJoinedServer(LoginSession session, String serverId); + public abstract boolean hasJoinedServer(LoginSession session, String serverId, InetSocketAddress ip); protected abstract String getUUIDFromJson(String json); diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index f828cf1c..11f44ec1 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -37,7 +37,7 @@ secondAttemptCracked: false switchMode: false # If this plugin detected that a player has a premium, it can also set the associated -# uuid from that account. So if the players changes their usernames, they will still have +# uuid from that account. So if the player changes the username, they will still have # the same player data (inventory, permissions, ...) # # Warning: This also means that the UUID will be different if the player is connecting @@ -49,14 +49,14 @@ switchMode: false # players could still join the server, because they have different UUID. # # Moreover you may want to convert the offline UUID to a premium UUID. This will ensure that the player -# will have the same inventory, permissions, ... if they switched to premium authentification from offline/cracked +# will have the same inventory, permissions, ... if they switched to premium authentication from offline/cracked # authentication. # # This feature requires Cauldron, Spigot or a fork of Spigot (Paper) premiumUuid: false # This will make an additional check (only for player names which are not in the database) against the mojang servers -# in order to get the premium UUID. If that premium UUID is in the database, we can assume on sucessful login that the +# in order to get the premium UUID. If that premium UUID is in the database, we can assume on successful login that the # player changed it's username and we just update the name in the database. # Examples: # #### Case 1 diff --git a/core/src/main/resources/messages.yml b/core/src/main/resources/messages.yml index a8ab31ce..b4affdbd 100644 --- a/core/src/main/resources/messages.yml +++ b/core/src/main/resources/messages.yml @@ -8,7 +8,7 @@ # You want to have language template? Visit the Github Wiki here: # https://github.com/games647/FastLogin/wiki/English -# In order to split a message into seperate lines you could just make a new line, but keep the ' +# In order to split a message into separate lines you could just make a new line, but keep the ' # Example: # bla: '&aFirst line # Second line @@ -24,10 +24,10 @@ # Switch mode is activated and a new (non-whitelist) cracked player tries to join switch-kick-message: '&4Only paid minecraft whitelisted accounts are allowed to join this server' -# Player activated premium logins in order to skip offline authentication +# Player activated premium login in order to skip offline authentication add-premium: '&2Added to the list of premium players' -# Player activated premium logins in order to skip offline authentication +# Player activated premium login in order to skip offline authentication add-premium-other: '&2Player has been added to the premium list' # Player is already set be a paid account @@ -73,17 +73,17 @@ wait-on-proxy: '&6Sending request...' # authentication. In this state the client expects a success packet with a encrypted connection or disconnect packet. # So we kick the player, if we cannot encrypt the connection. In other situation (example: premium name check), # the player will be just authenticated as cracked -error-kick: '&4Error occured' +error-kick: '&4Error occurred' -# The server sents a verify token within the premium authentication reqest. If this doesn't match on response, +# The server sends a verify token within the premium authentication request. If this doesn't match on response, # it could be another client sending malicious packets invalid-verify-token: '&4Invalid token' # The client sent no request join server request to the mojang servers which would proof that it's owner of that -# acciunt. Only modified clients would do this. +# account. Only modified clients would do this. invalid-session: '&4Invalid session' -# The client sent a malicous packet without a login request packet +# The client sent a malicious packet without a login request packet invalid-requst: '&4Invalid request' # Message if the bukkit isn't fully started to inject the packets