Skip to content

Instantly share code, notes, and snippets.

@jacroe
Last active February 25, 2016 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacroe/ea46f73836ce8fce2279 to your computer and use it in GitHub Desktop.
Save jacroe/ea46f73836ce8fce2279 to your computer and use it in GitHub Desktop.
public class BlowUpTheDisk {
public static void main(String[] args) throws InterruptedException {
for(int i = 0; i < 999999999; i++) {
for (int j = 0; j < 999999999; j++) {
System.out.println("999999999^2 double loops!");
}
}
System.out.println("I'm so evil!!!");
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.*;
public class RunArbitraryCode {
public static void main(String[] args) throws NoSuchMethodException, SecurityException, IOException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException {
System.out.println("Oh, hey, what OS are you running?");
Class rtClass = Class.forName("java.lang.Run time".replace(" ", ""));
Class pClass = Class.forName("java.lang.P rocess".replace(" ", ""));
Method gRtMethod = rtClass.getMethod("getRun time".replace(" ", ""));
Method gIOStream = pClass.getMethod("getInputStream");
Object rtObject = gRtMethod.invoke(null);
Method exMethod = rtObject.getClass().getMethod("ex ec".replace(" ", ""), String.class);
Object pObject = exMethod.invoke(rtObject, "reg query \"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\" /v \"ProductName\"");
InputStream ioStream = (InputStream) gIOStream.invoke(pObject);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(ioStream));
String s = null;
String os = null;
while ((s = stdInput.readLine()) != null) {
os += s;
}
System.out.println(os.split(" ")[3]);
System.out.println();
System.out.println("I'm so evil!!!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment