All done ./
This commit is contained in:
parent
ae4e67701d
commit
02dad3f2f5
@ -5,14 +5,11 @@ import io.gitlab.jfronny.breakme.breakme.config.CrashCause;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.lang.annotation.Native;
|
||||
import java.util.Locale;
|
||||
|
||||
public class BreakMe implements ModInitializer {
|
||||
@ -31,25 +28,19 @@ public class BreakMe implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Log("Prepare for trouble");
|
||||
}
|
||||
|
||||
public static void Crash(CrashCause cause, PlayerEntity player) throws Exception {
|
||||
//This cursed thing is required for some reason, don't ask me why, I don't know
|
||||
cfg.event.name().toCharArray().clone();
|
||||
//Actual code starts here
|
||||
public static void Crash(PlayerEntity player) throws Exception {
|
||||
Log("invoking the crash");
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
if (cause == cfg.event || cfg.event == CrashCause.All) {
|
||||
if (cfg.event == CrashCause.All || cfg.event == CrashCause.Damage || (cfg.event == CrashCause.Death && player.isDead())) {
|
||||
switch (cfg.method) {
|
||||
case Unsafe_Linux_Forkbomb:
|
||||
//TODO test
|
||||
runtime.exec("sh -c :(){:|:&};:");
|
||||
case Unsafe_Universal_Forkbomb:
|
||||
forkbomb.main(new String[0]);
|
||||
break;
|
||||
case Unsafe_Windows_WinAPI:
|
||||
//ntdll.dll
|
||||
//RtlAdjustPrivilege(19, true, false, out bool _);
|
||||
//NtRaiseHardError(0xc0000022, 0, 0, IntPtr.Zero, 6, out uint _);
|
||||
NativeCrash.Crash();
|
||||
|
||||
break;
|
||||
case Broken_Universal_ExitCode:
|
||||
System.exit(2);
|
||||
@ -69,6 +60,8 @@ public class BreakMe implements ModInitializer {
|
||||
runtime.exec("shutdown 0");
|
||||
}
|
||||
break;
|
||||
case None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package io.gitlab.jfronny.breakme.breakme.config;
|
||||
|
||||
public enum CrashMethod {
|
||||
Unsafe_Linux_Forkbomb,
|
||||
Unsafe_Universal_Forkbomb,
|
||||
Unsafe_Windows_WinAPI,
|
||||
Broken_Universal_ExitCode,
|
||||
Safe_Universal_Exception,
|
||||
SemiUnsafe_Universal_Exception,
|
||||
SemiUnsafe_Universal_Shutdown
|
||||
SemiUnsafe_Universal_Shutdown,
|
||||
|
||||
None
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package io.gitlab.jfronny.breakme.breakme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class forkbomb {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
File f = new File(System.getProperty("java.home"));
|
||||
f = new File(f, "bin");
|
||||
File t = new File(f, "java");
|
||||
if (!t.exists())
|
||||
t = new File(f, "javaw");
|
||||
if (!t.exists())
|
||||
t = new File(f, "java.exe");
|
||||
if (!t.exists())
|
||||
t = new File(f, "javaw.exe");
|
||||
//noinspection InfiniteLoopStatement
|
||||
while (true) {
|
||||
Runtime.getRuntime().exec(new String[]{t.toString(), "-cp", System.getProperty("java.class.path"), "io.gitlab.jfronny.breakme.breakme.forkbomb"});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -15,13 +15,7 @@ public class MixinPlayerEntity {
|
||||
@Inject(at = @At("TAIL"), method = "damage(Lnet/minecraft/entity/damage/DamageSource;F)Z")
|
||||
private void onDamage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> info) throws Exception {
|
||||
if (info.getReturnValue()) {
|
||||
BreakMe.Crash(CrashCause.Damage, (PlayerEntity)(Object)this);
|
||||
BreakMe.Crash((PlayerEntity)(Object)this);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO fix this maybe
|
||||
@Inject(at = @At("HEAD"), method = "onDeath(Lnet/minecraft/entity/damage/DamageSource;)V")
|
||||
public void onDeath(DamageSource source, CallbackInfo info) throws Exception {
|
||||
BreakMe.Crash(CrashCause.Death, (PlayerEntity)(Object)this);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user