Compare commits

...

4 Commits

Author SHA1 Message Date
games647
9249c1ea8c Fix equality null test 2022-07-28 13:30:42 +02:00
games647
fd33523189 Perform equality check 2022-07-28 13:25:13 +02:00
games647
5af43170da Try to skip filtering 2022-07-28 13:16:25 +02:00
games647
eb51f0c83c Debug sending fake packet out 2022-07-28 13:05:46 +02:00
2 changed files with 24 additions and 5 deletions

View File

@@ -50,6 +50,7 @@ import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.SignatureException;
import java.time.Instant;
import java.util.Objects;
import java.util.Optional;
import javax.crypto.BadPaddingException;
@@ -58,6 +59,7 @@ import javax.crypto.NoSuchPaddingException;
import lombok.var;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import static com.comphenix.protocol.PacketType.Login.Client.ENCRYPTION_BEGIN;
import static com.comphenix.protocol.PacketType.Login.Client.START;
@@ -75,6 +77,9 @@ public class ProtocolLibListener extends PacketAdapter {
private final boolean verifyClientKeys;
@Nullable
private PacketContainer lastStartPacket;
public ProtocolLibListener(FastLoginBukkit plugin, AntiBotService antiBotService, boolean verifyClientKeys) {
//run async in order to not block the server, because we are making api calls to Mojang
super(params()
@@ -95,12 +100,25 @@ public class ProtocolLibListener extends PacketAdapter {
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
plugin.getLog().info("New packet {} from {}; Cancellation: {}, Auth-Plugin: {}, Initialized: {}, Meta: {}",
PacketContainer packet = packetEvent.getPacket();
plugin.getLog().info("New packet {} from {}; Cancellation: {}, Meta: {}",
packetEvent.getPacketType(), packetEvent.getPlayer(), packetEvent.isCancelled(),
plugin.getCore().getAuthPluginHook(), !plugin.isServerFullyStarted(),
packetEvent.getPacket().getMeta(SOURCE_META_KEY)
packet.getMeta(SOURCE_META_KEY)
);
if (packetEvent.getPacketType() == START) {
if (lastStartPacket != null) {
plugin.getLog().info("Start-packet equality (Last/New): {}/{}, {}",
lastStartPacket.getHandle().hashCode(), packet.getHandle().hashCode(),
Objects.equals(lastStartPacket.getHandle(), packet.getHandle())
);
plugin.getLog().info("Content: {}, {}", lastStartPacket.getHandle(), packet.getHandle());
}
lastStartPacket = packet;
}
if (packetEvent.isCancelled()
|| plugin.getCore().getAuthPluginHook() == null
|| !plugin.isServerFullyStarted()) {
@@ -115,7 +133,7 @@ public class ProtocolLibListener extends PacketAdapter {
Player sender = packetEvent.getPlayer();
PacketType packetType = packetEvent.getPacketType();
if (packetType == START) {
PacketContainer packet = packetEvent.getPacket();
// PacketContainer packet = packet;
InetSocketAddress address = sender.getAddress();
String username = getUsername(packet);

View File

@@ -196,7 +196,7 @@ public class VerifyResponseTask implements Runnable {
}
//try to get the networkManager from ProtocolLib
private Object getNetworkManager() throws IllegalAccessException, ClassNotFoundException {
private Object getNetworkManager() throws ClassNotFoundException {
Object injectorContainer = TemporaryPlayerFactory.getInjectorFromPlayer(player);
// ChannelInjector
@@ -290,5 +290,6 @@ public class VerifyResponseTask implements Runnable {
//we don't want to handle our own packets so ignore filters
startPacket.setMeta(ProtocolLibListener.SOURCE_META_KEY, plugin.getName());
ProtocolLibrary.getProtocolManager().receiveClientPacket(player, startPacket, true);
plugin.getLog().info("Sending new fake login start packet to {}-{}", player, username);
}
}