Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

Commit

Permalink
Bibliocraft network patch (#6)
Browse files Browse the repository at this point in the history
* Added GC Time Command Fix

* Added fixes for bibliocraft network vulnerability
  • Loading branch information
bartimaeusnek authored Apr 4, 2021
1 parent cfb990e commit 44b6a73
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repositories {
}
}

version = "0.0.4"
version = "0.0.5"
group = "com.github.bartimaeusnek.modmixins"
archivesBaseName = "modmixins"

Expand Down Expand Up @@ -99,7 +99,7 @@ def refMapForYourConfig = 'mixins.modmixins.refmap.json'
repositories {
maven {
name = "sponge"
url = "http://repo.spongepowered.org/maven/"
url = "https://repo.spongepowered.org/maven/"
}
}

Expand Down
Binary file added libs/BiblioCraft[v1.11.7][MC1.7.10].jar
Binary file not shown.
11 changes: 11 additions & 0 deletions libs/BiblocraftCreditForLicense.txt
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object LoadingConfig {
fixExplosionPollution = config["fixes", "fixExplosionPollution", true, "Adds Pollution to every Explosion"].boolean
fixRocketPollution = config["fixes", "fixRocketPollution", true, "Adds Pollution to every rocket start"].boolean
fixZtonesNetworkVulnerability = config["fixes", "fixZtonesNetworkVulnerability", true, "Fixes Ztones Network Vulnerability"].boolean
fixBibliocraftNetworkVulnerability = config["fixes", "fixBibliocraftNetworkVulnerability", true, "Fixes Bibliocraft Network Vulnerability"].boolean
fixTimeCommandGc = config["fixes", "fixTimeCommandGc", true, "Fixes GC Time Command without creating lag"].boolean
rocketPollution = config["options","rocketPollution", 10000, "Pollution when starting per second, min 1!", 1 , Int.MAX_VALUE].int
furnacePollution = config["options","furnacePollution", 20, "Furnace pollution per second, min 1!", 1 , Int.MAX_VALUE].int
Expand All @@ -34,11 +35,12 @@ object LoadingConfig {
var fixThaumcraftFurnacePollution : Boolean = false
var fixExplosionPollution : Boolean = false
var fixZtonesNetworkVulnerability : Boolean = false
var fixBibliocraftNetworkVulnerability : Boolean = false
var furnacePollution : Int = 20
var rocketPollution : Int = 1
var explosionPollution : Float = 333.34f
var cokeOvenPollution : Int = 20;
var fireboxPollution : Int = 40;
var advancedCokeOvenPollution: Int = 80;
var hobbyistEnginePollution: Int = 20;
var cokeOvenPollution : Int = 20
var fireboxPollution : Int = 40
var advancedCokeOvenPollution: Int = 80
var hobbyistEnginePollution: Int = 20
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ class ModMixinsPlugin : IMixinConfigPlugin {
"vanilla.world.ExplosionPollutionAdder"
)
),
BIBLIOCRAFT_PACKAGE_FIX(
"BiblioCraft Network Vulnerability",
{ LoadingConfig.fixBibliocraftNetworkVulnerability },
"BiblioCraft",
arrayOf(
"bibliocraft.network.PackageFix"
)
),
ZTONES_PACKAGE_FIX(
"Ztones Network Vulnerability",
{ LoadingConfig.fixZtonesNetworkVulnerability },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import thaumcraft.api.ItemApi
import java.text.NumberFormat

Expand All @@ -38,7 +40,7 @@ object ModMixinsMod {
const val DEPENDENCIES = "required-after:spongemixins;" +
"required-after:forgelin;" +
"required-after:gregtech;"

val log: Logger = LogManager.getLogger(NAME)

@Mod.EventHandler
fun preinit(init : FMLPreInitializationEvent) {
Expand Down
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()
}

}

0 comments on commit 44b6a73

Please sign in to comment.