-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
209 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
.../java/me/moomoo/anarchyexploitfixes/modules/protocollib/tagparser/AntiTagParserCrash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package me.moomoo.anarchyexploitfixes.modules.protocollib.tagparser; | ||
|
||
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; | ||
import me.moomoo.anarchyexploitfixes.config.Config; | ||
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule; | ||
import me.moomoo.anarchyexploitfixes.utils.LogUtil; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class AntiTagParserCrash implements AnarchyExploitFixesModule { | ||
|
||
public AntiTagParserCrash() { | ||
AnarchyExploitFixes.getConfiguration().addComment("patches.tag-parser-crash-patch.enable", "Patches TagParser crash exploit."); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "tag-parser-crash-patch"; | ||
} | ||
|
||
@Override | ||
public String category() { | ||
return "patches"; | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
new TabCompleteListener().register(); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
Config config = AnarchyExploitFixes.getConfiguration(); | ||
if (config.getBoolean("patches.tag-parser-crash-patch.enable", true)) { | ||
if (config.protocolLib_IsDisabled) { | ||
LogUtil.moduleLog(Level.WARNING, name(), "Not patching exploit because you disabled ProtocolLib in config!"); | ||
return false; | ||
} | ||
if (!AnarchyExploitFixes.isProtocolLibInstalled()) { | ||
LogUtil.moduleLog(Level.SEVERE, name(), "Unable to patch exploit because ProtocolLib is not installed!"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public void disable() {} | ||
} |
53 changes: 53 additions & 0 deletions
53
...java/me/moomoo/anarchyexploitfixes/modules/protocollib/tagparser/TabCompleteListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package me.moomoo.anarchyexploitfixes.modules.protocollib.tagparser; | ||
|
||
import com.comphenix.protocol.PacketType; | ||
import com.comphenix.protocol.ProtocolLibrary; | ||
import com.comphenix.protocol.events.ListenerPriority; | ||
import com.comphenix.protocol.events.PacketAdapter; | ||
import com.comphenix.protocol.events.PacketContainer; | ||
import com.comphenix.protocol.events.PacketEvent; | ||
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; | ||
import me.moomoo.anarchyexploitfixes.utils.LogUtil; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class TabCompleteListener extends PacketAdapter { | ||
|
||
public TabCompleteListener() { | ||
super(AnarchyExploitFixes.getInstance(), ListenerPriority.HIGHEST, PacketType.Play.Client.TAB_COMPLETE); | ||
} | ||
|
||
protected void register() { | ||
ProtocolLibrary.getProtocolManager().addPacketListener(this); | ||
} | ||
|
||
@Override | ||
public void onPacketReceiving(PacketEvent event) { | ||
if (event.isPlayerTemporary()) return; | ||
|
||
final PacketContainer packet = event.getPacket(); | ||
|
||
try { | ||
final String command = packet.getStrings().read(0); | ||
|
||
if (command.contains("@") || command.contains("nbt")) { | ||
if (!event.getPlayer().isOp()) { | ||
event.setCancelled(true); | ||
return; | ||
} | ||
} | ||
|
||
if (command.length() > 64) { | ||
final int index = command.indexOf(' '); | ||
if (index == -1 || index >= 64) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} catch (Exception e) { | ||
LogUtil.moduleLog(Level.WARNING, "tag-parser-crash", | ||
"Error reading TabComplete Request Packet - " + e.getLocalizedMessage() + "\n" + | ||
"This might be due to version incompatibilities.\n" + | ||
"Packet in question: " + packet.toString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../java/me/moomoo/anarchyexploitfixes/modules/protocollib/tagparser/AntiTagParserCrash.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package me.moomoo.anarchyexploitfixes.modules.protocollib.tagparser; | ||
|
||
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; | ||
import me.moomoo.anarchyexploitfixes.config.Config; | ||
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule; | ||
import me.moomoo.anarchyexploitfixes.utils.LogUtil; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class AntiTagParserCrash implements AnarchyExploitFixesModule { | ||
|
||
public AntiTagParserCrash() { | ||
AnarchyExploitFixes.getConfiguration().addComment("patches.tag-parser-crash-patch.enable", "Patches TagParser crash exploit."); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return "tag-parser-crash-patch"; | ||
} | ||
|
||
@Override | ||
public String category() { | ||
return "patches"; | ||
} | ||
|
||
@Override | ||
public void enable() { | ||
new TabCompleteListener().register(); | ||
} | ||
|
||
@Override | ||
public boolean shouldEnable() { | ||
Config config = AnarchyExploitFixes.getConfiguration(); | ||
if (config.getBoolean("patches.tag-parser-crash-patch.enable", true)) { | ||
if (config.protocolLib_IsDisabled) { | ||
LogUtil.moduleLog(Level.WARNING, name(), "Not patching exploit because you disabled ProtocolLib in config!"); | ||
return false; | ||
} | ||
if (!AnarchyExploitFixes.isProtocolLibInstalled()) { | ||
LogUtil.moduleLog(Level.SEVERE, name(), "Unable to patch exploit because ProtocolLib is not installed!"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...java/me/moomoo/anarchyexploitfixes/modules/protocollib/tagparser/TabCompleteListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package me.moomoo.anarchyexploitfixes.modules.protocollib.tagparser; | ||
|
||
import com.comphenix.protocol.PacketType; | ||
import com.comphenix.protocol.ProtocolLibrary; | ||
import com.comphenix.protocol.events.ListenerPriority; | ||
import com.comphenix.protocol.events.PacketAdapter; | ||
import com.comphenix.protocol.events.PacketContainer; | ||
import com.comphenix.protocol.events.PacketEvent; | ||
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes; | ||
import me.moomoo.anarchyexploitfixes.utils.LogUtil; | ||
|
||
import java.util.logging.Level; | ||
|
||
public class TabCompleteListener extends PacketAdapter { | ||
|
||
public TabCompleteListener() { | ||
super(AnarchyExploitFixes.getInstance(), ListenerPriority.HIGHEST, PacketType.Play.Client.TAB_COMPLETE); | ||
} | ||
|
||
protected void register() { | ||
ProtocolLibrary.getProtocolManager().addPacketListener(this); | ||
} | ||
|
||
@Override | ||
public void onPacketReceiving(PacketEvent event) { | ||
if (event.isPlayerTemporary()) return; | ||
|
||
final PacketContainer packet = event.getPacket(); | ||
|
||
try { | ||
final String command = packet.getStrings().read(0); | ||
|
||
if (command.contains("@") || command.contains("nbt")) { | ||
if (!event.getPlayer().isOp()) { | ||
event.setCancelled(true); | ||
return; | ||
} | ||
} | ||
|
||
if (command.length() > 64) { | ||
final int index = command.indexOf(' '); | ||
if (index == -1 || index >= 64) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
} catch (Exception e) { | ||
LogUtil.moduleLog(Level.WARNING, "tag-parser-crash", | ||
"Error reading TabComplete Request Packet - " + e.getLocalizedMessage() + "\n" + | ||
"This might be due to version incompatibilities.\n" + | ||
"Packet in question: " + packet.toString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters