Skip to content

Instantly share code, notes, and snippets.

@No-Eul
Created August 11, 2024 18:54
Show Gist options
  • Save No-Eul/c094aef9dbdc48c80567562bad1b6cfb to your computer and use it in GitHub Desktop.
Save No-Eul/c094aef9dbdc48c80567562bad1b6cfb to your computer and use it in GitHub Desktop.
JVMCrasher
import sun.misc.Unsafe;
import java.lang.invoke.MethodHandles;
public class Main {
public static void main(String[] args) throws Throwable {
Unsafe unsafe = (Unsafe) MethodHandles.privateLookupIn(Unsafe.class, MethodHandles.lookup())
.findStaticGetter(Unsafe.class, "theUnsafe", Unsafe.class)
.invoke();
unsafe.setMemory(0L, 1L, (byte) 0);
}
}
// Jshell snippet
Unsafe unsafe = (Unsafe) MethodHandles.privateLookupIn(Unsafe.class, MethodHandles.lookup())
.findStaticGetter(Unsafe.class, "theUnsafe", Unsafe.class)
.invoke();
unsafe.setMemory(0L, 1L, (byte) 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment