This repository has been archived by the owner on Oct 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added GC Time Command Fix * Added fixes for bibliocraft network vulnerability
- Loading branch information
1 parent
cfb990e
commit 44b6a73
Showing
7 changed files
with
91 additions
and
7 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
Binary file not shown.
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,11 @@ | ||
[...]unless included in a mod pack consisting of two or more mods. In the case of mod packs, all I ask is that proper | ||
credit is given to myself, the OWNER, for any of my works used and a link is provided so all recipients of said mod pack | ||
can easily access my website. (http://www.bibliocraftmod.com) [...] | ||
|
||
(This libs folder is basically dev-modpack.) | ||
|
||
[...]Use of this MOD to be installed, manually or automatically, is given to the USER without restriction.[...] | ||
|
||
(No restriction? Great! That means i can install this mod in this dev-modpack.) | ||
|
||
http://www.bibliocraftmod.com |
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
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
61 changes: 61 additions & 0 deletions
61
src/main/kotlin/com/github/bartimaeusnek/modmixins/mixins/bibliocraft/network/PackageFix.kt
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,61 @@ | ||
package com.github.bartimaeusnek.modmixins.mixins.bibliocraft.network | ||
|
||
import com.github.bartimaeusnek.modmixins.main.ModMixinsMod | ||
import cpw.mods.fml.common.network.ByteBufUtils | ||
import io.netty.buffer.ByteBuf | ||
import jds.bibliocraft.Config | ||
import jds.bibliocraft.items.ItemAtlas | ||
import jds.bibliocraft.network.ServerPacketHandler | ||
import jds.bibliocraft.tileentities.TileEntityMapFrame | ||
import net.minecraft.entity.player.EntityPlayerMP | ||
import net.minecraft.item.ItemMap | ||
import net.minecraft.item.ItemStack | ||
import org.spongepowered.asm.mixin.Mixin | ||
import org.spongepowered.asm.mixin.injection.At | ||
import org.spongepowered.asm.mixin.injection.Inject | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo | ||
|
||
@Mixin(value = [ServerPacketHandler::class]) | ||
class PackageFix { | ||
|
||
@Inject(method = ["transferWaypointsToAtlas"], at = [At(value = "HEAD")], remap = false, cancellable = true) | ||
private fun fixTransferWaypointsToAtlas(frameTile: TileEntityMapFrame, atlasStack: ItemStack, player: EntityPlayerMP, c: CallbackInfo) { | ||
if (atlasStack.item !is ItemAtlas) | ||
kickAndWarn(player, c, "BiblioAtlasGive") | ||
} | ||
|
||
@Inject(method = ["handleAtlasSwapUpdate"], at = [At(value = "HEAD")], remap = false, cancellable = true) | ||
private fun fixHandleAtlasSwapUpdate(packet: ByteBuf, player: EntityPlayerMP, c: CallbackInfo) { | ||
packet.markReaderIndex() | ||
val insecureStack = ByteBufUtils.readItemStack(packet) | ||
packet.resetReaderIndex() | ||
val inventoryTagList = insecureStack?.tagCompound?.getTagList("Inventory", 10) ?: return | ||
for (i in 0 .. inventoryTagList.tagCount()) { | ||
if (ItemStack.loadItemStackFromNBT(inventoryTagList.getCompoundTagAt(i)).item !is ItemMap) | ||
kickAndWarn(player, c, "BiblioFrameGive") | ||
} | ||
} | ||
|
||
@Inject(method = ["handleBookEdit"], at = [At(value = "HEAD")], remap = false, cancellable = true) | ||
private fun fixHandleBookEdit(packet: ByteBuf, player: EntityPlayerMP, c: CallbackInfo) { | ||
packet.markReaderIndex() | ||
val insecureStack = ByteBufUtils.readItemStack(packet) | ||
packet.resetReaderIndex() | ||
val namePrior = insecureStack.displayName | ||
insecureStack.func_135074_t() | ||
val nameAfter = insecureStack.displayName | ||
|
||
if (namePrior == nameAfter || Config.testBookValidity(insecureStack)) | ||
return | ||
|
||
kickAndWarn(player, c,"BiblioTableGive") | ||
c.cancel() | ||
} | ||
|
||
private fun kickAndWarn(player: EntityPlayerMP, c: CallbackInfo, exploitName : String) { | ||
player.playerNetServerHandler.kickPlayerFromServer(player.displayName + " tried to cheat with \"$exploitName\"-Exploit!") | ||
ModMixinsMod.log.error(player.displayName + " tried to cheat with \"$exploitName\"-Exploit!") | ||
c.cancel() | ||
} | ||
|
||
} |