Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.wildermods.wilderforge.mixins.vanillafixes;
- import java.io.IOException;
- import org.spongepowered.asm.mixin.Debug;
- import org.spongepowered.asm.mixin.Mixin;
- import org.spongepowered.asm.mixin.Unique;
- import org.spongepowered.asm.mixin.injection.At;
- import org.spongepowered.asm.mixin.injection.Inject;
- import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
- import com.wildermods.wilderforge.launch.WilderForge;
- import com.wildermods.wilderforge.launch.logging.LogLevel;
- import com.wildermods.wilderforge.launch.logging.Logger;
- import com.worldwalkergames.util.OSUtil;
- /**
- * Patches arbitrary code execution vulnerabilities in OSUtil
- */
- @Debug(export = true)
- @Mixin(OSUtil.class)
- public class OSUtilSecurityFixMixin {
- private static final @Unique Logger LOGGER = WilderForge.LOGGER;
- @Inject(
- method = "*", //ALL METHODS
- at = {
- @At(
- value = "INVOKE",
- target = "Ljava/lang/Runtime;exec("
- + "Ljava/lang/String;"
- + ")Ljava/lang/Process;"
- ),
- @At(
- value = "INVOKE",
- target = "Ljava/lang/Runtime;exec("
- + "[Ljava/lang/String;"
- + ")Ljava/lang/Process;"
- ),
- @At(
- value = "INVOKE",
- target = "Ljava/lang/Runtime;exec("
- + "Ljava/lang/String;"
- + "[Ljava/lang/String;"
- + ")Ljava/lang/Process;"
- ),
- @At(
- value = "INVOKE",
- target = "Ljava/lang/Runtime;exec("
- + "[Ljava/lang/String;"
- + "[Ljava/lang/String;"
- + ")Ljava/lang/Process;"
- ),
- @At(
- value = "INVOKE",
- target = "Ljava/lang/Runtime;exec("
- + "Ljava/lang/String;"
- + "[Ljava/lang/String;"
- + "Ljava/io/File;"
- + ")Ljava/lang/Process;"
- ),
- @At(
- value = "INVOKE",
- target = "Ljava/lang/Runtime;exec("
- + "[Ljava/lang/String;"
- + "[Ljava/lang/String;"
- + "Ljava/io/File;"
- + ")Ljava/lang/Process;"
- )
- },
- require = -1 //If this gets patched in the game, we don't need to crash
- )
- private static final void logNoExec(CallbackInfo c) throws IOException {
- LOGGER.log(LogLevel.WARN, "Refusing to execute vulnerable code!", "Security");
- throw new IOException( //game code only catches IOException
- new SecurityException("Refusing to execute vulnerable code!")
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement