MCPcopy Create free account
hub / github.com/ax1sX/MemShell / ClassToBase64

Class ClassToBase64

SpringMVCMemShell/src/main/java/ClassToBase64.java:11–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import java.util.Base64;
10
11public class ClassToBase64 {
12 public static void main(String[] args) throws IllegalAccessException, IOException, InstantiationException {
13 String s = fileToBase64("/xx/classes/TestInterceptor.class");
14 }
15 public static String fileToBase64(String filePath) throws IOException, IllegalAccessException, InstantiationException {
16 File file = new File(filePath);
17 FileInputStream inputFile = new FileInputStream(file);
18 byte[] buffer = new byte[(int) file.length()];
19 inputFile.read(buffer);
20 inputFile.close();
21 byte[] bs = Base64.getEncoder().encode(buffer);
22 System.out.println(new String(bs));
23 return new String(bs);
24 }
25
26 private static String classToBcel(String classFileName) throws IOException {
27 Path path = Paths.get(classFileName);
28 byte[] bytes = Files.readAllBytes(path);
29 String result = Utility.encode(bytes,true);
30 return "$$BCEL$$" + result;
31 }
32
33}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected