Added a fix to the new item name exploit that makes it possible to make clickable text and, made the chest patch work for all containers and so that books are cleared properly...

This commit is contained in:
CoolJWB 2020-07-20 01:49:07 +02:00
parent 04524c9e3b
commit 5bc6d8c0fd
16 changed files with 114 additions and 42 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="VulnerabilityPatcher:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="me.cooljwb.vulnerabilitypatcher" external.system.module.type="sourceSet" external.system.module.version="v1.6" type="JAVA_MODULE" version="4">
<module external.linked.project.id="VulnerabilityPatcher:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="me.cooljwb.vulnerabilitypatcher" external.system.module.type="sourceSet" external.system.module.version="v1.8" type="JAVA_MODULE" version="4">
<component name="CheckStyle-IDEA-Module">
<option name="configuration">
<map />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="VulnerabilityPatcher:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="me.cooljwb.vulnerabilitypatcher" external.system.module.type="sourceSet" external.system.module.version="v1.6" type="JAVA_MODULE" version="4">
<module external.linked.project.id="VulnerabilityPatcher:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="me.cooljwb.vulnerabilitypatcher" external.system.module.type="sourceSet" external.system.module.version="v1.8" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="VulnerabilityPatcher" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="me.cooljwb.vulnerabilitypatcher" external.system.module.version="v1.6" type="JAVA_MODULE" version="4">
<module external.linked.project.id="VulnerabilityPatcher" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="me.cooljwb.vulnerabilitypatcher" external.system.module.version="v1.8" type="JAVA_MODULE" version="4">
<component name="CheckStyle-IDEA-Module">
<option name="configuration">
<map />
</option>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../..">

View file

@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4038a6e9-7d52-4dd0-91ef-d9a12aa1c1b2" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Beehives.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Skulls.java" afterDir="false" />
<list default="true" id="4038a6e9-7d52-4dd0-91ef-d9a12aa1c1b2" name="Default Changelist" comment="Added a fix to the new item name exploit that makes it possible to make clickable text and, made the chest patch work for all containers and so that books are cleared properly...">
<change afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Item_Names.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules/VulnerabilityPatcher.main.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules/VulnerabilityPatcher.main.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules/VulnerabilityPatcher.test.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules/VulnerabilityPatcher.test.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/modules/me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/modules/me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/gradle.properties" beforeDir="false" afterPath="$PROJECT_DIR$/gradle.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/VulnerabilityPatcher.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/VulnerabilityPatcher.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13_2.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13_2.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_14.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_14.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_15.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_15.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_16.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_16.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Disconnect_Items.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Disconnect_Items.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Books.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Books.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Chests.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Containers.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Patches.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Patches.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/config.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/config.yml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/resources/plugin.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/plugin.yml" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
@ -39,6 +43,11 @@
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="VulnerabilityPatcher" type="f1a62948:ProjectNode" />
</path>
<path>
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="VulnerabilityPatcher" type="f1a62948:ProjectNode" />
<item name="Source Sets" type="e897c970:GradleViewContributor$SourceSetsNode" />
</path>
<path>
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="VulnerabilityPatcher" type="f1a62948:ProjectNode" />
@ -57,6 +66,9 @@
</state>
</system>
</component>
<component name="FavoritesManager">
<favorites_list name="VulnerabilityPatcher" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
@ -79,7 +91,7 @@
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1565016144369" />
<property name="last_opened_file_path" value="$USER_HOME$/Desktop/TF/TF - Code/TFM 1.16/TotalFreedomMod" />
<property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.last.edited" value="Libraries" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="settings.editor.selected.configurable" value="editor.preferences.completion" />
@ -148,4 +160,8 @@
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Added a fix to the new item name exploit that makes it possible to make clickable text and, made the chest patch work for all containers and so that books are cleared properly..." />
<option name="LAST_COMMIT_MESSAGE" value="Added a fix to the new item name exploit that makes it possible to make clickable text and, made the chest patch work for all containers and so that books are cleared properly..." />
</component>
</project>

View file

@ -1,2 +1,2 @@
pluginGroup=me.cooljwb.vulnerabilitypatcher
pluginVersion=v1.6
pluginVersion=v1.8

View file

@ -68,6 +68,7 @@ public final class VulnerabilityPatcher extends JavaPlugin {
Bukkit.getServer().getPluginCommand(CommandVulnerabilityPatcher.vulnerabilitypatcher).setExecutor(commandvulnerabilitypatcher);
Bukkit.getServer().getPluginCommand(CommandGetNBT.getnbt).setExecutor(commandgetnbt);
Bukkit.getServer().getPluginCommand(CommandGetLag.getlag).setExecutor(commandgetlag);
//Bukkit.getPluginManager().registerEvents(new DisconnectionAid(), this); In-dev feature.
hand_switch.runnable();
@ -136,11 +137,12 @@ public final class VulnerabilityPatcher extends JavaPlugin {
case "StructureBlocks": listeners.add(new Structure_Blocks()); break;
case "Chunks": listeners.add(new Chunks()); break;
case "ItemFrames": listeners.add(new Item_Frames()); break;
case "Handswitch": listeners.add(new Handswitch()); break;
case "HandSwitch": listeners.add(new Handswitch()); break;
case "Fireworks": listeners.add(new Fireworks()); break;
case "Chests": listeners.add(new Chests()); break;
case "Containers": listeners.add(new Containers()); break;
case "Beehives": listeners.add(new Beehives()); break;
case "Skulls": listeners.add(new Skulls()); break;
case "ItemNames": listeners.add(new Item_Names()); break;
} // Adds all events to the event register.
}
listeners.forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this)); // Register the events.

View file

@ -95,7 +95,8 @@ public class NBTModifier_1_13_2 {
net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
if(nmsItemStack.hasTag() && nmsItemStack.getTag().hasKey("pages")) {
if (nmsItemStack.getTag().getList("pages", 8).toString().contains("run_command")) {
String pages = nmsItemStack.getTag().getList("pages", 8).toString();
if (pages.contains("clickEvent") || pages.contains("hoverEvent")) {
BookMeta meta = (BookMeta) item.getItemMeta();
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);

View file

@ -116,7 +116,8 @@ public class NBTModifier_1_14 {
net.minecraft.server.v1_14_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
if(nmsItemStack.hasTag() && nmsItemStack.getTag().hasKey("pages")) {
if (nmsItemStack.getTag().getList("pages", 8).toString().contains("run_command")) {
String pages = nmsItemStack.getTag().getList("pages", 8).toString();
if (pages.contains("clickEvent") || pages.contains("hoverEvent")) {
BookMeta meta = (BookMeta) item.getItemMeta();
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);

View file

@ -116,7 +116,8 @@ public class NBTModifier_1_15 {
net.minecraft.server.v1_15_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
if(nmsItemStack.hasTag() && nmsItemStack.getTag().hasKey("pages")) {
if (nmsItemStack.getTag().getList("pages", 8).toString().contains("run_command")) {
String pages = nmsItemStack.getTag().getList("pages", 8).toString();
if (pages.contains("clickEvent") || pages.contains("hoverEvent")) {
BookMeta meta = (BookMeta) item.getItemMeta();
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);

View file

@ -117,7 +117,8 @@ public class NBTModifier_1_16 {
net.minecraft.server.v1_16_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
if(nmsItemStack.hasTag() && nmsItemStack.getTag().hasKey("pages")) {
if (nmsItemStack.getTag().getList("pages", 8).toString().contains("run_command")) {
String pages = nmsItemStack.getTag().getList("pages", 8).toString();
if (pages.contains("clickEvent") || pages.contains("hoverEvent")) {
BookMeta meta = (BookMeta) item.getItemMeta();
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);

View file

@ -39,7 +39,6 @@ public class Books extends Patches implements Listener {
ItemStack item = event.getItem();
EquipmentSlot hand = event.getHand();
switch (item.getType().toString()) {
case "WRITTEN_BOOK":
writtenBook(player, hand);
@ -67,14 +66,16 @@ public class Books extends Patches implements Listener {
private void knowledgeBook(Player player, EquipmentSlot hand) {
if(hand.name().equals("OFF_HAND")) {
ItemStack hand_item = player.getInventory().getItemInOffHand();
if(itemToString(hand_item).length() > 100)
if(itemToString(hand_item).length() > 100) {
hand_item.setItemMeta(null);
}
}
else if(hand.name().equals("HAND")) {
ItemStack hand_item = player.getInventory().getItemInMainHand();
if(itemToString(hand_item).length() > 100)
if(itemToString(hand_item).length() > 100) {
hand_item.setItemMeta(null);
}
}
}
}

View file

@ -1,17 +1,16 @@
package me.cooljwb.vulnerabilitypatcher.patches;
import org.bukkit.block.Chest;
import org.bukkit.block.Container;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class Chests extends Patches implements Listener {
public class Containers extends Patches implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreakEvent(BlockBreakEvent event) {
if(event.getBlock().getState() instanceof Chest) {
if(event.getBlock().getState() instanceof Container) {
Container container = (Container) event.getBlock().getState();
container.getInventory().clear();
}

View file

@ -0,0 +1,25 @@
package me.cooljwb.vulnerabilitypatcher.patches;
import org.apache.commons.lang.StringUtils;
import org.bukkit.entity.Tameable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
public class Item_Names extends Patches implements Listener {
@EventHandler
public void onDeathMessage(PlayerDeathEvent event) {
if(event.getDeathMessage().contains("using")) {
event.setDeathMessage(StringUtils.substringBefore(event.getDeathMessage(), "using"));
}
}
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if(event.getEntity() instanceof Tameable && ((Tameable) event.getEntity()).getOwner() != null) {
event.setDamage(0);
event.getEntity().remove();
}
}
}

View file

@ -67,7 +67,7 @@ public class Patches extends NBTModifier implements Listener {
public static byte mode = 0;
public Patches() {}
public Patches() { }
public Patches(VulnerabilityPatcher main) {
Patches.main = main;
listeners = main.getConfig().getStringList("Patches");
@ -91,15 +91,24 @@ public class Patches extends NBTModifier implements Listener {
@Override
public void run() {
for(Player player : Bukkit.getOnlinePlayers()) {
if(player.getLocation().getY() <= -29999990) { // Fixes invalid movement disconnection.
if(player.getInventory().getContents().toString().length() > 1048560) {
for(ItemStack item : player.getInventory()) {
clearItemMeta(item);
}
}
// Fixes invalid movement disconnection.
if(player.getLocation().getY() <= -29999990) {
player.getLocation().setY(-29999990);
}
else if(player.getLocation().getY() >= 29999990) { // Fixes invalid movement disconnection.
// Fixes invalid movement disconnection.
else if(player.getLocation().getY() >= 29999990) {
player.getLocation().setY(29999990);
}
for(ItemStack item : player.getInventory()) {
if(mode == 2) {
// Removes enchants above level 5 and attributes if the security mode is strict.
if(mode == 2) {
for(ItemStack item : player.getInventory()) {
if(item != null && item.getItemMeta() != null) {
if(item.getItemMeta().getEnchants() != null && !item.getItemMeta().getEnchants().isEmpty()) {
for (Map.Entry entry : item.getItemMeta().getEnchants().entrySet()) {
@ -110,38 +119,48 @@ public class Patches extends NBTModifier implements Listener {
}
}
if(item.getItemMeta().getAttributeModifiers() != null && !item.getItemMeta().getAttributeModifiers().isEmpty()) {
else if(item.getItemMeta().getAttributeModifiers() != null && !item.getItemMeta().getAttributeModifiers().isEmpty()) {
clearItemMeta(item);
}
else if(item.hasItemMeta()) {
clearItemMeta(item);
}
}
} // Removes enchants above level 5 and attributes if the security mode is strict.
}
}
active_attributes.clear();
}
for(World world : Bukkit.getWorlds()) {
for(Entity entity : world.getEntities()) {
if(entity == null)
if(entity == null) {
continue;
}
// Remove Spawner Minecarts.
if(entity.getName().equalsIgnoreCase("Minecart with Spawner")) {
entity.remove(); // TODO: Make this configurable.
} // Remove Minecart Spawners.
}
// Remove crazy fireworks.
if((entity.getVelocity().getX() > 10.0D || entity.getVelocity().getY() > 10.0D || entity.getVelocity().getZ() > 10.0D || entity.getVelocity().getX() < -6.0D || entity.getVelocity().getY() < -6.0D || entity.getVelocity().getZ() < -6.0D)) {
if(entity.getName().equals("Firework Rocket"))
entity.remove();
else {
if(entity.getVelocity().getX() > 10.0D)
if(entity.getVelocity().getX() > 10.0D) {
entity.getVelocity().setX(10);
else if(entity.getVelocity().getY() > 10.0D)
}
else if(entity.getVelocity().getY() > 10.0D) {
entity.getVelocity().setY(10);
else if(entity.getVelocity().getZ() > 10.0D)
}
else if(entity.getVelocity().getZ() > 10.0D) {
entity.getVelocity().setZ(10);
}
}
} // Remove crazy fireworks.
}
}
} // Remove Spawner Minecarts.
}
}
}, 20L, 0); // Made the delay 20 ticks cause it's easier on the server.
}
@ -153,7 +172,7 @@ public class Patches extends NBTModifier implements Listener {
double speedZ = event.getTo().getZ() - event.getFrom().getZ();
double speed = Math.abs(speedX) + Math.abs(speedY) + Math.abs(speedZ);
if(speed > 5 || speed < -5) {
if(speed > 7 || speed < -7) {
event.setCancelled(true);
}
}

View file

@ -1,7 +1,7 @@
# VulnerabilityPatcher by CoolJWB.
# Patches: DeathPotions, DeathItems, CrashItems, Books, RougeEntity, Arrows, Riptide, FollowRange, DisconnectItems,
# EntityTag, Blocks, StructureBlocks, Chunks, ItemFrames, Handswitch, Fireworks, Chests, Beehives, Skulls.
# EntityTag, Blocks, StructureBlocks, Chunks, ItemFrames, HandSwitch, Fireworks, Chests, Beehives, Skulls, ItemNames.
# All patches added in the list below will be activated on server startup.
Patches:
- DeathPotions # Potions that kill creative players
@ -18,11 +18,12 @@ Patches:
- StructureBlocks # Used to modify the world
- Chunks # Spawn command that crashes the server
- ItemFrames # Item frames that crashes the server
- Handswitch # Hand switcher hack that crashes clients and possibly the server
- HandSwitch # Hand switcher hack that crashes clients and possibly the server
- Fireworks # Lags the clients when too many effects
- Chests # Disables chest drops fully to avoid large item drops
#- Containers # Disables container drops (chests and such) fully to avoid large item drops (only recommended for creative servers).
- Beehives # Removes all NBT data from any EntityBlockStorage such as beehives
- Skulls # Purges empty skull owner IDs
- ItemNames # Removes item names with events in them.
# All entities added below will be blocked to use in a spawn egg.
BlockedEntityTags:

View file

@ -1,9 +1,9 @@
name: VulnerabilityPatcher
version: "1.6"
version: "1.8"
api-version: 1.13
main: me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher
authors: [CoolJWB]
description: Patches vurnelabilities that cause server instabilaty.
description: Patches vulnerabilities that cause server instabilaty.
commands:
vulnerabilitypatcher:
aliases: [vp]