Added old commits from forked repo Fastlogin

commits: \nAuto-add - character for offline mode users\nFix empty database getting users marked as cracked falsely\nDon't save offline mode user to database\nalways use false to fix an error\nsome debug stuff...\nadd GovindasPreSecondAttemptEvent\n
This commit is contained in:
mohammed jasem alaajel 2021-06-14 22:39:06 +04:00
parent edfe26957e
commit 1251b67fd7
2 changed files with 310 additions and 1 deletions

View File

@ -0,0 +1,309 @@
From 4c74c0c9b0da05fb070a012dddc791c7fb8c4e4e Mon Sep 17 00:00:00 2001
From: mohammed jasem alaajel <34905970+ham1255@users.noreply.github.com>
Date: Mon, 14 Jun 2021 22:27:22 +0400
Subject: [PATCH] Added old commits from forked repo Fastlogin
commits: \nAuto-add - character for offline mode users\nFix empty database getting users marked as cracked falsely\nDon't save offline mode user to database\nalways use false to fix an error\nsome debug stuff...\nadd GovindasPreSecondAttemptEvent\nshade sqlite so we can stop using mariadb for fastlogin
diff --git a/bungee/pom.xml b/bungee/pom.xml
index 2e6f977..9f9c28a 100644
--- a/bungee/pom.xml
+++ b/bungee/pom.xml
@@ -170,5 +170,11 @@
<optional>true</optional>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.xerial</groupId>
+ <artifactId>sqlite-jdbc</artifactId>
+ <version>3.34.0</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java
index 8a81b14..db8f269 100644
--- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java
+++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java
@@ -42,6 +42,7 @@ import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.Field;
+import java.nio.charset.StandardCharsets;
import java.util.UUID;
import net.md_5.bungee.api.connection.PendingConnection;
@@ -167,6 +168,52 @@ public class ConnectListener implements Listener {
}
}
}
+ // LimeLogin start
+ //start of Govindas code to auto-add "-" character for offline mode users differentiation from online mode
+ else {
+ if (!connection.getName().contains("-")) {
+ InitialHandler initialHandler = (InitialHandler) loginEvent.getConnection();
+ //TODO add bedrock check of player and don't trigger this for bedrock users
+ LoginSession session = plugin.getSession().get(connection);
+ String username = connection.getName();
+
+ //for bedrock support, this opens up vulnerability, so cracked players with * can join without auth
+ //but that isn't a problem as we're handling * in LimeworkProxy instead
+ //but it would be better to handle it here, just need to debug it further
+
+ //debug, we can remove after
+ UUID checkUUID = UUID.nameUUIDFromBytes(("OfflinePlayer:" + connection.getName()).getBytes(StandardCharsets.UTF_8));
+ System.out.println("Profile uuid: " + session.getProfile().getId());
+ System.out.println("Session uuid: " + session.getUuid());
+ System.out.println("Offline uuid: " + checkUUID);
+ if (username.contains("*")) {
+
+ if (checkUUID.equals(session.getProfile().getId())) {
+ System.out.println("IT EQUALS!");
+ }
+ return;
+ }
+ if (username.length() >= 16) {
+ username = username.substring(0, 15);
+ }
+
+ session.setVerifiedUsername("-" + username);
+ initialHandler.getLoginRequest().setData("-" + username);
+ UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + connection.getName()).getBytes(StandardCharsets.UTF_8));
+ plugin.getLog().info("Govindas system has converted username to contain - character: " + username);
+ try {
+ uniqueIdSetter.invokeExact(initialHandler, uuid);
+ } catch (Throwable throwable) {
+ throwable.printStackTrace();
+ }
+ session.getProfile().setPremium(false);
+ session.getProfile().setPlayerName(connection.getName());
+ session.setUuid(uuid);
+ session.getProfile().setId(uuid);
+ }
+ }
+ //end of Govindas code
+ // LimeLogin stop
}
private void setOfflineId(InitialHandler connection, String username) {
diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml
index c52f41a..1d1c8d9 100644
--- a/bungee/src/main/resources/bungee.yml
+++ b/bungee/src/main/resources/bungee.yml
@@ -3,10 +3,10 @@
# This make it easy to combine BungeeCord and Bukkit support in one plugin
name: ${project.parent.name}
# ${-} will be automatically replaced by Maven
-main: ${project.groupId}.${project.artifactId}.${project.name}
+main: com.github.games647.fastlogin.bungee.FastLoginBungee
-version: ${project.version}-${git.commit.id.abbrev}
-author: games647, https://github.com/games647/FastLogin/graphs/contributors
+version: ${project.version}
+author: games647, https://github.com/games647/FastLogin/graphs/contributors, Limework.net
softDepends:
# BungeeCord auth plugins
diff --git a/core/pom.xml b/core/pom.xml
index ccdc63a..3491ef0 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -81,7 +81,7 @@
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-config</artifactId>
- <version>1.12-SNAPSHOT</version>
+ <version>1.16-R0.5-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
@@ -90,6 +90,13 @@
</exclusions>
</dependency>
+ <dependency>
+ <groupId>net.md-5</groupId>
+ <artifactId>bungeecord-proxy</artifactId>
+ <version>1.16-R0.5-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
<!--Floodgate for Xbox Live Authentication-->
<dependency>
<groupId>org.geysermc.floodgate</groupId>
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java
index 94500cb..b304559 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java
@@ -142,9 +142,8 @@ public class AuthStorage {
+ "`Name` VARCHAR(16) NOT NULL, "
+ "`Premium` BOOLEAN NOT NULL, "
+ "`LastIp` VARCHAR(255) NOT NULL, "
- + "`LastLogin` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "
+ + "`LastLogin` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAM"
//the premium shouldn't steal the cracked account by changing the name
- + "UNIQUE (`Name`) "
+ ')';
if (dataSource.getJdbcUrl().contains("sqlite")) {
@@ -208,7 +207,13 @@ public class AuthStorage {
public void save(StoredProfile playerProfile) {
try (Connection con = dataSource.getConnection()) {
String uuid = playerProfile.getOptId().map(UUIDAdapter::toMojangId).orElse(null);
+ // LimeLogin start
+ //start of Govindas code
+ if (!playerProfile.getName().contains("-")) { playerProfile.setPremium(true); }
+ //end of Govindas code
+
+ // LimeLogin stop
playerProfile.getSaveLock().lock();
try {
if (playerProfile.isSaved()) {
@@ -222,6 +227,13 @@ public class AuthStorage {
saveStmt.execute();
}
} else {
+ // LimeLogin start
+
+ //start of Govindas code
+ if (!playerProfile.getName().contains("-")) { playerProfile.setPremium(true); }
+ //end of Govindas code
+
+ // LimeLogin stop
try (PreparedStatement saveStmt = con.prepareStatement(INSERT_PROFILE, RETURN_GENERATED_KEYS)) {
saveStmt.setString(1, uuid);
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java
index 7efb157..b417e64 100644
--- a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java
+++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java
@@ -92,7 +92,13 @@ public abstract class ForceLoginManagement<P extends C, C, L extends LoginSessio
//cracked player
playerProfile.setId(null);
playerProfile.setPremium(false);
- storage.save(playerProfile);
+ // LimeLogin start
+
+ //Govindas comment - don't save cracked player profiles, I found it to be useless
+ //storage.save(playerProfile);
+ //end of Govindas comment
+
+ // LimeLogin stop
}
} catch (Exception ex) {
core.getPlugin().getLog().warn("ERROR ON FORCE LOGIN of {}", getName(player), ex);
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 ec129a8..5490673 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
@@ -34,6 +34,8 @@ import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent;
import java.util.Optional;
+import com.github.games647.fastlogin.core.shared.event.GovindasPreSecondAttemptEvent;
+import net.md_5.bungee.api.ProxyServer;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
import net.md_5.bungee.config.Configuration;
@@ -80,11 +82,16 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
}
} else {
if (core.getPendingLogin().remove(ip + username) != null && config.get("secondAttemptCracked", false)) {
- core.getPlugin().getLog().info("Second attempt login -> cracked {}", username);
-
- //first login request failed so make a cracked session
- startCrackedSession(source, profile, username);
- return;
+ // LimeLogin start
+ GovindasPreSecondAttemptEvent event = new GovindasPreSecondAttemptEvent(ip, username);
+ ProxyServer.getInstance().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ core.getPlugin().getLog().info("Second attempt login -> cracked {}", username);
+ //first login request failed so make a cracked session
+ startCrackedSession(source, profile, username);
+ return;
+ }
+ // LimeLogin start
}
Optional<Profile> premiumUUID = Optional.empty();
@@ -116,8 +123,17 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
private boolean checkPremiumName(S source, String username, StoredProfile profile) throws Exception {
core.getPlugin().getLog().info("GameProfile {} uses a premium username", username);
- if (core.getConfig().get("autoRegister", false) && (authHook == null || !authHook.isRegistered(username))) {
- requestPremiumLogin(source, profile, username, false);
+ // LimeLogin start
+
+ //start of Govindas comment, THIS IS NEEDED to be commented if FastLogin database gets emptied, to not get premium users counted as cracked
+ //if (core.getConfig().get("autoRegister", false) && (authHook == null || !authHook.isRegistered(username))) {
+ //end of Govindas comment
+
+ // LimeLogin stop
+ if (core.getConfig().get("autoRegister", false) && (authHook == null)) {
+ // LimeLogin start
+ requestPremiumLogin(source, profile, username, false); //Comment: always use false to fix an error XD
+ // LimeLogin stop
return true;
}
diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/event/GovindasPreSecondAttemptEvent.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/GovindasPreSecondAttemptEvent.java
new file mode 100644
index 0000000..007083e
--- /dev/null
+++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/event/GovindasPreSecondAttemptEvent.java
@@ -0,0 +1,36 @@
+// LimeLogin start
+package com.github.games647.fastlogin.core.shared.event;
+
+import net.md_5.bungee.api.plugin.Cancellable;
+import net.md_5.bungee.api.plugin.Event;
+
+public class GovindasPreSecondAttemptEvent extends Event implements Cancellable {
+
+ private final String ip;
+ private final String username;
+ private boolean cancelled;
+
+ public GovindasPreSecondAttemptEvent(String ip, String username) {
+ this.ip = ip;
+ this.username = username;
+ }
+ public String getIP() {
+ return ip;
+ }
+
+
+ public String getUsername() {
+ return username;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancelled) {
+ this.cancelled = cancelled;
+ }
+}
+// LimeLogin stop
\ No newline at end of file
diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml
index ecb1c44..477c026 100644
--- a/core/src/main/resources/config.yml
+++ b/core/src/main/resources/config.yml
@@ -235,7 +235,7 @@ autoRegisterFloodgate: false
# Recommended is the use of MariaDB (a better version of MySQL)
# Single file SQLite database
-driver: 'org.sqlite.JDBC'
+driver: 'fastlogin.sqlite.JDBC'
# File location
database: '{pluginDir}/FastLogin.db'
--
2.31.1.windows.1

View File

@ -29,7 +29,7 @@ savePatches() {
target=$2
branch=$3
cd "$basedir/$target"
git format-patch -1 --no-stat -N -o "../${what}-Patches/" $branch
git format-patch --no-stat -N -o "../${what}-Patches/" $branch
cd "$basedir"
git add -A "${what}-Patches"
if [ "$clean" != "clean" ]; then