Skip to content

Instantly share code, notes, and snippets.

@mwulftange
Created March 3, 2015 09:22
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 mwulftange/d11bd5711e85d0f0b097 to your computer and use it in GitHub Desktop.
Save mwulftange/d11bd5711e85d0f0b097 to your computer and use it in GitHub Desktop.
$@|sh – Or: Getting a shell environment from Runtime.exec (http://codewhitesec.blogspot.com/2015/03/sh-or-getting-shell-environment-from.html)
import java.io.*;
public class Exec {
public static void main(String[] args) throws IOException {
Process p = Runtime.getRuntime().exec(args[0]);
byte[] b = new byte[1];
while (p.getErrorStream().read(b) > 0)
System.out.write(b);
while (p.getInputStream().read(b) > 0)
System.out.write(b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment