File tree Expand file tree Collapse file tree 4 files changed +32
-7
lines changed
jmg-core/src/main/java/jmg/core
jmg-gui/src/main/java/jmg/gui/form Expand file tree Collapse file tree 4 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,26 @@ public void setJarClassName(String jarClassName) {
410
410
411
411
private String jarClassName ;
412
412
413
+ public byte [] getBytesInLoader () {
414
+ return bytesInLoader ;
415
+ }
416
+
417
+ public void setBytesInLoader (byte [] bytesInLoader ) {
418
+ this .bytesInLoader = bytesInLoader ;
419
+ }
420
+
421
+ private byte [] bytesInLoader ;
422
+
423
+ public String getClassNameInLoader () {
424
+ return classNameInLoader ;
425
+ }
426
+
427
+ public void setClassNameInLoader (String classNameInLoader ) {
428
+ this .classNameInLoader = classNameInLoader ;
429
+ }
430
+
431
+ private String classNameInLoader ;
432
+
413
433
public void build () {
414
434
// 检查 serverType、modelType、formatType 是否已设置
415
435
if (this .toolType == null || this .serverType == null || this .shellType == null || this .outputFormat == null || this .gadgetType == null ) {
@@ -429,8 +449,6 @@ public void build() {
429
449
this .setShellClassName (ClassNameUtil .getRandomShellClassName (this .getShellType ()));
430
450
if (this .getShellSimpleClassName () == null )
431
451
this .setShellSimpleClassName (CommonUtil .getSimpleName (this .getShellClassName ()));
432
- if (this .getOutputFormat ().contains (Constants .FORMAT_BCEL ))
433
- this .setLoaderClassName (ClassNameUtil .getRandomLoaderClassName ());
434
452
this .setSavePath (CommonUtil .getFileOutputPath (this .getOutputFormat (), this .getInjectorSimpleClassName (), this .getSavePath ()));
435
453
}
436
454
}
Original file line number Diff line number Diff line change 1
1
package jmg .core .format ;
2
2
3
3
import jmg .core .config .AbstractConfig ;
4
+ import jmg .core .util .ClassNameUtil ;
4
5
import me .gv7 .woodpecker .bcel .HackBCELs ;
5
6
6
7
import java .io .IOException ;
@@ -9,7 +10,15 @@ public class BCELFormater implements IFormater {
9
10
10
11
11
12
public byte [] transform (byte [] clazzbyte , AbstractConfig config ) throws IOException {
12
- // 解决 BCEL 的classloader 的问题
13
+ // 解决 BCEL ClassLoader 带来的问题
14
+ if (config .isEnabledExtender ()){
15
+ config .setBytesInLoader (config .getExtenderBytes ());
16
+ config .setClassNameInLoader (config .getExtenderClassName ());
17
+ }else {
18
+ config .setBytesInLoader (config .getInjectorBytes ());
19
+ config .setClassNameInLoader (config .getInjectorClassName ());
20
+ }
21
+ config .setLoaderClassName (ClassNameUtil .getRandomLoaderClassName ());
13
22
byte [] bcelClzBytes = BCELoaderGenerator .generatorBCELoaderClass (config );
14
23
return HackBCELs .encode (bcelClzBytes ).getBytes ();
15
24
}
Original file line number Diff line number Diff line change @@ -17,9 +17,9 @@ public static byte[] generatorBCELoaderClass(AbstractConfig config) {
17
17
ctClass .setName (config .getLoaderClassName ());
18
18
ctClass .getClassFile ().setVersionToJava5 ();
19
19
CtMethod getClassName = ctClass .getDeclaredMethod ("getClassName" );
20
- getClassName .setBody (String .format ("{return \" %s\" ;}" , config .getInjectorClassName ()));
20
+ getClassName .setBody (String .format ("{return \" %s\" ;}" , config .getClassNameInLoader ()));
21
21
CtMethod getBase64String = ctClass .getDeclaredMethod ("getBase64String" );
22
- String base64ClassString = encodeToBase64 (config .getInjectorBytes ()).replace ( System . lineSeparator () , "" );
22
+ String base64ClassString = encodeToBase64 (config .getBytesInLoader ()).replaceAll ( "[ \\ s* \t \n \r ]" , "" );
23
23
String [] parts = splitChunks (base64ClassString , 40000 );
24
24
StringBuilder result = new StringBuilder ();
25
25
for (int i = 0 ; i < parts .length ; i ++) {
Original file line number Diff line number Diff line change @@ -382,8 +382,6 @@ public void initConfig(AbstractConfig config) {
382
382
config .setUrlPattern ("/*" );
383
383
}
384
384
}
385
- if (config .getOutputFormat ().contains (Constants .FORMAT_BCEL ))
386
- config .setLoaderClassName (ClassNameUtil .getRandomLoaderClassName ());
387
385
config .setInjectorSimpleClassName (CommonUtil .getSimpleName (config .getInjectorClassName ()));
388
386
389
387
}
You can’t perform that action at this time.
0 commit comments